11<template >
22 <div class =" ezuikit-js" >
33 <div >
4- <div id =" video-container" style =" width : 600 px ; height : 400px " ></div >
4+ <div id =" video-container" style =" height : 400px " ></div >
55 </div >
66 <div >
77 <button v-on:click =" init" >init</button >
1212 <button v-on:click =" startSave" >startSave</button >
1313 <button v-on:click =" stopSave" >stopSave</button >
1414 <button v-on:click =" capturePicture" >capturePicture</button >
15- <button v-on:click =" fullScreen " >fullScreen </button >
15+ <button v-on:click =" fullscreen " >fullscreen </button >
1616 <button v-on:click =" getOSDTime" >getOSDTime</button >
17- <button v-on:click =" ezopenStartTalk " >startTalk</button >
18- <button v-on:click =" ezopenStopTalk " >stopTalk</button >
17+ <button v-on:click =" startTalk " >startTalk</button >
18+ <button v-on:click =" stopTalk " >stopTalk</button >
1919 <button v-on:click =" destroy" >destroy</button >
2020 </div >
2121 </div >
2222</template >
2323
2424<script >
25- import { EZUIKitPlayer } from " ezuikit-js" ;
25+ // import { EZUIKitPlayer } from "ezuikit-js/index.js";
26+ import * as EZUIKit from ' ezuikit-js' ;
2627var player = null ;
2728
2829export default {
@@ -45,22 +46,20 @@ export default {
4546 // var accessToken = res.data.accessToken;
4647
4748 // });
48- player = new EZUIKitPlayer ({
49+ player = new EZUIKit. EZUIKitPlayer ({
4950 id: " video-container" , // 视频容器ID
5051 accessToken:
5152 " at.aw5w2pjo5qzpd0o07blbhl8e4tgrz9xm-58hpuns9dj-1csffwn-oelzubkb" ,
5253 url: " ezopen://open.ys7.com/BC7799091/1.hd.live" ,
5354 // simple: 极简版; pcLive: pc直播; pcRec: pc回放; mobileLive: 移动端直播; mobileRec: 移动端回放;security: 安防版; voice: 语音版;
5455 template: " pcLive" ,
55- // plugin: ["talk"], // 加载插件,talk-对讲
56- width: 600 ,
5756 height: 400 ,
5857 handleError : (error ) => {
5958 console .error (" handleError" , error);
6059 },
6160 // quality: 6, //
6261 language: " en" , // zh | en
63- // staticPath: "/ezuikit_static", // 如果想使用本地静态资源,请复制根目录下ezuikit_static 到当前目录下, 然后设置该值
62+ // staticPath: ". /ezuikit_static", // 如果想使用本地静态资源,请复制根目录下ezuikit_static 到当前目录下, 然后设置该值
6463 env: {
6564 // https://open.ys7.com/help/1772?h=domain
6665 // domain默认是 https://open.ys7.com, 如果是私有化部署或海外的环境,请配置对应的domain
@@ -92,90 +91,107 @@ export default {
9291 // ],
9392 });
9493
95- player .eventEmitter .on (EZUIKitPlayer .EVENTS .videoInfo , (info ) => {
96- console .log (" videoinfo" , info);
94+
95+ // 8.1.x 事件监听
96+ // player.eventEmitter.on(EZUIKitPlayer.EVENTS.videoInfo, (info) => {
97+ // console.warn("eventEmitter videoInfo", info);
98+ // });
99+ // 8.2.x 事件监听
100+ player .on (EZUIKitPlayer .EVENTS .videoInfo , (info ) => {
101+ console .warn (" videoInfo" , info);
97102 });
98103
99- player .eventEmitter .on (EZUIKitPlayer .EVENTS .audioInfo , (info ) => {
100- console .log (" audioInfo" , info);
104+ // 8.1.x 事件监听
105+ // player.eventEmitter.on(EZUIKitPlayer.EVENTS.audioInfo, (info) => {
106+ // console.warn("eventEmitter audioInfo", info);
107+ // });
108+ // 8.2.x 事件监听
109+ player .on (EZUIKitPlayer .EVENTS .audioInfo , (info ) => {
110+ console .warn (" audioInfo" , info);
101111 });
102112
103113 // 首帧渲染成功
104114 // first frame display
105- player .eventEmitter .on (EZUIKitPlayer .EVENTS .firstFrameDisplay , () => {
106- console .log (" firstFrameDisplay " );
115+ // 8.1.x 事件监听
116+ // player.eventEmitter.on(EZUIKitPlayer.EVENTS.firstFrameDisplay, () => {
117+ // console.warn("eventEmitter firstFrameDisplay ");
118+ // });
119+ // 8.2.x 事件监听
120+ player .on (EZUIKitPlayer .EVENTS .firstFrameDisplay , () => {
121+ console .warn (" firstFrameDisplay " );
107122 });
108- player .eventEmitter .on (EZUIKitPlayer .EVENTS .streamInfoCB , (info ) => {
109- console .log (" streamInfoCB " , info);
123+
124+ // 8.1.x 事件监听
125+ // player.eventEmitter.on(EZUIKitPlayer.EVENTS.streamInfoCB, (info) => {
126+ // console.warn("eventEmitter streamInfoCB ", info);
127+ // });
128+ // 8.2.x 事件监听
129+ player .on (EZUIKitPlayer .EVENTS .streamInfoCB , (info ) => {
130+ console .warn (" streamInfoCB " , info);
110131 });
111132
112133 window .player = player;
113134 },
114135 play () {
115- var playPromise = player . play ();
116- playPromise .then ((data ) => {
117- console .log (" promise 获取 数据" , data);
118- });
136+ if (player)
137+ player . play () .then ((data ) => {
138+ console .log (" play 获取 数据" , data);
139+ });
119140 },
120141 stop () {
121- var stopPromise = player . stop ();
122- stopPromise .then ((data ) => {
123- console .log (" promise 获取 数据" , data);
124- });
142+ if (player)
143+ player . stop () .then ((data ) => {
144+ console .log (" stop 获取 数据" , data);
145+ });
125146 },
126147 getOSDTime () {
127- var getOSDTimePromise = player . getOSDTime ();
128- getOSDTimePromise .then ((data ) => {
129- console .log (" promise 获取 数据" , data);
148+ if (player)
149+ player . getOSDTime () .then ((data ) => {
150+ console .log (" getOSDTime 获取 数据" , data);
130151 });
131152 },
132153 capturePicture () {
133- var capturePicturePromise = player .capturePicture (
154+ if (player)
155+ player .capturePicture (
134156 ` ${ new Date ().getTime ()} `
135- );
136- capturePicturePromise .then ((data ) => {
137- console .log (" promise 获取 数据" , data);
157+ ).then ((data ) => {
158+ console .log (" capturePicture 获取 数据" , data);
138159 });
139160 },
140161 openSound () {
141- var openSoundPromise = player .openSound ();
142- openSoundPromise .then ((data ) => {
143- console .log (" promise 获取 数据" , data);
144- });
162+ if (player) player .openSound ()
145163 },
146164 closeSound () {
147- var openSoundPromise = player .closeSound ();
148- openSoundPromise .then ((data ) => {
149- console .log (" promise 获取 数据" , data);
150- });
165+ if (player) player .closeSound ()
151166 },
152167 startSave () {
153- var startSavePromise = player . startSave ( ` ${ new Date (). getTime () } ` );
154- startSavePromise .then ((data ) => {
155- console .log (" promise 获取 数据" , data);
156- });
168+ if (player)
169+ player . startSave ( ` ${ new Date (). getTime () } ` ) .then ((data ) => {
170+ console .log (" startSave 获取 数据" , data);
171+ });
157172 },
158173 stopSave () {
159- var stopSavePromise = player . stopSave ();
160- stopSavePromise .then ((data ) => {
161- console .log (" promise 获取 数据" , data);
162- });
174+ if (player)
175+ player . stopSave () .then ((data ) => {
176+ console .log (" promise 获取 数据" , data);
177+ });
163178 },
164- ezopenStartTalk () {
165- player .startTalk ();
179+ startTalk () {
180+ if (player) player .startTalk ();
166181 },
167- ezopenStopTalk () {
168- player .stopTalk ();
182+ stopTalk () {
183+ if (player) player .stopTalk ();
169184 },
170- fullScreen () {
171- player . fullScreen ();
185+ fullscreen () {
186+ if ( player) player . fullscreen (); // 8.2.0 新增, 老版本使用 fullScreen()
172187 },
173188 destroy () {
174- var destroyPromise = player .destroy ();
175- destroyPromise .then ((data ) => {
176- console .log (" promise 获取 数据" , data);
177- });
178- player = null ;
189+ if (player) {
190+ player .destroy ().then ((data ) => {
191+ console .log (" promise 获取 数据" , data);
192+ });
193+ player = null ;
194+ }
179195 },
180196 },
181197};
0 commit comments