|
| 1 | +<!DOCTYPE html> |
| 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"></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; |
| 45 | + |
| 46 | + function destroy() { |
| 47 | + if (player) { |
| 48 | + player.destroy(); |
| 49 | + } |
| 50 | + player = null; |
| 51 | + } |
| 52 | + |
| 53 | + document.querySelector(".init").addEventListener("click", () => { |
| 54 | + if (player) { |
| 55 | + destroy(); |
| 56 | + } |
| 57 | + |
| 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.9uoaxo0k3e5dinq8bretm18e5l37k1l6-26lx1qcvcc-1neesaz-kh9hqvqc3", |
| 66 | + url: "ezopen://open.ys7.com/BC7799091/1.hd.live", |
| 67 | + template: "pcLive", // simple: 极简版; pcLive: 预览; pcRec: 回放; security: 安防版; voice: 语音版; |
| 68 | + // width: 600, // 8.2.0 版本开始支持 style 里面宽的值(如 "100%" 或 '100vw' 或 "600px" 或 600 或 "1em" 等等) |
| 69 | + height: 400, |
| 70 | + language: "en", // zh | en |
| 71 | + // debugDownloadData: true, // 调试下载原始数据 |
| 72 | + handleError: (error) => { |
| 73 | + console.error("handleError", error); |
| 74 | + }, |
| 75 | + scaleMode: 1, // 默认 0 完全填充窗口,会有拉伸 1: 等比适配 2: 等比完全填充窗口, 超出隐藏 @sine 8.2.0 |
| 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: 2 }, // 需要设备支持子码流 |
| 103 | + // { level: 1, name: "高清", streamTypeIn: 1 }, |
| 104 | + // ], |
| 105 | + // videoLevelList: [ |
| 106 | + // { level: -1, name: "标清", streamTypeIn: 2 }, // 8.1.17 开始 当 level 的值小于 0时, 不在向设备发送指令,仅根据 streamTypeIn 切换码流 (请保证 streamTypeIn 对应的码流存在) |
| 107 | + // { level: -2, name: "高清", streamTypeIn: 1 }, // 8.1.17 开始 当 level 的值小于 0时, 不在向设备发送指令,仅根据 streamTypeIn 切换码流 (请保证 streamTypeIn 对应的码流存在) |
| 108 | + // ] |
| 109 | + }); |
| 110 | + |
| 111 | + // 8.1.x 版本, 9.x.x 移除了 eventEmitter |
| 112 | + // player.eventEmitter.on(EZUIKit.EZUIKitPlayer.EVENTS.videoInfo, (info) => { |
| 113 | + // console.log("eventEmitter videoInfo", info); |
| 114 | + // }); |
| 115 | + // 8.2.0 开始 推荐使用 player.on |
| 116 | + // prettier-ignore |
| 117 | + player.on(EZUIKit.EZUIKitPlayer.EVENTS.videoInfo,(info) => { |
| 118 | + console.log("videoInfo", info); |
| 119 | + }); |
| 120 | + |
| 121 | + // 8.1.x 版本, 9.x.x 移除了 eventEmitter |
| 122 | + // player.eventEmitter.on(EZUIKit.EZUIKitPlayer.EVENTS.audioInfo, (info) => { |
| 123 | + // console.log("eventEmitter audioInfo", info); |
| 124 | + // }); |
| 125 | + // 8.2.0 开始 推荐使用 player.on |
| 126 | + // prettier-ignore |
| 127 | + player.on(EZUIKit.EZUIKitPlayer.EVENTS.audioInfo, (info) => { |
| 128 | + console.log("audioInfo", info); |
| 129 | + }); |
| 130 | + |
| 131 | + // 首帧渲染成功 |
| 132 | + // first frame display |
| 133 | + // 8.1.x 版本, 9.x.x 移除了 eventEmitter |
| 134 | + // player.eventEmitter.on(EZUIKit.EZUIKitPlayer.EVENTS.firstFrameDisplay, () => { |
| 135 | + // console.log("eventEmitter firstFrameDisplay "); |
| 136 | + // }); |
| 137 | + // 8.2.0 开始 推荐使用 player.on |
| 138 | + // prettier-ignore |
| 139 | + player.on(EZUIKit.EZUIKitPlayer.EVENTS.firstFrameDisplay, () => { |
| 140 | + console.log("firstFrameDisplay "); |
| 141 | + }); |
| 142 | + |
| 143 | + // 8.1.x 版本, 9.x.x 移除了 eventEmitter |
| 144 | + // player.eventEmitter.on(EZUIKit.EZUIKitPlayer.EVENTS.streamInfoCB, (info) => { |
| 145 | + // console.log("eventEmitter streamInfoCB ", info); |
| 146 | + // }); |
| 147 | + // 8.2.0 开始 推荐使用 player.on |
| 148 | + // prettier-ignore |
| 149 | + player.on(EZUIKit.EZUIKitPlayer.EVENTS.streamInfoCB, (info) => { |
| 150 | + console.log("streamInfoCB ", info); |
| 151 | + }); |
| 152 | + }); |
| 153 | + |
| 154 | + document.querySelector(".fullscreen").addEventListener("click", () => { |
| 155 | + player.fullscreen(); |
| 156 | + }); |
| 157 | + |
| 158 | + document.querySelector(".play").addEventListener("click", () => { |
| 159 | + var playPromise = player.play(); |
| 160 | + playPromise.then((data) => { |
| 161 | + console.log("play", data); |
| 162 | + }); |
| 163 | + }); |
| 164 | + |
| 165 | + document.querySelector(".stop").addEventListener("click", () => { |
| 166 | + var stopPromise = player.stop(); |
| 167 | + stopPromise.then((data) => { |
| 168 | + console.log("stop", data); |
| 169 | + }); |
| 170 | + }); |
| 171 | + |
| 172 | + document.querySelector(".getOSDTime").addEventListener("click", () => { |
| 173 | + var getOSDTimePromise = player.getOSDTime(); |
| 174 | + getOSDTimePromise.then((data) => { |
| 175 | + console.log("getOSDTime: ", data); |
| 176 | + }); |
| 177 | + }); |
| 178 | + document |
| 179 | + .querySelector(".capturePicture") |
| 180 | + .addEventListener("click", () => { |
| 181 | + var capturePicturePromise = player.capturePicture(); |
| 182 | + capturePicturePromise.then((data) => { |
| 183 | + console.log("promise 获取 数据", data); |
| 184 | + }); |
| 185 | + }); |
| 186 | + |
| 187 | + document.querySelector(".openSound").addEventListener("click", () => { |
| 188 | + var openSoundPromise = player.openSound(); |
| 189 | + openSoundPromise.then((data) => { |
| 190 | + console.log("promise 获取 数据", data); |
| 191 | + }); |
| 192 | + }); |
| 193 | + |
| 194 | + document.querySelector(".closeSound").addEventListener("click", () => { |
| 195 | + var closeSoundPromise = player.closeSound(); |
| 196 | + closeSoundPromise.then((data) => { |
| 197 | + console.log("promise 获取 数据", data); |
| 198 | + }); |
| 199 | + }); |
| 200 | + document.querySelector(".startSave").addEventListener("click", () => { |
| 201 | + var startSavePromise = player.startSave(`${new Date().getTime()}`); |
| 202 | + startSavePromise.then((data) => { |
| 203 | + console.log("promise 获取 数据", data); |
| 204 | + }); |
| 205 | + }); |
| 206 | + document.querySelector(".stopSave").addEventListener("click", () => { |
| 207 | + var stopSavePromise = player.stopSave(); |
| 208 | + stopSavePromise.then((data) => { |
| 209 | + console.log("promise 获取 数据", data); |
| 210 | + }); |
| 211 | + }); |
| 212 | + document.querySelector(".startTalk").addEventListener("click", () => { |
| 213 | + player.startTalk(); |
| 214 | + }); |
| 215 | + document.querySelector(".stopTalk").addEventListener("click", () => { |
| 216 | + player.stopTalk(); |
| 217 | + }); |
| 218 | + document.querySelector(".destroy").addEventListener("click", destroy); |
| 219 | + })(); |
| 220 | + </script> |
| 221 | + </body> |
| 222 | +</html> |
0 commit comments