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 🙏

© 2024 – Pkg Stats / Ryan Hefner

usc-player-sdk

v1.2.3

Published

usc player

Downloads

144

Readme

USC-PLAYER-SDK

安装和使用说明

  1. 安装
# 安装依赖
pnpm i usc-player-sdk

安装后在node_modules找到 usc-player-sdk的dist目录的文件(libffmpeg.js libffmpeg.wasm), 放在项目中或使用CDN

脚本方式引入, 播放器对象实例 new USC.USCPlayer()

// 与libffmpeg在相同目录
<script src="/path/to/index.js"></script>

es方式引用 播放器对象实例 new USCPlayer()

import { USCPlayer } from 'usc-player-sdk'
  1. 使用

HTML

  <div class="test">
    <!-- <canvas id="scr0"></canvas> --> 
    <video id="scr0" class="test"></video>
  </div>

JS 播放器参数 参考示例网页

  • url: 播放地址 (ws或wss协议)
  • code: 播放码流
  • mode: 模式, 取值 0 | 1 | 2 分别代表了canvas监控模式, canvas预览模式, video监控模式, mode=2时标签使用video
  • container: 容器 (上面HTML示例中容器为 scr0 )
  • libpath 库文件 libffmpeg文件的网络地址或本地地址
  import { USCPlayer } from 'usc-player-sdk'
  const { url, code, mode, container, libpath } = config
  const player = new USCPlayer({ url, code, container, mode, libpath })
  // 开始播放
  player.openPlayer()
  // 停止播放 true表示会在关闭后清空视频的内容, 默认false保留最后的画面
  player.closePlayer(true)
  // 动态切换, 在当前播放器切换视频源
  player.dynamicSwitchVideo('ws://47.98.215.65:1936', '2000000000100010')
  //显示事件(表示播放成功)
  player.on('frame', () => {
    console.log('start display first frame');
  })
  //视频大小事件(可用来监听横竖切换)
  player.on('size', (data) => {
    console.log('size: ', data);
  })

  // 播放器关闭事件(表示播放器此时已完全关闭)
  player.on('closed', () => {
    console.log('close success');
  })

  //错误事件(播放器初始化或播放过程中都可能触发该事件)
  /** e: { error: number, status: number, message: string, ref?: any }
   * status: -99 -504 -509 -511 ===> 连接超时;   -518 -513 ===> 播放失败(无流)
   */
  player.on('error', (e) => {
    console.log(e);
  })