1+ <!DOCTYPE html>
2+ < html lang ="zh-CN ">
3+
4+ < head >
5+ < meta charset ="UTF-8 ">
6+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge,chrome=1 ">
7+ < meta name ="renderer " content ="webkit ">
8+ < title > EZOPEN播放协议</ title >
9+ < style >
10+ body {
11+ margin : 0 ;
12+ }
13+ .hint {
14+ font-size : 14px ;
15+ line-height : 3em ;
16+ color : gray;
17+ }
18+ # url ,
19+ # url2 ,
20+ # urlList ,
21+ # accessToken {
22+ width : 100% ;
23+ }
24+
25+ .btn-container {
26+ margin : 10px ;
27+ }
28+ .normal {
29+ color : green;
30+ margin : 5px ;
31+ }
32+ .error {
33+ color : red;
34+ margin : 5px ;
35+ }
36+ </ style >
37+ </ head >
38+ < script >
39+ </ script >
40+
41+ < body >
42+ < script src ="../ezuikit.js "> </ script >
43+ <!-- <script src="../js/jsPlugin-1.2.0.js"></script> -->
44+ < script src ="../js/jquery.min.js "> </ script >
45+ < div class ="hint "> demo页面仅为代码示例无法直接运行,需要部署到服务器上才可以播放。另外监控模式与多窗口模式对浏览器版本有要求:Chrome: 55+ Firefox: V55+。</ div >
46+ < h2 > 预览,回放功能示例:</ h2 >
47+ < textarea id ="url " placeholder ="这里输入ezopen地址 "> ezopen://open.ys7.com/140428934/1.hd.live</ textarea >
48+ < textarea id ="accessToken " placeholder ="这里输入accessToken "> at.dvnc3iovbi3lh8881cmj41437jawxvz5-4g39a5ep63-0jevvyn-5o3uxbkut</ textarea >
49+ < textarea id ="urlList " placeholder ="这里输入ezopen地址 ">
50+ ezopen://open.ys7.com/105809781/1.hd.live,
51+ ezopen://open.ys7.com/108664727/1.hd.live,
52+ ezopen://open.ys7.com/119957136/1.hd.live,
53+ ezopen://open.ys7.com/123648658/1.hd.live,
54+ ezopen://open.ys7.com/126049710/1.hd.live,
55+ ezopen://open.ys7.com/139404369/1.hd.live,
56+ ezopen://open.ys7.com/140428934/1.hd.live,
57+ ezopen://open.ys7.com/140449298/1.hd.live,
58+ ezopen://open.ys7.com/158663659/1.hd.live,
59+ ezopen://open.ys7.com/158663714/1.hd.live,
60+ ezopen://open.ys7.com/176949160/1.hd.live,
61+ ezopen://open.ys7.com/176949177/1.hd.live,
62+ ezopen://open.ys7.com/237444430/1.hd.live,
63+ ezopen://open.ys7.com/243902831/1.hd.live,
64+ ezopen://open.ys7.com/247892233/1.hd.live,
65+ ezopen://open.ys7.com/453940576/1.hd.live,
66+ ezopen://open.ys7.com/488338243/1.hd.live,
67+ ezopen://open.ys7.com/536934849/1.hd.live,
68+ ezopen://open.ys7.com/553899398/1.hd.live,
69+ ezopen://open.ys7.com/562185433/1.hd.live,
70+ ezopen://open.ys7.com/569620748/1.hd.live,
71+ ezopen://open.ys7.com/593251216/1.hd.live,
72+ ezopen://open.ys7.com/594336409/1.hd.live,
73+ ezopen://open.ys7.com/622538889/1.hd.live,
74+ ezopen://open.ys7.com/644480867/1.hd.live,
75+
76+
77+
78+
79+
80+ </ textarea >
81+ < div class ="btn-container ">
82+ <!-- <button id="init">初始化播放</button> -->
83+ < button id ="play "> 播放</ button >
84+ < button id ="stop "> 结束</ button >
85+ < button id ="getOSDTime "> 获取OSD时间</ button >
86+ < button id ="openSound "> 打开声音(默认已经开启)</ button >
87+ < button id ="closeSound "> 关闭声音</ button >
88+ < button id ="capturePicture "> 视频截图</ button >
89+ < button id ="startSave "> 开始录像</ button >
90+ < button id ="stopSave "> 停止录像</ button >
91+ < button id ="enableZoom "> 开启电子放大</ button >
92+ < button id ="closeZoom "> 关闭电子放大</ button >
93+ < button id ="fullScreen "> 全屏</ button >
94+ < button id ="switch "> 切换</ button >
95+ < span > 录制功能不支持加密视频,且录制的文件需要< a href ="https://service.ys7.com/downloadInfoSite/admin " target ="_blank "> 下载海康播放器播放</ a > </ span >
96+
97+ </ div >
98+ < div id ="currentUrl "> </ div >
99+ < div id ="playWind " style ="width: 600px; height: 400px; ">
100+ </ div >
101+ < script >
102+ function handleError ( e ) {
103+ console . log ( '捕获到错误' , e )
104+ }
105+ function handleSuccess ( ) {
106+ console . log ( "播放成功回调函数,此处可执行播放成功后续动作" ) ;
107+ }
108+ var url = $ ( '#url' ) . val ( ) . trim ( ) ;
109+ var accessToken = $ ( '#accessToken' ) . val ( ) . trim ( ) ;
110+ var decoder = new EZUIKit . EZUIPlayer ( {
111+ id : 'playWind' ,
112+ autoplay : true ,
113+ url : url ,
114+ accessToken : accessToken ,
115+ decoderPath : '' ,
116+ width : 600 ,
117+ height : 400 ,
118+ handleError : handleError ,
119+ handleSuccess : handleSuccess ,
120+ } ) ;
121+ // 这里是打印日志,本例抛出到播放页面
122+ decoder . on ( 'log' , log ) ;
123+ function log ( str , className ) {
124+ var div = document . createElement ( 'DIV' ) ;
125+ div . className = className || 'normal' ;
126+ div . innerHTML = ( new Date ( ) ) . Format ( 'yyyy-MM-dd hh:mm:ss.S' ) + JSON . stringify ( str ) ;
127+ document . body . appendChild ( div ) ;
128+ }
129+ $ ( "#start" ) . click ( function ( ) {
130+ function handleError ( e ) {
131+ console . log ( 'handleError' , e )
132+ }
133+ function handleSuccess ( ) {
134+ console . log ( 'handleSuccess' )
135+ }
136+ decoder . play ( {
137+ handleError : handleError ,
138+ } ) ;
139+ } )
140+ $ ( "#stop" ) . click ( function ( ) {
141+ /*停止播放方法1*/
142+ // decoder.stop();
143+ /*停止播放方法2 - promise模式*/
144+ var stopPromise = decoder . stop ( ) ;
145+ stopPromise . then ( function ( ) {
146+ console . log ( "关闭成功,用户执行关闭成功后的操作" ) ;
147+ } )
148+ } )
149+ $ ( "#getOSDTime" ) . click ( function ( ) {
150+ var getOSDTimePromise = decoder . getOSDTime ( ) ;
151+ getOSDTimePromise . then ( function ( data ) {
152+ console . log ( "getOSDTime success" , data )
153+ } )
154+ } )
155+ $ ( "#openSound" ) . click ( function ( ) {
156+ decoder . openSound ( ) ;
157+ } )
158+ $ ( "#closeSound" ) . click ( function ( ) {
159+ decoder . closeSound ( ) ;
160+ } )
161+ $ ( "#capturePicture" ) . click ( function ( ) {
162+ /*截图方法1*/
163+ // decoder.capturePicture(0,'default');
164+ /*截图方法2*/
165+ var capturePicturePromise = decoder . capturePicture ( 0 , 'default' ) ;
166+ capturePicturePromise . then ( function ( data ) {
167+ console . log ( "截图成功,用户执行关闭成功后的操作" , data ) ;
168+ } )
169+ } )
170+ $ ( "#startSave" ) . click ( function ( ) {
171+ // decoder.startSave(0, (new Date().getTime() + 'video'));
172+ /*开始录制方法2*/
173+ var startSavePromise = decoder . startSave ( 0 , ( new Date ( ) . getTime ( ) + 'video' ) ) ;
174+ startSavePromise . then ( function ( data ) {
175+ console . log ( "start save success" , startSavePromise )
176+ } )
177+ . catch ( function ( error ) {
178+ console . log ( "start Save error" , error )
179+ } )
180+ } )
181+ $ ( "#stopSave" ) . click ( function ( ) {
182+ /*结束录制方法1*/
183+ // decoder.stopSave(0);
184+ /*结束录制方法2*/
185+ var stopSavePromise = decoder . stopSave ( 0 ) ;
186+ stopSavePromise . then ( function ( data ) {
187+ console . log ( "stop save success" , stopSavePromise )
188+ } )
189+ . catch ( function ( error ) {
190+ console . log ( "stop Save error" , error )
191+ } )
192+ } )
193+ $ ( "#play" ) . click ( function ( ) {
194+ var url = $ ( '#url' ) . val ( ) . trim ( ) ;
195+ var accessToken = $ ( '#accessToken' ) . val ( ) . trim ( ) ;
196+ decoder . play ( {
197+ url : url ,
198+ accessToken : accessToken ,
199+ } ) ;
200+ } )
201+ $ ( "#enableZoom" ) . click ( function ( ) {
202+ decoder . enableZoom ( ) ;
203+ } )
204+ $ ( "#closeZoom" ) . click ( function ( ) {
205+ decoder . closeZoom ( ) ;
206+ } )
207+ $ ( "#fullScreen" ) . click ( function ( ) {
208+ decoder . fullScreen ( ) ;
209+ } ) ;
210+ var index = - 1 ;
211+ $ ( "#switch" ) . click ( function ( ) {
212+ decoder . stop ( )
213+ . then ( ( ) => {
214+ console . log ( "stop promise success" ) ;
215+ index = index + 1 ;
216+ var urlList = $ ( "#urlList" ) . val ( ) . split ( "," ) ;
217+ $ ( "#currentUrl" ) . text ( `当前播放索引:${ index } ` ) ;
218+ if ( index === urlList . length - 2 ) {
219+ $ ( "#currentUrl" ) . text ( `已经全部播放` ) ;
220+ $ ( "#switch" ) . attr ( 'disabled' , true ) ;
221+ }
222+ decoder . play ( urlList [ index ] . trim ( ) ) ;
223+ } )
224+ } )
225+ </ script >
226+ </ body >
227+
228+ </ html >
0 commit comments