|
2 | 2 | <div class="hello-ezuikit-js"> |
3 | 3 | <div id="video-container" style="width: 600px; height: 400px"></div> |
4 | 4 | <div> |
| 5 | + <button v-on:click="init">init</button> |
5 | 6 | <button v-on:click="stop">stop</button> |
6 | 7 | <button v-on:click="play">play</button> |
7 | 8 | <button v-on:click="openSound">openSound</button> |
@@ -29,24 +30,31 @@ export default { |
29 | 30 | }, |
30 | 31 | mounted: () => { |
31 | 32 | console.group("mounted 组件挂载完毕状态===============》"); |
32 | | - fetch("https://open.ys7.com/jssdk/ezopen/demo/token") |
33 | | - .then((response) => response.json()) |
34 | | - .then((res) => { |
35 | | - var accessToken = res.data.accessToken; |
36 | | - player = new EZUIKit.EZUIKitPlayer({ |
37 | | - id: "video-container", // 视频容器ID |
38 | | - accessToken: accessToken, |
39 | | - url: "ezopen://open.ys7.com/G39444019/1.live", |
40 | | - // simple - 极简版; pcLive-pc直播;pcRec-pc回放;mobileLive-移动端直播;mobileRec-移动端回放;security - 安防版;voice-语音版; |
41 | | - //template: 'simple', |
42 | | - plugin: ["talk"], // 加载插件,talk-对讲 |
43 | | - width: 600, |
44 | | - height: 400 |
45 | | - }); |
46 | | - window.player = player; |
47 | | - }); |
48 | 33 | }, |
49 | 34 | methods: { |
| 35 | + init() { |
| 36 | + if (player) { |
| 37 | + this.destroy(); |
| 38 | + } |
| 39 | +
|
| 40 | + fetch("https://open.ys7.com/jssdk/ezopen/demo/token") |
| 41 | + .then((response) => response.json()) |
| 42 | + .then((res) => { |
| 43 | + var accessToken = res.data.accessToken; |
| 44 | + player = new EZUIKit.EZUIKitPlayer({ |
| 45 | + id: "video-container", // 视频容器ID |
| 46 | + accessToken: |
| 47 | + "at.dynmds5wcjnjbtls3lf7tuwu13aobjm2-490yt3xp77-0gl3ntq-44scndtqf", |
| 48 | + url: "ezopen://open.ys7.com/G39444019/1.live", |
| 49 | + // simple: 极简版; pcLive: pc直播; pcRec: pc回放; mobileLive: 移动端直播; mobileRec: 移动端回放;security: 安防版; voice: 语音版; |
| 50 | + template: "pcLive", |
| 51 | + plugin: ["talk"], // 加载插件,talk-对讲 |
| 52 | + width: 600, |
| 53 | + height: 400 |
| 54 | + }); |
| 55 | + window.player = player; |
| 56 | + }); |
| 57 | + }, |
50 | 58 | play() { |
51 | 59 | var playPromise = player.play(); |
52 | 60 | playPromise.then((data) => { |
@@ -111,6 +119,7 @@ export default { |
111 | 119 | destroyPromise.then((data) => { |
112 | 120 | console.log("promise 获取 数据", data); |
113 | 121 | }); |
| 122 | + player = null; |
114 | 123 | } |
115 | 124 | } |
116 | 125 | }; |
|
0 commit comments