|
1 |
| -<!DOCTYPE html> |
| 1 | +<!doctype html> |
2 | 2 | <html lang="en">
|
3 |
| - <head> |
4 |
| - <meta charset="UTF-8" /> |
5 |
| - <meta |
6 |
| - name="viewport" |
7 |
| - content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" |
8 |
| - /> |
9 |
| - <title>Document</title> |
10 |
| - <style> |
11 |
| - #video-container { |
12 |
| - width: 600px; |
13 |
| - height: 400px; |
14 |
| - background-color: #000; |
15 |
| - } |
16 |
| - </style> |
17 |
| - <script src="./ezuikit.js"></script> |
18 |
| - </head> |
| 3 | + <head> |
| 4 | + <meta charset="UTF-8" /> |
| 5 | + <meta |
| 6 | + name="viewport" |
| 7 | + content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" |
| 8 | + /> |
| 9 | + <title>Document</title> |
| 10 | + <style> |
| 11 | + #video-container { |
| 12 | + width: 600px; |
| 13 | + height: 400px; |
| 14 | + background-color: #000; |
| 15 | + } |
| 16 | + </style> |
| 17 | + <script src="./ezuikit.js"></script> |
| 18 | + </head> |
19 | 19 |
|
20 |
| - <body> |
21 |
| - <div className="demo"> |
22 |
| - <h2>视频模式使用示例:</h2> |
23 |
| - <div> |
24 |
| - <div id="video-container" style="width: 600px"></div> |
25 |
| - </div> |
26 |
| - <div> |
27 |
| - <button onClick="init()">init</button> |
28 |
| - <button onClick="play()">play</button> |
29 |
| - <button onClick="stop()">stop</button> |
30 |
| - <button onClick="getOSDTime()">getOSDTime</button> |
31 |
| - <button onClick="capturePicture()">capturePicture</button> |
32 |
| - <button onClick="openSound()">openSound</button> |
33 |
| - <button onClick="closeSound()">closeSound</button> |
34 |
| - <button onClick="startSave()">startSave</button> |
35 |
| - <button onClick="stopSave()">stopSave</button> |
36 |
| - <button onClick="ezopenStartTalk()">开始对讲</button> |
37 |
| - <button onClick="ezopenStopTalk()">结束对讲</button> |
38 |
| - <button onClick="fullScreen()">全屏</button> |
39 |
| - <button onClick="destroy()">销毁</button> |
40 |
| - </div> |
41 |
| - <p style="font-style: italic"> |
42 |
| - 播放多个视频,可初始化多个实例,参考:/demos/base-demo/multi-demo |
43 |
| - </p> |
44 |
| - </div> |
45 |
| - <script> |
46 |
| - var player; |
| 20 | + <body> |
| 21 | + <div className="demo"> |
| 22 | + <h2>视频模式使用示例:</h2> |
| 23 | + <div> |
| 24 | + <div id="video-container" style="width: 600px"></div> |
| 25 | + </div> |
| 26 | + <div> |
| 27 | + <button onClick="init()">init</button> |
| 28 | + <button onClick="play()">play</button> |
| 29 | + <button onClick="stop()">stop</button> |
| 30 | + <button onClick="getOSDTime()">getOSDTime</button> |
| 31 | + <button onClick="capturePicture()">capturePicture</button> |
| 32 | + <button onClick="openSound()">openSound</button> |
| 33 | + <button onClick="closeSound()">closeSound</button> |
| 34 | + <button onClick="startSave()">startSave</button> |
| 35 | + <button onClick="stopSave()">stopSave</button> |
| 36 | + <button onClick="ezopenStartTalk()">开始对讲</button> |
| 37 | + <button onClick="ezopenStopTalk()">结束对讲</button> |
| 38 | + <button onClick="fullScreen()">全屏</button> |
| 39 | + <button onClick="destroy()">销毁</button> |
| 40 | + </div> |
| 41 | + <p style="font-style: italic"> |
| 42 | + 播放多个视频,可初始化多个实例,参考:/demos/base-demo/multi-demo |
| 43 | + </p> |
| 44 | + </div> |
| 45 | + <script> |
| 46 | + var player; |
47 | 47 |
|
48 |
| - function init() { |
49 |
| - if (player) { |
50 |
| - destroy(); |
51 |
| - } |
| 48 | + function init() { |
| 49 | + if (player) { |
| 50 | + destroy(); |
| 51 | + } |
52 | 52 |
|
53 |
| - // fetch('https://open.ys7.com/jssdk/ezopen/demo/token') |
54 |
| - // .then(response => response.json()) |
55 |
| - // .then(res => { |
56 |
| - // var accessToken = res.data.accessToken; |
57 |
| - player = new EZUIKit.EZUIKitPlayer({ |
58 |
| - id: "video-container", // 视频容器ID |
59 |
| - accessToken: |
60 |
| - "at.clbukes44vf7k52873p71dby1qz1o7be-7sn9vqrwnw-1psx5mr-hd9shlp", |
61 |
| - url: "ezopen://open.ys7.com/BB9480953/1.hd.live", |
62 |
| - template: "pcLive", // simple: 极简版; pcLive: 预览; pcRec: 回放; security: 安防版; voice: 语音版; |
63 |
| - plugin: ["talk"], // 加载插件,talk-对讲 |
64 |
| - width: 600, |
65 |
| - height: 400, |
66 |
| - language: "en", // zh | en |
67 |
| - // debugDownloadData: true, |
68 |
| - handleError: (error) => { |
69 |
| - console.error("handleError", error); |
70 |
| - }, |
71 |
| - env: { |
72 |
| - // https://open.ys7.com/help/1772?h=domain |
73 |
| - // domain默认是 https://open.ys7.com, 如果是私有化部署或海外的环境,请配置对应的domain |
74 |
| - // The default domain is https://open.ys7.com If it is a private deployment or overseas (outside of China) environment, please configure the corresponding domain |
75 |
| - domain: "https://open.ys7.com", |
76 |
| - }, |
77 |
| - // staticPath: "/ezuikit_static", // 如果想使用本地静态资源,请复制根目录下ezuikit_static 到当前目录下, 然后设置该值 |
78 |
| - }); |
79 |
| - // }); |
80 |
| - } |
| 53 | + // fetch('https://open.ys7.com/jssdk/ezopen/demo/token') |
| 54 | + // .then(response => response.json()) |
| 55 | + // .then(res => { |
| 56 | + // var accessToken = res.data.accessToken; |
| 57 | + player = new EZUIKit.EZUIKitPlayer({ |
| 58 | + id: "video-container", // 视频容器ID |
| 59 | + accessToken: |
| 60 | + "ra.2zhsfvhv5n36uqiu5skq9a458d9g28o0-361rtyke9p-1r80x45-iteypfxmq", |
| 61 | + url: "ezopen://open.ys7.com/BC7799091/1.hd.live", |
| 62 | + template: "pcLive", // simple: 极简版; pcLive: 预览; pcRec: 回放; security: 安防版; voice: 语音版; |
| 63 | + plugin: ["talk"], // 加载插件,talk-对讲 |
| 64 | + width: 600, |
| 65 | + height: 400, |
| 66 | + language: "en", // zh | en |
| 67 | + // debugDownloadData: true, |
| 68 | + handleError: (error) => { |
| 69 | + console.error("handleError", error); |
| 70 | + }, |
| 71 | + env: { |
| 72 | + // https://open.ys7.com/help/1772?h=domain |
| 73 | + // domain默认是 https://open.ys7.com, 如果是私有化部署或海外的环境,请配置对应的domain |
| 74 | + // The default domain is https://open.ys7.com If it is a private deployment or overseas (outside of China) environment, please configure the corresponding domain |
| 75 | + domain: "https://open.ys7.com", |
| 76 | + }, |
| 77 | + // 日志打印设置 |
| 78 | + loggerOptions: { |
| 79 | + // player.setLoggerOptions(options) |
| 80 | + level: "INFO", // INFO LOG WARN ERROR |
| 81 | + name: "ezuikit", |
| 82 | + showTime: true, |
| 83 | + }, |
| 84 | + // 视频流的信息回调类型 |
| 85 | + /** |
| 86 | + * 打开流信息回调,监听 streamInfoCB 事件 |
| 87 | + * 0 : 每次都回调 |
| 88 | + * 1 : 只回调一次 |
| 89 | + * 注意:会影响性能 |
| 90 | + * 默认值 1 |
| 91 | + */ |
| 92 | + streamInfoCBType: 1, |
| 93 | + staticPath: "/ezuikit_static", // 如果想使用本地静态资源,请复制根目录下ezuikit_static 到当前目录下, 然后设置该值 |
| 94 | + }); |
81 | 95 |
|
82 |
| - function fullScreen() { |
83 |
| - var playPromise = player.fullScreen(); |
84 |
| - } |
85 |
| - function play() { |
86 |
| - var playPromise = player.play(); |
87 |
| - playPromise.then((data) => { |
88 |
| - console.log("promise 获取 数据", data); |
89 |
| - }); |
90 |
| - } |
91 |
| - function stop() { |
92 |
| - var stopPromise = player.stop(); |
93 |
| - stopPromise.then((data) => { |
94 |
| - console.log("promise 获取 数据", data); |
95 |
| - }); |
96 |
| - } |
97 |
| - function getOSDTime() { |
98 |
| - var getOSDTimePromise = player.getOSDTime(); |
99 |
| - getOSDTimePromise.then((data) => { |
100 |
| - console.log("promise 获取 数据", data); |
101 |
| - }); |
102 |
| - } |
| 96 | + player.eventEmitter.on( |
| 97 | + EZUIKit.EZUIKitPlayer.EVENTS.videoInfo, |
| 98 | + (info) => { |
| 99 | + console.log("videoinfo", info); |
| 100 | + }, |
| 101 | + ); |
103 | 102 |
|
104 |
| - function capturePicture() { |
105 |
| - var capturePicturePromise = player.capturePicture(); |
106 |
| - capturePicturePromise.then((data) => { |
107 |
| - console.log("promise 获取 数据", data); |
108 |
| - }); |
109 |
| - } |
110 |
| - function openSound() { |
111 |
| - var openSoundPromise = player.openSound(); |
112 |
| - openSoundPromise.then((data) => { |
113 |
| - console.log("promise 获取 数据", data); |
114 |
| - }); |
115 |
| - } |
116 |
| - function closeSound() { |
117 |
| - var closeSoundPromise = player.closeSound(); |
118 |
| - closeSoundPromise.then((data) => { |
119 |
| - console.log("promise 获取 数据", data); |
120 |
| - }); |
121 |
| - } |
122 |
| - function startSave() { |
123 |
| - var startSavePromise = player.startSave(`${new Date().getTime()}`); |
124 |
| - startSavePromise.then((data) => { |
125 |
| - console.log("promise 获取 数据", data); |
126 |
| - }); |
127 |
| - } |
128 |
| - function stopSave() { |
129 |
| - var stopSavePromise = player.stopSave(); |
130 |
| - stopSavePromise.then((data) => { |
131 |
| - console.log("promise 获取 数据", data); |
132 |
| - }); |
133 |
| - } |
134 |
| - function ezopenStartTalk() { |
135 |
| - player.startTalk(); |
136 |
| - } |
137 |
| - function ezopenStopTalk() { |
138 |
| - player.stopTalk(); |
139 |
| - } |
| 103 | + player.eventEmitter.on( |
| 104 | + EZUIKit.EZUIKitPlayer.EVENTS.audioInfo, |
| 105 | + (info) => { |
| 106 | + console.log("audioInfo", info); |
| 107 | + }, |
| 108 | + ); |
140 | 109 |
|
141 |
| - function destroy() { |
142 |
| - if (player) { |
143 |
| - player.destroy(); |
144 |
| - } |
145 |
| - player = null; |
146 |
| - } |
147 |
| - </script> |
148 |
| - </body> |
| 110 | + // 首帧渲染成功 |
| 111 | + // first frame display |
| 112 | + player.eventEmitter.on( |
| 113 | + EZUIKit.EZUIKitPlayer.EVENTS.firstFrameDisplay, |
| 114 | + () => { |
| 115 | + console.log("firstFrameDisplay "); |
| 116 | + }, |
| 117 | + ); |
| 118 | + player.eventEmitter.on( |
| 119 | + EZUIKit.EZUIKitPlayer.EVENTS.streamInfoCB, |
| 120 | + (info) => { |
| 121 | + console.log("streamInfoCB ", info); |
| 122 | + }, |
| 123 | + ); |
| 124 | + // }); |
| 125 | + } |
| 126 | + |
| 127 | + function fullScreen() { |
| 128 | + var playPromise = player.fullScreen(); |
| 129 | + } |
| 130 | + |
| 131 | + function play() { |
| 132 | + var playPromise = player.play(); |
| 133 | + playPromise.then((data) => { |
| 134 | + console.log("promise 获取 数据", data); |
| 135 | + }); |
| 136 | + } |
| 137 | + |
| 138 | + function stop() { |
| 139 | + var stopPromise = player.stop(); |
| 140 | + stopPromise.then((data) => { |
| 141 | + console.log("promise 获取 数据", data); |
| 142 | + }); |
| 143 | + } |
| 144 | + function getOSDTime() { |
| 145 | + var getOSDTimePromise = player.getOSDTime(); |
| 146 | + getOSDTimePromise.then((data) => { |
| 147 | + console.log("promise 获取 数据", data); |
| 148 | + }); |
| 149 | + } |
| 150 | + |
| 151 | + function capturePicture() { |
| 152 | + var capturePicturePromise = player.capturePicture(); |
| 153 | + capturePicturePromise.then((data) => { |
| 154 | + console.log("promise 获取 数据", data); |
| 155 | + }); |
| 156 | + } |
| 157 | + function openSound() { |
| 158 | + var openSoundPromise = player.openSound(); |
| 159 | + openSoundPromise.then((data) => { |
| 160 | + console.log("promise 获取 数据", data); |
| 161 | + }); |
| 162 | + } |
| 163 | + function closeSound() { |
| 164 | + var closeSoundPromise = player.closeSound(); |
| 165 | + closeSoundPromise.then((data) => { |
| 166 | + console.log("promise 获取 数据", data); |
| 167 | + }); |
| 168 | + } |
| 169 | + function startSave() { |
| 170 | + var startSavePromise = player.startSave( |
| 171 | + `${new Date().getTime()}`, |
| 172 | + ); |
| 173 | + startSavePromise.then((data) => { |
| 174 | + console.log("promise 获取 数据", data); |
| 175 | + }); |
| 176 | + } |
| 177 | + function stopSave() { |
| 178 | + var stopSavePromise = player.stopSave(); |
| 179 | + stopSavePromise.then((data) => { |
| 180 | + console.log("promise 获取 数据", data); |
| 181 | + }); |
| 182 | + } |
| 183 | + function ezopenStartTalk() { |
| 184 | + player.startTalk(); |
| 185 | + } |
| 186 | + function ezopenStopTalk() { |
| 187 | + player.stopTalk(); |
| 188 | + } |
| 189 | + |
| 190 | + function destroy() { |
| 191 | + if (player) { |
| 192 | + player.destroy(); |
| 193 | + } |
| 194 | + player = null; |
| 195 | + } |
| 196 | + </script> |
| 197 | + </body> |
149 | 198 | </html>
|
0 commit comments