1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- import WebSocketServer from './websocketServer.js';
- class Player {
- constructor(option) {
- this.ws = null;
- this.options = option;
- this.events = {
- error: ()=>{}
- };
- }
- init() {
- //console.log('init');
- this.ws = new WebSocketServer(this.options);
- this.ws.init();
- }
- connect() {
- for(let i in this.events) {
- this.ws.setCallBack(i, this.events[i]);
- }
- this.ws.connect();
- }
- play() {
- //console.log('player')
- }
- pause() {
- //console.log('pause')
- }
- close() {
- this.ws.close();
- //console.log('close1')
- }
- /**
- * 绘制额外信息
- * @param obj
- */
- updateInfo(obj) {
- this.ws.updateInfo(obj);
- }
- setROI(data) {
- this.ws.setROI(data);
- }
- resetROI() {
- this.ws.resetROI();
- }
- getROIData() {
- return this.ws.getROIData();
- }
- setPolygonNum(num) {
- return this.ws.setPolygonNum(num);
- }
- /**
- * 自定义事件
- * 目前支持如下事件
- * [error] websocket连接失败
- * [noStream] 收不到码流
- * [canplay] 视频能够播放时触发
- * [initialCompleted] 视频初始化完成, 首次canplay
- * [ROIFinished] 手动绘制ROI完成时触发
- *
- * @param event 事件名
- * @param callback 事件响应函数
- */
- on(event, callback) {
- this.events[event] = callback;
- }
- }
- export default Player;
|