Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bonc-htmlplayer

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bonc-htmlplayer - npm Package Compare versions

Comparing version 1.0.7 to 1.0.8

2

package.json
{
"name": "bonc-htmlplayer",
"version": "1.0.7",
"version": "1.0.8",
"description": "东方国信的html播放器内核",

@@ -5,0 +5,0 @@ "main": "./src/index.js",

@@ -0,26 +1,15 @@

[TOC]
# BonchH5Player 播放器内核接口文档
## 下载源码及安装配置
```
git clone https://code.bonc.com.cn/liuyuchao/civms_h5player.git
cd bonc-htmlplayer
npm install
# npm全局安装的路径配置到系统环境变量中,将项目的包放到全局目录下
npm link
```
环境变量如下图所示
## 描述
本项目包含一个h5播放器,接收相机传过来的h264流媒体数据。即可以通过git拉取源码使用,也可以通过npm安装适应。公司的私有npm需要连接公司的内网使用,我把播放器内核包放到了 https://code.bonc.com.cn/nexus/repository/npm-test/ 切换npm仓库地址后即可通过npm安装。同时,该npm包在公有npm上也有推送,所以可以直接执行“npm i bonc-htmlplayer”。播放视频的过程中需保证网络流畅,否则会造成丢包,引起花屏。
![环境变量](https://code.bonc.com.cn/fuqingyu/bonc-htmlplayer/blob/master/doc/environment_variable.png)
## 项目中使用
```
npm link bonc-htmlplayer
```
## 快速开始(基于react)
## 快速开始(基于react的demo)
```javascript
import React,{Component} from 'react';
import configs from './config'
import Html5Player from 'bonc-htmlplayer'
import Html5Player from 'bonc-htmlplayer'//播放器内核库
class App extends Component{

@@ -30,9 +19,5 @@

this._player = new Html5Player(configs);
//绑定回调(打开视频、准备完毕、断开连接)
this._player.on('startVideo',this.onOpen.bind(this));
this._player.on('startSuccess',this.onPlay.bind(this));
this._player.on('disconnectNetWork',this.onDisconnectNetWork.bind(this));
}
playVideo(){
var url = 'http://172.16.17.165:80/vms/deviceForChannel/openChanneltForHtml'
var url = 'http://172.16.17.165:80//vms/deviceForChannel/openChanneltForHtml'
var formData = new FormData();

@@ -82,3 +67,6 @@ var channelidstr = '334a578c72334d21a201656e246f4c25-0000'

```
## 注:
demo中的channelidstr这个通道id来自于接口(两种方式),具体用哪个字段,请参考文档以下两个接口的说明:
1.根据组织id获取编码设备以及编码设备下的通道
2.获取通道列表
## API

@@ -90,5 +78,5 @@

|videoId |是 |String | 视频的video标签的ID |
|centerInfo|否|object|包含中心服务器的url和摄像头通道id的对象 centerInfo:{centerUrl:'172.16.17.165',channelId:'334a578c72334d21a201656e246f4c25-0000'}
|centerInfo|否|object|包含中心服务器的url和摄像头通道id的对象 centerInfo:{centerUrl:'http://172.16.96.165:80//vms/deviceForChannel/openChanneltForHtml' ,channelId:'334a578c72334d21a201656e246f4c25-0000'}
例:
例1:
```javascript

@@ -100,2 +88,13 @@ var configs = {

```
例2:
```javascript
var configs = {
videoId : 'playerid',
centerInfo:{
centerUrl:'http://172.16.96.165:80//vms/deviceForChannel/openChanneltForHtml',
channelId:'334a578c72334d21a201656e246f4c25-0000'
}
};
this._player = new Html5Player(configs);
```

@@ -105,2 +104,3 @@ ## 实例方法

json:object,如果构造方法的配置项中指定了中心服务器地址和通道id,openVideo方法不再需要参数
|配置项|必选|类型|说明|

@@ -134,11 +134,20 @@ |:---- |:---|:----- |----- |

### closeVideo() 关闭视频
### fullScreen() 全屏
## 事件
### startVideo 开始播放
### on(event,function) 绑定事件的回调函数
|参数|类型|说明|
|:---- |:----- |----- |
|event|string|事件名称|
|function|function|事件的回调|
### off(event,function) 解绑定事件的回调 参数同上
### offAll() 解绑定所有事件的所有回调
### startSuccess 取流成功
## 事件及其回调
| 名称 | 说明 | 参数 |
| ------------ | ------------ | ------------ |
| startVideo |播放命令执行后,请求websocket服务之前 | |
| startSuccess |视频准备成功,开始播放之前 | |
| disconnectNetWork |网络异常断开后 | |
| currentTime |播放当前帧数据对应的时间|time:int 当前帧的unix时间,单位是ms
|imgInfo |抛出人脸序列的回调|e:人脸数据,类型ArrayBuffer
### disconnectNetWork 网络断开

@@ -275,3 +275,3 @@ import {extractNALubonc} from './utils'

{
if(nalType!=7 && nalType!=8)
if(nalType!=7 && nalType!=8 )
{

@@ -387,6 +387,10 @@ nalarr.push(nal);

})
if(bufferLength>2 && bufferLength<=3){
if(bufferLength>0){
this.app.node.play();
this.app.node.playbackRate = 1;
this.app.node.play();
}
else if(bufferLength>2 && bufferLength<=3){
this.app.node.playbackRate = 1;
}
else if(bufferLength>3 && bufferLength<=5){

@@ -393,0 +397,0 @@ this.app.node.playbackRate = 1.25;

@@ -92,9 +92,9 @@ import ByteArray from './ByteArray' ;

var biPlanes=socketBA.ReadUint16(true);//2字节
var biBitCount=socketBA.ReadUint16(true);
var biCompression=socketBA.ReadUint32(true);
var biSizeImage=socketBA.ReadUint32(true);
var biXPelsPerMeter=socketBA.ReadUint32(true);
var biYPelsPerMeter=socketBA.ReadUint32(true);
var biClrUsed=socketBA.ReadUint32(true);
var biClrImportant=socketBA.ReadUint32(true);
var biBitCount=socketBA.ReadUint16(true);//2字节
var biCompression=socketBA.ReadUint32(true);//4字节
var biSizeImage=socketBA.ReadUint32(true);//4字节
var biXPelsPerMeter=socketBA.ReadUint32(true);//4字节
var biYPelsPerMeter=socketBA.ReadUint32(true);//4字节
var biClrUsed=socketBA.ReadUint32(true);//4v
var biClrImportant=socketBA.ReadUint32(true);//4字节
// var timestamp=biXPelsPerMeter*1000 + Math.floor(biYPelsPerMeter/1000);

@@ -101,0 +101,0 @@ if(!this.start){

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc