1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
| <template> <div class="hello-ezuikit-js"> <div id="video-container"></div> <div> <button @click="init">初始化</button> <button @click="stop">停止</button> <button @click="play">播放</button> <button @click="openSound">开启声音</button> <button @click="closeSound">关闭声音</button> <button @click="startSave">开始录制</button> <button @click="stopSave">结束录制</button> <button @click="capturePicture">截图</button> <button @click="fullScreen">全屏</button> <button @click="cancelFullScreen">退出全屏</button> <button @click="getOSDTime">获取基准时间</button> <button @click="ezopenStartTalk">开始对讲</button> <button @click="ezopenStopTalk">结束对讲</button> <button @click="destroy">销毁</button> </div> </div> </template>
<script setup> import { onMounted } from "vue"; import EZUIKit from "ezuikit-js";
let player;
function init() { if (player) destroy(); fetch("https://open.ys7.com/jssdk/ezopen/demo/token") .then((response) => response.json()) .then((res) => { var accessToken = res.data.accessToken; player = new EZUIKit.EZUIKitPlayer({ id: "video-container", accessToken: accessToken, url: "ezopen://open.ys7.com/序列号/通道号.live", template: "simple", plugin: [], width: 600, height: 400, }); window.player = player; }); }
onMounted(() => { init(); });
function play() { const playPromise = player.play(); playPromise.then((data) => { console.log("promise 获取 数据", data); }); }
function stop() { const stopPromise = player.stop(); stopPromise.then((data) => { console.log("promise 获取 数据", data); }); }
function getOSDTime() { const getOSDTimePromise = player.getOSDTime(); getOSDTimePromise.then((data) => { console.log("promise 获取 数据", data); }); }
function capturePicture() { player.capturePicture(`${new Date().getTime()}`, (data) => { console.log("截图数据", data); }); }
function openSound() { const openSoundPromise = player.openSound(); openSoundPromise.then((data) => { console.log("promise 获取 数据", data); }); }
function closeSound() { const openSoundPromise = player.closeSound(); openSoundPromise.then((data) => { console.log("promise 获取 数据", data); }); }
function startSave() { const startSavePromise = player.startSave(`${new Date().getTime()}`); startSavePromise.then((data) => { console.log("promise 获取 数据", data); }); }
function stopSave() { const stopSavePromise = player.stopSave(); stopSavePromise.then((data) => { console.log("promise 获取 数据", data); }); }
function ezopenStartTalk() { player.startTalk(); }
function ezopenStopTalk() { player.stopTalk(); }
function fullScreen() { player.fullScreen(); }
function cancelFullScreen() { player.cancelFullScreen(); }
function destroy() { player.value = null; document.getElementById(playerId.value)?.remove(); } </script>
|