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

imperception-player

v1.0.12

Published

无感知播放器

Readme

imperception-player

无感知播放器

支持视频无缝切换同时支持视频扣绿

DOC

调用

import ImperceptionPlayer from "imperception-player";

const player = new ImperceptionPlayer();

<script type="text/javascript" src="../dist/index.js"></script>;

const player = new ImperceptionPlayer();

初始化

interface IOption {
  //视频播放结束的回调
  onVideoEnded?: (url: string) => void;
  //默认地址,如果传入则默认播放,且每次视频播放完成切换到默认视频
  defaultUrl?: string;
  //处理配置
  processOptions?: {
    //是否开启视频扣绿
    videoGreenCutout: boolean;
    //视频扣绿颜色
    videoGreenCutoutColor: number | string;
    //扣绿后画板分辨率倍率(适当调整,过高会有问题)
    pixelRatio: number
  };
  //是否将视频地址转换成blob再播放,默认true(可以解决部分移动端浏览器捕获视频资源问题,但会提高每次切换延迟,如果不涉及移动端可以自行取消)
  isUrlToBlob?: boolean;
}

/**
 *
 * @param id 播放器容器id
 * @param options {Ioption}
 */
player.init();

暂停

player.pause();

播放

player.play();

更改音量

/**
 * 更改音量
 * @param num 音量
 * @returns
 */
player.setVol(num);

切换播放地址

/**
 * 更改播放地址
 * @param url 播放地址
 * @returns 返回Promise代表视频切换并成功显示在屏幕上
 */
player.setUrl(url);

销毁

player.destroy();

重新绑定部分事件,用于类似 react hooks 中 state 更改后回调无法获取最新数据的问题

/**
 * 重新绑定部分事件,用于类似react hooks中state更改后回调无法获取最新数据的问题
 * @param onVideoEnded 视频播放结束的回调
 */
player.ReBindEventListener(onVideoEnded);

更改播放器属性

/**
 * 更改播放器属性
 * @param attr 属性名
 * @param value 属性值
 * @param isCache 是否对更改属性做缓存,部分属性在播放器地址更改后会被重置,此时如需要保留则设置为true
 * @returns
 */
player.setVideoAttr("playbackRate", 0.5, true);

获取当前正在播放的 dom 节点

//当前正在播放的dom节点,需要什么属性或状态可以直接获取
//不要去操作dom,因为播放器内部会进行一些操作,可能会导致播放器出错
player.playingDom;