|
| 1 | +<template> |
| 2 | + <div class="hello-ezuikit-js"> |
| 3 | + <div> |
| 4 | + <div id="video-container" style="width: 100%;height: 300px"></div> |
| 5 | + </div> |
| 6 | + <div> |
| 7 | + <button v-on:click="init">init</button> |
| 8 | + <button v-on:click="stop">stop</button> |
| 9 | + <button v-on:click="play">play</button> |
| 10 | + <button v-on:click="openSound">openSound</button> |
| 11 | + <button v-on:click="closeSound">closeSound</button> |
| 12 | + <button v-on:click="startSave">startSave</button> |
| 13 | + <button v-on:click="stopSave">stopSave</button> |
| 14 | + <button v-on:click="capturePicture">capturePicture</button> |
| 15 | + <button v-on:click="fullScreen">fullScreen</button> |
| 16 | + <button v-on:click="getOSDTime">getOSDTime</button> |
| 17 | + <button v-on:click="startTalk">startTalk</button> |
| 18 | + <button v-on:click="stopTalk">stopTalk</button> |
| 19 | + <button v-on:click="destroy">destroy</button> |
| 20 | + </div> |
| 21 | + </div> |
| 22 | +</template> |
| 23 | + |
| 24 | +<script> |
| 25 | +import { EZUIKitPlayer } from "ezuikit-js"; |
| 26 | +var player = null; |
| 27 | +
|
| 28 | +export default { |
| 29 | + name: "Player", |
| 30 | + props: { |
| 31 | + msg: String, |
| 32 | + }, |
| 33 | + mounted: () => { |
| 34 | + console.group("mounted 组件挂载完毕状态===============》"); |
| 35 | + }, |
| 36 | + methods: { |
| 37 | + init() { |
| 38 | + if (player) { |
| 39 | + this.destroy(); |
| 40 | + } |
| 41 | +
|
| 42 | + const systemInfo = uni.getSystemInfoSync(); |
| 43 | + const windowWidth = systemInfo.windowWidth; |
| 44 | +
|
| 45 | + player = new EZUIKitPlayer({ |
| 46 | + id: "video-container", // 视频容器ID |
| 47 | + accessToken: |
| 48 | + "at.4dd7o6hgdb9ywl9c283g0hj27e789uru-2a5ejk6tkf-19b1cb1-azyfqm3a", |
| 49 | + url: "ezopen://open.ys7.com/C69625501/1.hd.live", |
| 50 | + // simple: 极简版; pcLive: pc直播; pcRec: pc回放; mobileLive: 移动端直播; mobileRec: 移动端回放;security: 安防版; voice: 语音版; |
| 51 | + template: "mobileLive", |
| 52 | + plugin: ["talk"], // 加载插件,talk-对讲 |
| 53 | + width: windowWidth || 375, |
| 54 | + height: 300, |
| 55 | + handleError: (error) => { |
| 56 | + console.error("handleError", error); |
| 57 | + }, |
| 58 | + // quality: 1, // |
| 59 | + // language: "en", // zh | en |
| 60 | + // staticPath: "/ezuikit_static", // 如果想使用本地静态资源,请复制根目录下ezuikit_static 到当前目录下, 然后设置该值 |
| 61 | + env: { |
| 62 | + // https://open.ys7.com/help/1772?h=domain |
| 63 | + // domain默认是 https://open.ys7.com, 如果是私有化部署或海外的环境,请配置对应的domain |
| 64 | + // 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 |
| 65 | + domain: "https://open.ys7.com", |
| 66 | + }, |
| 67 | + // staticPath:"https://openstatic.ys7.com/ezuikit_js/v8.1.9/ezuikit_static", |
| 68 | + // 日志打印设置 |
| 69 | + loggerOptions: { |
| 70 | + // player.setLoggerOptions(options) |
| 71 | + level: "INFO", // INFO LOG WARN ERROR |
| 72 | + name: "ezuikit", |
| 73 | + showTime: true, |
| 74 | + }, |
| 75 | + // 视频流的信息回调类型 |
| 76 | + /** |
| 77 | + * 打开流信息回调,监听 streamInfoCB 事件 |
| 78 | + * 0 : 每次都回调 |
| 79 | + * 1 : 只回调一次 |
| 80 | + * 注意:会影响性能 |
| 81 | + * 默认值 1 |
| 82 | + */ |
| 83 | + streamInfoCBType: 1, |
| 84 | + // v8.1.10 |
| 85 | + // 自定义清晰度 默认 null, 如果有值 sdk 内部不在进行获取, null 默认使用接口获取的清晰度列表, videoLevelList.length === 0 不展示清晰度控件 sdk 内部不在进行获取, videoLevelList.length > 0 展示控件 sdk 内部不在进行获取 |
| 86 | + // videoLevelList: [ |
| 87 | + // { level: 1, name: "标清", streamTypeIn: 2 }, // 需要保证支持子码流 (streamTypeIn=2) |
| 88 | + // { level: 2, name: "高清", streamTypeIn: 1 }, |
| 89 | + // ], |
| 90 | + }); |
| 91 | +
|
| 92 | + player.eventEmitter.on(EZUIKitPlayer.EVENTS.videoInfo, (info) => { |
| 93 | + console.log("videoinfo", info); |
| 94 | + }); |
| 95 | +
|
| 96 | + player.eventEmitter.on(EZUIKitPlayer.EVENTS.audioInfo, (info) => { |
| 97 | + console.log("audioInfo", info); |
| 98 | + }); |
| 99 | +
|
| 100 | + // 首帧渲染成功 |
| 101 | + // first frame display |
| 102 | + player.eventEmitter.on( |
| 103 | + EZUIKitPlayer.EVENTS.firstFrameDisplay, |
| 104 | + () => { |
| 105 | + console.log("firstFrameDisplay "); |
| 106 | + } |
| 107 | + ); |
| 108 | + player.eventEmitter.on( |
| 109 | + EZUIKitPlayer.EVENTS.streamInfoCB, |
| 110 | + (info) => { |
| 111 | + console.log("streamInfoCB ", info); |
| 112 | + } |
| 113 | + ); |
| 114 | +
|
| 115 | + window.player = player; |
| 116 | + }, |
| 117 | + play() { |
| 118 | + var playPromise = player.play(); |
| 119 | + playPromise.then((data) => { |
| 120 | + console.log("promise 获取 数据", data); |
| 121 | + }); |
| 122 | + }, |
| 123 | + stop() { |
| 124 | + var stopPromise = player.stop(); |
| 125 | + stopPromise.then((data) => { |
| 126 | + console.log("promise 获取 数据", data); |
| 127 | + }); |
| 128 | + }, |
| 129 | + getOSDTime() { |
| 130 | + var getOSDTimePromise = player.getOSDTime(); |
| 131 | + getOSDTimePromise.then((data) => { |
| 132 | + console.log("promise 获取 数据", data); |
| 133 | + }); |
| 134 | + }, |
| 135 | + capturePicture() { |
| 136 | + var capturePicturePromise = player.capturePicture( |
| 137 | + `${new Date().getTime()}` |
| 138 | + ); |
| 139 | + capturePicturePromise.then((data) => { |
| 140 | + console.log("promise 获取 数据", data); |
| 141 | + }); |
| 142 | + }, |
| 143 | + openSound() { |
| 144 | + var openSoundPromise = player.openSound(); |
| 145 | + openSoundPromise.then((data) => { |
| 146 | + console.log("promise 获取 数据", data); |
| 147 | + }); |
| 148 | + }, |
| 149 | + closeSound() { |
| 150 | + var openSoundPromise = player.closeSound(); |
| 151 | + openSoundPromise.then((data) => { |
| 152 | + console.log("promise 获取 数据", data); |
| 153 | + }); |
| 154 | + }, |
| 155 | + startSave() { |
| 156 | + var startSavePromise = player.startSave(`${new Date().getTime()}`); |
| 157 | + startSavePromise.then((data) => { |
| 158 | + console.log("promise 获取 数据", data); |
| 159 | + }); |
| 160 | + }, |
| 161 | + stopSave() { |
| 162 | + var stopSavePromise = player.stopSave(); |
| 163 | + stopSavePromise.then((data) => { |
| 164 | + console.log("promise 获取 数据", data); |
| 165 | + }); |
| 166 | + }, |
| 167 | + startTalk() { |
| 168 | + player.startTalk(); |
| 169 | + }, |
| 170 | + stopTalk() { |
| 171 | + player.stopTalk(); |
| 172 | + }, |
| 173 | + fullScreen() { |
| 174 | + player.fullScreen(); |
| 175 | + }, |
| 176 | + destroy() { |
| 177 | + var destroyPromise = player.destroy(); |
| 178 | + destroyPromise.then((data) => { |
| 179 | + console.log("promise 获取 数据", data); |
| 180 | + }); |
| 181 | + player = null; |
| 182 | + }, |
| 183 | + }, |
| 184 | +}; |
| 185 | +</script> |
0 commit comments