|
1 | 1 | <script lang="ts" setup> |
2 | | -import EZUIKit from 'ezuikit-js' |
3 | | -import { onMounted } from 'vue' |
| 2 | +import EZUIKit from "ezuikit-js"; |
| 3 | +import { onMounted } from "vue"; |
4 | 4 |
|
5 | 5 | interface IPlayer { |
6 | | - play: Function |
7 | | - stop: Function |
8 | | - getOSDTime: Function |
9 | | - capturePicture: Function |
10 | | - openSound: Function |
11 | | - closeSound: Function |
12 | | - startSave: Function |
13 | | - stopSave: Function |
14 | | - startTalk: Function |
15 | | - stopTalk: Function |
16 | | - fullScreen: Function |
17 | | - destroy: Function |
| 6 | + play: Function; |
| 7 | + stop: Function; |
| 8 | + getOSDTime: Function; |
| 9 | + capturePicture: Function; |
| 10 | + openSound: Function; |
| 11 | + closeSound: Function; |
| 12 | + startSave: Function; |
| 13 | + stopSave: Function; |
| 14 | + startTalk: Function; |
| 15 | + stopTalk: Function; |
| 16 | + fullScreen: Function; |
| 17 | + destroy: Function; |
18 | 18 | } |
19 | 19 |
|
20 | | -let player:IPlayer |
| 20 | +let player: IPlayer; |
21 | 21 |
|
22 | 22 | const play = () => { |
23 | | - const playPromise = player.play() |
| 23 | + const playPromise = player.play(); |
24 | 24 | playPromise.then((data: any) => { |
25 | | - console.log('promise 获取 数据', data) |
26 | | - }) |
27 | | -} |
| 25 | + console.log("promise 获取 数据", data); |
| 26 | + }); |
| 27 | +}; |
28 | 28 |
|
29 | 29 | const stop = () => { |
30 | | - const stopPromise = player.stop() |
| 30 | + const stopPromise = player.stop(); |
31 | 31 | stopPromise.then((data: any) => { |
32 | | - console.log('promise 获取 数据', data) |
33 | | - }) |
34 | | -} |
| 32 | + console.log("promise 获取 数据", data); |
| 33 | + }); |
| 34 | +}; |
35 | 35 |
|
36 | 36 | const getOSDTime = () => { |
37 | | - const getOSDTimePromise = player.getOSDTime() |
| 37 | + const getOSDTimePromise = player.getOSDTime(); |
38 | 38 | getOSDTimePromise.then((data: any) => { |
39 | | - console.log('promise 获取 数据', data) |
40 | | - }) |
41 | | -} |
| 39 | + console.log("promise 获取 数据", data); |
| 40 | + }); |
| 41 | +}; |
42 | 42 |
|
43 | 43 | const capturePicture = () => { |
44 | | - const capturePicturePromise = player.capturePicture(`${new Date().getTime()}`) |
| 44 | + const capturePicturePromise = player.capturePicture( |
| 45 | + `${new Date().getTime()}` |
| 46 | + ); |
45 | 47 | capturePicturePromise.then((data: any) => { |
46 | | - console.log('promise 获取 数据', data) |
47 | | - }) |
48 | | -} |
| 48 | + console.log("promise 获取 数据", data); |
| 49 | + }); |
| 50 | +}; |
49 | 51 |
|
50 | 52 | const openSound = () => { |
51 | | - const openSoundPromise = player.openSound() |
| 53 | + const openSoundPromise = player.openSound(); |
52 | 54 | openSoundPromise.then((data: any) => { |
53 | | - console.log('promise 获取 数据', data) |
54 | | - }) |
55 | | -} |
| 55 | + console.log("promise 获取 数据", data); |
| 56 | + }); |
| 57 | +}; |
56 | 58 |
|
57 | 59 | const closeSound = () => { |
58 | | - const openSoundPromise = player.closeSound() |
| 60 | + const openSoundPromise = player.closeSound(); |
59 | 61 | openSoundPromise.then((data: any) => { |
60 | | - console.log('promise 获取 数据', data) |
61 | | - }) |
62 | | -} |
| 62 | + console.log("promise 获取 数据", data); |
| 63 | + }); |
| 64 | +}; |
63 | 65 |
|
64 | 66 | const startSave = () => { |
65 | | - const startSavePromise = player.startSave(`${new Date().getTime()}`) |
| 67 | + const startSavePromise = player.startSave(`${new Date().getTime()}`); |
66 | 68 | startSavePromise.then((data: any) => { |
67 | | - console.log('promise 获取 数据', data) |
68 | | - }) |
69 | | -} |
| 69 | + console.log("promise 获取 数据", data); |
| 70 | + }); |
| 71 | +}; |
70 | 72 |
|
71 | 73 | const stopSave = () => { |
72 | | - const stopSavePromise = player.stopSave() |
| 74 | + const stopSavePromise = player.stopSave(); |
73 | 75 | stopSavePromise.then((data: any) => { |
74 | | - console.log('promise 获取 数据', data) |
75 | | - }) |
76 | | -} |
| 76 | + console.log("promise 获取 数据", data); |
| 77 | + }); |
| 78 | +}; |
77 | 79 |
|
78 | 80 | const ezopenStartTalk = () => { |
79 | | - player.startTalk() |
80 | | -} |
| 81 | + player.startTalk(); |
| 82 | +}; |
81 | 83 |
|
82 | 84 | const ezopenStopTalk = () => { |
83 | | - player.stopTalk() |
84 | | -} |
| 85 | + player.stopTalk(); |
| 86 | +}; |
85 | 87 |
|
86 | 88 | const fullScreen = () => { |
87 | | - player.fullScreen() |
88 | | -} |
| 89 | + player.fullScreen(); |
| 90 | +}; |
89 | 91 |
|
90 | 92 | const destroy = () => { |
91 | | - const destroyPromise = player.destroy() |
| 93 | + const destroyPromise = player.destroy(); |
92 | 94 | destroyPromise.then((data: any) => { |
93 | | - console.log('promise 获取 数据', data) |
94 | | - }) |
95 | | -} |
| 95 | + console.log("promise 获取 数据", data); |
| 96 | + }); |
| 97 | +}; |
96 | 98 |
|
97 | 99 | onMounted(() => { |
98 | | - console.group('mounted 组件挂载完毕状态===============》') |
99 | | - fetch('https://open.ys7.com/jssdk/ezopen/demo/token') |
100 | | - .then(response => response.json()) |
101 | | - .then(res => { |
102 | | - var accessToken = res.data.accessToken; |
103 | | - player = new EZUIKit.EZUIKitPlayer({ |
104 | | - id: 'video-container', // 视频容器ID |
105 | | - accessToken: accessToken, |
106 | | - url: 'ezopen://open.ys7.com/G39444019/1.live', |
107 | | - // simple - 极简版; pcLive-pc直播;pcRec-pc回放;mobileLive-移动端直播;mobileRec-移动端回放;security - 安防版;voice-语音版; |
108 | | - //template: 'simple', |
109 | | - plugin: ['talk'], // 加载插件,talk-对讲 |
110 | | - width: 600, |
111 | | - height: 400, |
112 | | - }) |
113 | | - window.player = player |
114 | | - }) |
115 | | -}) |
| 100 | + console.group("mounted 组件挂载完毕状态===============》"); |
| 101 | + fetch("https://open.ys7.com/jssdk/ezopen/demo/token") |
| 102 | + .then((response) => response.json()) |
| 103 | + .then((res) => { |
| 104 | + var accessToken = res.data.accessToken; |
| 105 | + player = new EZUIKit.EZUIKitPlayer({ |
| 106 | + id: "video-container", // 视频容器ID |
| 107 | + accessToken: accessToken, |
| 108 | + url: "ezopen://open.ys7.com/G39444019/1.live", |
| 109 | + // simple - 极简版; pcLive-pc直播;pcRec-pc回放;mobileLive-移动端直播;mobileRec-移动端回放;security - 安防版;voice-语音版; |
| 110 | + //template: 'simple', |
| 111 | + plugin: ["talk"], // 加载插件,talk-对讲 |
| 112 | + width: 600, |
| 113 | + height: 400, |
| 114 | + }); |
| 115 | + window.player = player; |
| 116 | + }); |
| 117 | +}); |
116 | 118 | </script> |
117 | 119 |
|
118 | 120 | <template> |
119 | | -<div class="hello-ezuikit-js"> |
120 | | - <div id="video-container" style="width:600px;height:400px"></div> |
| 121 | + <div class="hello-ezuikit-js"> |
| 122 | + <div id="video-container" style="width: 600px; height: 400px"></div> |
121 | 123 | <div> |
122 | 124 | <button @click="stop">stop</button> |
123 | 125 | <button @click="play">play</button> |
|
0 commit comments