npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pretty-video

v3.1.0

Published

基于video标签自定义播放器,原video播放器各个浏览器表现不一,自定义video控制栏

Readme

video播放器

  • 不依赖三方库,TypeSrcipt + less + html编写, 使用 webpack 将less,ts,html,svg打包umd模块方便各种方式引入, 自定义video控制条。
  • 自定义 进度条、进度条拖动、音量控制、倍速切换、全屏 等基础功能。
  • 完全基于video标签实现,只是单纯自定义了控制条,支持视频格式参考video标签。
  • 简单处理了 移动端 和 PC端 的事件兼容,例如拖动事件、鼠标移入进度条事件等。
  • PS:原生video标签各个浏览器样式不一,并且总感觉不好看,所以自己实现了个简单的播放器,后期有时间会扩展, 清晰度 、 选集 功能,如有需要自行修改源码,源码大部分都有注释,有点乱(捂脸),代码水平有限,大佬轻喷,欢迎issue.

install

npm install pretty-video; import PrettyVideo from 'pretty-video';

使用

 // 直接浏览器标签引入
 <body>
     <div id="MyVideo"></div>
    <script type="text/javascript" src="./video.bundle.js"></script></body>
    <script type="text/javascript">
        window.onload = function () {
            var video = document.getElementById('MyVideo');
            var myVideo = new PrettyVideo();
            myVideo.init(video, {
                src: 'http://vfx.mtime.cn/Video/2019/03/19/mp4/190319222227698228.mp4',
                poster: 'http://a3.att.hudong.com/68/61/300000839764127060614318218_950.jpg',
            });
        }
    </script>
 </body>

 // es6
 import PrettyVideo from 'video.bundle';

 const myVideo = new PrettyVideo();
 myVideo.init(elId, obj: Config);

API

// config
export interface Config {
    /** 视频加载是否自动播放 默认false */
    autoplay?: boolean;
    /** 播放地址 */
    src?: string;
    /** 封面 */
    poster?: string;
    /** 是否自动隐藏控制栏 controls 为 true 有效*/
    autoHideControls?: boolean;
    /** 是否允许点击、拖动进度条跳转进度 默认true*/
    isFastForward?: boolean;
    /** 是否隐藏全屏按钮 默认fasle*/
    hideFullScreen?: boolean;
    /** 显示控制条 默认true */
    controls?: boolean;
    /** 视频结束是否循环播放 */
    loop?: boolean;
    /** 预加载 默认 auto*/
    preload?: 'auto' | 'meta' | 'none';
}
// 方法
export default class PrettyVideo {
    /** 初始化 */
    init(el: string | HTMLElement, config: Config): void;
    /** 获取当前播放时长和总时长 */
    getDuration(): { currentSecond: number, durationSecond: number, currentText: string, durationText: string };
    /** 修改config */
    setupConfig(newConfig: Config): void;
    /** 修改播放地址 */
    setUrl(obj: { src: string, poster?: string }): void;
    /** 重置播放 */
    reload(): void;
    /** 播放 */
    play(): void;
    /** 暂停 */
    pause(): void;
     /** 是否暂停状态 */
    isPause(): boolean;
     /** 设置音量 0-1 */
    setVolum(num: number): void;
    /** 监听事件 'loadstart' | 'canplay' | 'play' | 'pause' | 'waiting' | 'playing' | 'ended' | 'error' | 'seeked' | 'loadedmetadata' */
    on(eventName: string, callback: () => {}): void;
    /** 取消事件监听 */
    unOn(eventName: string): void
    /** 销毁video包括dom元素 */
    dispose(): void
}

其他

  1. IE兼容 iE10+