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 🙏

© 2025 – Pkg Stats / Ryan Hefner

oniot-playersdk

v0.0.24

Published

luoding`s npm

Downloads

8

Readme

web-sdk 功能描述

引用

  • import PlayerSDK from "PlayerSDK.min";

初始化

let player = new PlayerSDK({options})  

其中options设置:

  • id : 播放器实例化的时候需要明确DOM的占位,video将要输出到该DOM下,播放器的尺寸与占位DOM一致, 必填项;
  • url : 视频源地址 , 非必填项;
  • isLive: 是否是直播,用于切换播放器,true 时为flv, false 时为hls, 选填,默认为true
  • auto : 是否自动播放,选填,默认为true
  • width: 播放器宽度 数字;
  • height: 播放器高度 数字;
  • volume:预设音量大小。默认值:0.6,参考值:0 ~ 1;选填
  • socketServer: 用于建立socket连接更新token和获取设备状态,必填项(例:ws://172.19.3.59:18888/ws/devices?token=test)
  • registerDeviceEvent : 是否注册设备事件。默认false
  • product_id:如果 registerDeviceEvent 为true , 则为必填项
  • device_id: 如果 registerDeviceEvent 为true , 则为必填项

方法

  • 直播地址 player.flvUrl //返回当前SDK中是否有flv 地址
  • 播放直播 player.playLive()
  • 播放暂停 player.pause()
  • 恢复播放 player.resume() //该方法用于直播地址初始化正常情况下,回放切换直播,如若直播地址初始化为空,请调用 player.playLiveUrl(flv)方法 重置直播
  • 停止播放 player.stop()
  • 进入全屏 player.getCssFullscreen()
  • 退出全屏 player.exitCssFullscreen()
  • 切换直播源 player.switchLive(newUrl)
  • 销毁播发器 player.destroy(boolean) // true 删除内部DOM元素 | false 保留内部DOM元素,默认为true
  • 重置直播地址 player.playLiveUrl(flvurl) // 其中flvUrl是可播放的直播地址(必须是FLV协议),参数不能为空
  • 回播 player.playAtTime(start_time,end_time,urlData) 其中start_time 和 urlData为必填项,urlData为一个数组, 包含了多个回放视频信息
  • 初始化对话通道 player.initTalk() //初始成功后即进入对话状态
  • 停止对话 player.stopTalk()
  • 开始对话 play.startTalk()
     [{
         "end_time": "2020-03-23 09:57:45",
         "hls_url": "https://v-test.cmcconenet.com:8443/vod/33713/33875316_1/33875316115849267512601584926813805.m3u8",
         "start_time": "2020-03-23 09:25:51",
         "videoid": "33875316115849267512601584926813805"
     }, {
         "end_time": "2020-03-23 10:29:48",
         "hls_url": "https://v-test.cmcconenet.com:8443/vod/33713/33875316_1/33875316115849286657901584928727800.m3u8",
         "start_time": "2020-03-23 09:57:45",
     }
        ...
     ]

事件

  • 初始化成功 PLAYER_INIT
  • 播放器缓存了资源可播放时触发 PLAYER_CAN_PLAY
  • 视频加载过程触发 PLAYER_PLAY_LOADING
  • 开始播放 PLAYER_PLAY
  • 持续播放 PLAYER_PLAYING
  • 播放暂停 PLAYER_PAUSE
  • 当前播放时间变化时触发 PLAYER_TIME_CHANGE
  • 回播视频结束时触发 REVIEW_END
  • 设备离线时触发 DEVICE_ONLINE_OFFLINE_CHANGE
  • 实例:
   player.Events("PLAYER_INIT",()=>{
      console.log("可以播放了")
   })