# cmiot-playersdk

> sindlly`s npm

Latest version **0.0.16** (published 2020-05-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install cmiot-playersdk
pnpm add cmiot-playersdk
yarn add cmiot-playersdk
bun add cmiot-playersdk
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.16 |
| Published | 2020-05-06 |
| First published | 2020-03-17 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Unpacked size | 891.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | sindlly |

## Links

- npm: https://www.npmjs.com/package/cmiot-playersdk
- npm.io page: https://npm.io/package/cmiot-playersdk

## Dependencies (10)

- [scp2](https://npm.io/package/scp2.md) ^0.5.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [xgplayer](https://npm.io/package/xgplayer.md) ^2.6.19
- [uupaa.aac.js](https://npm.io/package/uupaa.aac.js.md) ^0.4.3
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.8.7
- [@babel/polyfill](https://npm.io/package/@babel/polyfill.md) ^7.8.7
- [xgplayer-flv.js](https://npm.io/package/xgplayer-flv.js.md) ^2.1.1
- [xgplayer-hls.js](https://npm.io/package/xgplayer-hls.js.md) ^2.2.0
- [@babel/runtime-corejs2](https://npm.io/package/@babel/runtime-corejs2.md) ^7.8.7
- [@babel/plugin-transform-modules-commonjs](https://npm.io/package/@babel/plugin-transform-modules-commonjs.md) ^7.8.3

## Recent versions

- 0.0.16 (latest) — 2020-05-06
- 0.0.15 — 2020-05-06
- 0.0.14 — 2020-05-06
- 0.0.13 — 2020-05-06
- 0.0.12 — 2020-05-06
- 0.0.11 — 2020-04-27
- 0.0.10 — 2020-04-27
- 0.0.9 — 2020-04-26
- 0.0.8 — 2020-04-26
- 0.0.7 — 2020-04-24
- 0.0.6 — 2020-03-30
- 0.0.5 — 2020-03-19
- 0.0.4 — 2020-03-18
- 0.0.3 — 2020-03-17
- 0.0.2 — 2020-03-17
- … 1 more at https://npm.io/package/cmiot-playersdk/versions

## 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.playLive()
 * 播放暂停  player.pause()
 * 恢复播放  player.resume()
 * 停止播放  player.stop()
 * 进入全屏  player.getCssFullscreen()
 * 退出全屏  player.exitCssFullscreen()
 * 切换直播源 player.switchLive(newUrl) 
 * 销毁播发器 player.destroy(boolean) // true 删除内部DOM元素 | false 保留内部DOM元素，默认为true
 * 回播 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("可以播放了")
>    })
>```

---
_Source: https://npm.io/package/cmiot-playersdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
