|
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> |
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="startTalk()">开始对讲</button> |
37 | | - <button onClick="stopTalk()">结束对讲</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; |
| 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> |
47 | 19 |
|
48 | | - function init() { |
49 | | - if (player) { |
50 | | - destroy(); |
51 | | - } |
| 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 class="init">出初始化(init)</button> |
| 28 | + <button class="play">play</button> |
| 29 | + <button class="stop">stop</button> |
| 30 | + <button class="getOSDTime">getOSDTime</button> |
| 31 | + <button class="capturePicture">capturePicture</button> |
| 32 | + <button class="openSound">openSound</button> |
| 33 | + <button class="closeSound">closeSound</button> |
| 34 | + <button class="startSave">startSave</button> |
| 35 | + <button class="stopSave">stopSave</button> |
| 36 | + <button class="startTalk">开始对讲</button> |
| 37 | + <button class="stopTalk">结束对讲</button> |
| 38 | + <button class="fullScreen">全屏</button> |
| 39 | + <button class="destroy">销毁</button> |
| 40 | + </div> |
| 41 | + </div> |
| 42 | + <script> |
| 43 | + (function () { |
| 44 | + var player = null; |
52 | 45 |
|
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.d525oyj8d7bwohb40ssn3266cfq2mwi2-8hgpypehn9-1fafaty-ea2fxbc1k", |
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 | | - // v8.1.10 |
95 | | - // 自定义清晰度 默认 null, 如果有值 sdk 内部不在进行获取, null 默认使用接口获取的清晰度列表, videoLevelList.length === 0 不展示清晰度控件 sdk 内部不在进行获取, videoLevelList.length > 0 展示控件 sdk 内部不在进行获取 |
96 | | - // videoLevelList: [ |
97 | | - // { level: 0, name: "流畅", streamTypeIn: 1 }, |
98 | | - // { level: 1, name: "标清", streamTypeIn: 1 }, |
99 | | - // ], |
100 | | - }); |
| 46 | + function destroy() { |
| 47 | + if (player) { |
| 48 | + player.destroy(); |
| 49 | + } |
| 50 | + player = null; |
| 51 | + } |
101 | 52 |
|
102 | | - player.eventEmitter.on( |
103 | | - EZUIKit.EZUIKitPlayer.EVENTS.videoInfo, |
104 | | - (info) => { |
105 | | - console.log("videoinfo", info); |
106 | | - }, |
107 | | - ); |
| 53 | + document.querySelector(".init").addEventListener("click", () => { |
| 54 | + if (player) { |
| 55 | + destroy(); |
| 56 | + } |
108 | 57 |
|
109 | | - player.eventEmitter.on( |
110 | | - EZUIKit.EZUIKitPlayer.EVENTS.audioInfo, |
111 | | - (info) => { |
112 | | - console.log("audioInfo", info); |
113 | | - }, |
114 | | - ); |
115 | | - |
116 | | - // 首帧渲染成功 |
117 | | - // first frame display |
118 | | - player.eventEmitter.on( |
119 | | - EZUIKit.EZUIKitPlayer.EVENTS.firstFrameDisplay, |
120 | | - () => { |
121 | | - console.log("firstFrameDisplay "); |
122 | | - }, |
123 | | - ); |
124 | | - player.eventEmitter.on( |
125 | | - EZUIKit.EZUIKitPlayer.EVENTS.streamInfoCB, |
126 | | - (info) => { |
127 | | - console.log("streamInfoCB ", info); |
128 | | - }, |
129 | | - ); |
130 | | - // }); |
131 | | - } |
| 58 | + // fetch('https://open.ys7.com/jssdk/ezopen/demo/token') |
| 59 | + // .then(response => response.json()) |
| 60 | + // .then(res => { |
| 61 | + // var accessToken = res.data.accessToken; |
| 62 | + player = new EZUIKit.EZUIKitPlayer({ |
| 63 | + id: "video-container", // 视频容器ID |
| 64 | + accessToken: |
| 65 | + "at.d525oyj8d7bwohb40ssn3266cfq2mwi2-8hgpypehn9-1fafaty-ea2fxbc1k", |
| 66 | + url: "ezopen://open.ys7.com/BC7799091/1.hd.live", |
| 67 | + template: "pcLive", // simple: 极简版; pcLive: 预览; pcRec: 回放; security: 安防版; voice: 语音版; |
| 68 | + // plugin: ["talk"], // 加载插件,talk-对讲 |
| 69 | + width: 600, |
| 70 | + height: 400, |
| 71 | + language: "en", // zh | en |
| 72 | + // debugDownloadData: true, |
| 73 | + handleError: (error) => { |
| 74 | + console.error("handleError", error); |
| 75 | + }, |
| 76 | + env: { |
| 77 | + // https://open.ys7.com/help/1772?h=domain |
| 78 | + // domain默认是 https://open.ys7.com, 如果是私有化部署或海外的环境,请配置对应的domain |
| 79 | + // 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 |
| 80 | + domain: "https://open.ys7.com", |
| 81 | + }, |
| 82 | + // 日志打印设置 |
| 83 | + loggerOptions: { |
| 84 | + // player.setLoggerOptions(options) |
| 85 | + level: "INFO", // INFO LOG WARN ERROR |
| 86 | + name: "ezuikit", |
| 87 | + showTime: true, |
| 88 | + }, |
| 89 | + // 视频流的信息回调类型 |
| 90 | + /** |
| 91 | + * 打开流信息回调,监听 streamInfoCB 事件 |
| 92 | + * 0 : 每次都回调 |
| 93 | + * 1 : 只回调一次 |
| 94 | + * 注意:会影响性能 |
| 95 | + * 默认值 1 |
| 96 | + */ |
| 97 | + streamInfoCBType: 1, |
| 98 | + staticPath: "/ezuikit_static", // 如果想使用本地静态资源,请复制根目录下ezuikit_static 到当前目录下, 然后设置该值 |
| 99 | + // v8.1.10 |
| 100 | + // 自定义清晰度 默认 null, 如果有值 sdk 内部不在进行获取, null 默认使用接口获取的清晰度列表, videoLevelList.length === 0 不展示清晰度控件 sdk 内部不在进行获取, videoLevelList.length > 0 展示控件 sdk 内部不在进行获取 |
| 101 | + // videoLevelList: [ |
| 102 | + // { level: 0, name: "流畅", streamTypeIn: 1 }, |
| 103 | + // { level: 1, name: "标清", streamTypeIn: 1 }, |
| 104 | + // ], |
| 105 | + }); |
132 | 106 |
|
133 | | - function fullScreen() { |
134 | | - var playPromise = player.fullScreen(); |
| 107 | + player.eventEmitter.on( |
| 108 | + EZUIKit.EZUIKitPlayer.EVENTS.videoInfo, |
| 109 | + (info) => { |
| 110 | + console.log("videoinfo", info); |
135 | 111 | } |
| 112 | + ); |
136 | 113 |
|
137 | | - function play() { |
138 | | - var playPromise = player.play(); |
139 | | - playPromise.then((data) => { |
140 | | - console.log("promise 获取 数据", data); |
141 | | - }); |
| 114 | + player.eventEmitter.on( |
| 115 | + EZUIKit.EZUIKitPlayer.EVENTS.audioInfo, |
| 116 | + (info) => { |
| 117 | + console.log("audioInfo", info); |
142 | 118 | } |
| 119 | + ); |
143 | 120 |
|
144 | | - function stop() { |
145 | | - var stopPromise = player.stop(); |
146 | | - stopPromise.then((data) => { |
147 | | - console.log("promise 获取 数据", data); |
148 | | - }); |
| 121 | + // 首帧渲染成功 |
| 122 | + // first frame display |
| 123 | + player.eventEmitter.on( |
| 124 | + EZUIKit.EZUIKitPlayer.EVENTS.firstFrameDisplay, |
| 125 | + () => { |
| 126 | + console.log("firstFrameDisplay "); |
149 | 127 | } |
150 | | - function getOSDTime() { |
151 | | - var getOSDTimePromise = player.getOSDTime(); |
152 | | - getOSDTimePromise.then((data) => { |
153 | | - console.log("promise 获取 数据", data); |
154 | | - }); |
| 128 | + ); |
| 129 | + player.eventEmitter.on( |
| 130 | + EZUIKit.EZUIKitPlayer.EVENTS.streamInfoCB, |
| 131 | + (info) => { |
| 132 | + console.log("streamInfoCB ", info); |
155 | 133 | } |
| 134 | + ); |
| 135 | + }); |
156 | 136 |
|
157 | | - function capturePicture() { |
158 | | - var capturePicturePromise = player.capturePicture(); |
159 | | - capturePicturePromise.then((data) => { |
160 | | - console.log("promise 获取 数据", data); |
161 | | - }); |
162 | | - } |
163 | | - function openSound() { |
164 | | - var openSoundPromise = player.openSound(); |
165 | | - openSoundPromise.then((data) => { |
166 | | - console.log("promise 获取 数据", data); |
167 | | - }); |
168 | | - } |
169 | | - function closeSound() { |
170 | | - var closeSoundPromise = player.closeSound(); |
171 | | - closeSoundPromise.then((data) => { |
172 | | - console.log("promise 获取 数据", data); |
173 | | - }); |
174 | | - } |
175 | | - function startSave() { |
176 | | - var startSavePromise = player.startSave( |
177 | | - `${new Date().getTime()}`, |
178 | | - ); |
179 | | - startSavePromise.then((data) => { |
180 | | - console.log("promise 获取 数据", data); |
181 | | - }); |
182 | | - } |
183 | | - function stopSave() { |
184 | | - var stopSavePromise = player.stopSave(); |
185 | | - stopSavePromise.then((data) => { |
186 | | - console.log("promise 获取 数据", data); |
187 | | - }); |
188 | | - } |
189 | | - function startTalk() { |
190 | | - player.startTalk(); |
191 | | - } |
192 | | - function stopTalk() { |
193 | | - player.stopTalk(); |
194 | | - } |
| 137 | + document.querySelector(".fullScreen").addEventListener("click", () => { |
| 138 | + player.fullScreen(); |
| 139 | + }); |
195 | 140 |
|
196 | | - function destroy() { |
197 | | - if (player) { |
198 | | - player.destroy(); |
199 | | - } |
200 | | - player = null; |
201 | | - } |
202 | | - </script> |
203 | | - </body> |
| 141 | + document.querySelector(".play").addEventListener("click", () => { |
| 142 | + var playPromise = player.play(); |
| 143 | + playPromise.then((data) => { |
| 144 | + console.log("play", data); |
| 145 | + }); |
| 146 | + }); |
| 147 | + |
| 148 | + document.querySelector(".stop").addEventListener("click", () => { |
| 149 | + var stopPromise = player.stop(); |
| 150 | + stopPromise.then((data) => { |
| 151 | + console.log("stop", data); |
| 152 | + }); |
| 153 | + }); |
| 154 | + |
| 155 | + document.querySelector(".getOSDTime").addEventListener("click", () => { |
| 156 | + var getOSDTimePromise = player.getOSDTime(); |
| 157 | + getOSDTimePromise.then((data) => { |
| 158 | + console.log("getOSDTime: ", data); |
| 159 | + }); |
| 160 | + }); |
| 161 | + document |
| 162 | + .querySelector(".capturePicture") |
| 163 | + .addEventListener("click", () => { |
| 164 | + var capturePicturePromise = player.capturePicture(); |
| 165 | + capturePicturePromise.then((data) => { |
| 166 | + console.log("promise 获取 数据", data); |
| 167 | + }); |
| 168 | + }); |
| 169 | + |
| 170 | + document.querySelector(".openSound").addEventListener("click", () => { |
| 171 | + var openSoundPromise = player.openSound(); |
| 172 | + openSoundPromise.then((data) => { |
| 173 | + console.log("promise 获取 数据", data); |
| 174 | + }); |
| 175 | + }); |
| 176 | + |
| 177 | + document.querySelector(".closeSound").addEventListener("click", () => { |
| 178 | + var closeSoundPromise = player.closeSound(); |
| 179 | + closeSoundPromise.then((data) => { |
| 180 | + console.log("promise 获取 数据", data); |
| 181 | + }); |
| 182 | + }); |
| 183 | + document.querySelector(".startSave").addEventListener("click", () => { |
| 184 | + var startSavePromise = player.startSave(`${new Date().getTime()}`); |
| 185 | + startSavePromise.then((data) => { |
| 186 | + console.log("promise 获取 数据", data); |
| 187 | + }); |
| 188 | + }); |
| 189 | + document.querySelector(".stopSave").addEventListener("click", () => { |
| 190 | + var stopSavePromise = player.stopSave(); |
| 191 | + stopSavePromise.then((data) => { |
| 192 | + console.log("promise 获取 数据", data); |
| 193 | + }); |
| 194 | + }); |
| 195 | + document.querySelector(".startTalk").addEventListener("click", () => { |
| 196 | + player.startTalk(); |
| 197 | + }); |
| 198 | + document.querySelector(".stopTalk").addEventListener("click", () => { |
| 199 | + player.stopTalk(); |
| 200 | + }); |
| 201 | + document.querySelector(".destroy").addEventListener("click", destroy); |
| 202 | + })(); |
| 203 | + </script> |
| 204 | + </body> |
204 | 205 | </html> |
0 commit comments