|
4 | 4 | <head> |
5 | 5 | <meta charset="UTF-8"> |
6 | 6 | <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> |
7 | | - <title>Document</title> |
| 7 | + <title>template</title> |
8 | 8 | <script src="./ezuikit.js"></script> |
9 | 9 | </head> |
10 | 10 |
|
11 | 11 | <body> |
12 | 12 | <div className="demo"> |
13 | 13 | <h2>视频模式使用示例:</h2> |
14 | | - <div id="video-container" style="width:600px;"> |
| 14 | + <div id="video-container" style="height: 400px;"></div> |
| 15 | + <div> |
| 16 | + <div> |
| 17 | + url <input id="url" style="width: 500px;" value="ezopen://open.ys7.com/BC7799091/1.live" /> |
| 18 | + </div> |
| 19 | + <div> |
| 20 | + accessToken <input id="accessToken" style="width: 500px;" value="at.1avhd3v86cp1lme835myxf3y81vlmih6-3goswzltfu-1wjopp9-cunywpbba" /> |
| 21 | + </div> |
| 22 | + <div> |
| 23 | + template <input id="template" style="width: 500px;" value="0ced7b62b01b42f59fc3e7d2b5fc1245" /> |
| 24 | + </div> |
| 25 | + <div> |
| 26 | + staticPath <input id="staticPath" style="width: 500px;" value="./ezuikit_static" /> |
| 27 | + </div> |
15 | 28 | </div> |
16 | 29 | <div> |
17 | | - <button onClick="play()">play</button> |
18 | | - <button onClick="stop()">stop</button> |
19 | | - <button onClick="getOSDTime()">getOSDTime</button> |
20 | | - <button onClick="capturePicture()">capturePicture</button> |
21 | | - <button onClick="openSound()">openSound</button> |
22 | | - <button onClick="closeSound()">closeSound</button> |
23 | | - <button onClick="startSave()">startSave</button> |
24 | | - <button onClick="stopSave()">stopSave</button> |
25 | | - <button onClick="ezopenStartTalk()">开始对讲</button> |
26 | | - <button onClick="ezopenStopTalk()">结束对讲</button> |
27 | | - <button onClick="fullScreen()">全屏</button> |
| 30 | + <button onClick="init()">初始化</button> |
| 31 | + <button onClick="play()">play()</button> |
| 32 | + <button onClick="stop()">stop()</button> |
| 33 | + <button onClick="getOSDTime()">getOSDTime()</button> |
| 34 | + <button onClick="capturePicture()">capturePicture()</button> |
| 35 | + <button onClick="openSound()">openSound()</button> |
| 36 | + <button onClick="closeSound()">closeSound()</button> |
| 37 | + <button onClick="startSave()">startSave()</button> |
| 38 | + <button onClick="stopSave()">stopSave()</button> |
| 39 | + <button onClick="startTalk()">startTalk()</button> |
| 40 | + <button onClick="stopTalk()">stopTalk()</button> |
| 41 | + <button onClick="fullscreen()">fullscreen()</button> |
| 42 | + <button onClick="destroy()">destroy()</button> |
28 | 43 | </div> |
29 | | - <p style="font-style: italic;">播放多个视频,可初始化多个实例,参考:/demos/base-demo/multi-demo</p> |
| 44 | + <p style="font-style: italic;">播放多个视频,可初始化多个实例,参考:<a href="./multi.html">multi.html</a></p> |
30 | 45 | </div> |
31 | 46 | <script> |
32 | 47 | var player; |
33 | 48 | // 获取测试token |
34 | | - fetch('https://open.ys7.com/jssdk/ezopen/demo/token') |
35 | | - .then(response => response.json()) |
36 | | - .then(res => { |
37 | | - var accessToken = res.data.accessToken; |
38 | | - // 获取主题 |
39 | | - fetch(`https://open.ys7.com/jssdk/ezopen/template/get?pageStart=1&pageSize=10&accessToken=${accessToken}`) |
40 | | - .then(response => response.json()) |
41 | | - .then(res => { |
42 | | - var template = res.data.result[0].themeId; |
43 | | - player = new EZUIKit.EZUIKitPlayer({ |
44 | | - id: 'video-container', // 视频容器ID |
45 | | - accessToken: accessToken, |
46 | | - url: 'ezopen://open.ys7.com/G39444019/1.live', |
47 | | - template: template, // simple: 极简版; pcLive: 预览; pcRec: 回放; security: 安防版; voice: 语音版; |
48 | | - plugin: ['talk'], // 加载插件,talk-对讲 |
49 | | - width: 600, |
50 | | - height: 400, |
51 | | - env: { |
52 | | - // https://open.ys7.com/help/1772?h=domain |
53 | | - // domain默认是 https://open.ys7.com, 如果是私有化部署或海外的环境,请配置对应的domain |
54 | | - // 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 |
55 | | - domain: "https://open.ys7.com" |
56 | | - } |
57 | | - }); |
58 | | - }) |
| 49 | + // fetch('https://open.ys7.com/jssdk/ezopen/demo/token') |
| 50 | + // .then(response => response.json()) |
| 51 | + // .then(res => { |
| 52 | + // var accessToken = res.data.accessToken; |
| 53 | + // // 获取主题 |
| 54 | + // fetch(`https://open.ys7.com/jssdk/ezopen/template/get?pageStart=1&pageSize=10&accessToken=${accessToken}`) |
| 55 | + // .then(response => response.json()) |
| 56 | + // .then(res => { |
| 57 | + // var template = res.data.result[0].themeId; |
| 58 | + // }) |
| 59 | + // }); |
| 60 | + |
| 61 | + function init() { |
| 62 | + const url = (document.getElementById('url').value).trim(); |
| 63 | + const accessToken = (document.getElementById('accessToken').value).trim(); |
| 64 | + const template = (document.getElementById('template').value).trim(); |
| 65 | + const staticPath = (document.getElementById('staticPath').value).trim(); |
| 66 | + destroy() |
| 67 | + player = new EZUIKit.EZUIKitPlayer({ |
| 68 | + id: 'video-container', // 视频容器ID |
| 69 | + accessToken: accessToken, |
| 70 | + url: url, |
| 71 | + template: template, // simple: 极简版; pcLive: 预览; pcRec: 回放; security: 安防版; voice: 语音版; |
| 72 | + // width: 600, |
| 73 | + height: 400, |
| 74 | + staticPath: staticPath, // 如果想使用本地静态资源,请复制根目录下ezuikit_static 到当前目录下, 然后设置该值 |
| 75 | + env: { |
| 76 | + // https://open.ys7.com/help/1772?h=domain |
| 77 | + // domain默认是 https://open.ys7.com, 如果是私有化部署或海外的环境,请配置对应的domain |
| 78 | + // 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 |
| 79 | + domain: "https://open.ys7.com" |
| 80 | + } |
59 | 81 | }); |
60 | | - function fullScreen() { |
61 | | - var playPromise = player.fullScreen(); |
62 | | - playPromise.then((data) => { |
63 | | - console.log("promise 获取 数据", data) |
64 | | - }) |
65 | 82 | } |
| 83 | + |
| 84 | + function fullscreen() { |
| 85 | + if (player) player.fullscreen() |
| 86 | + } |
| 87 | + |
66 | 88 | function play() { |
67 | | - var playPromise = player.play(); |
68 | | - playPromise.then((data) => { |
69 | | - console.log("promise 获取 数据", data) |
70 | | - }) |
| 89 | + if (player) player.play() |
71 | 90 | } |
| 91 | + |
72 | 92 | function stop() { |
73 | | - var stopPromise = player.stop(); |
74 | | - stopPromise.then((data) => { |
75 | | - console.log("promise 获取 数据", data) |
76 | | - }) |
| 93 | + if (player) player.stop(); |
77 | 94 | } |
| 95 | + |
78 | 96 | function getOSDTime() { |
79 | | - var getOSDTimePromise = player.getOSDTime(); |
80 | | - getOSDTimePromise.then((data) => { |
81 | | - console.log("promise 获取 数据", data) |
82 | | - }) |
| 97 | + if (player) { |
| 98 | + player.getOSDTime().then((data) => { |
| 99 | + console.log("getOSDTime 获取 数据", data) |
| 100 | + }) |
| 101 | + } |
83 | 102 | } |
84 | 103 |
|
85 | 104 | function capturePicture() { |
86 | | - var capturePicturePromise = player.capturePicture(); |
87 | | - capturePicturePromise.then((data) => { |
88 | | - console.log("promise 获取 数据", data) |
89 | | - }) |
| 105 | + if (player) { |
| 106 | + player.capturePicture().then((data) => { |
| 107 | + console.log("capturePicture 获取 数据", data) |
| 108 | + }) |
| 109 | + } |
90 | 110 | } |
| 111 | + |
91 | 112 | function openSound() { |
92 | | - var openSoundPromise = player.openSound(); |
93 | | - openSoundPromise.then((data) => { |
94 | | - console.log("promise 获取 数据", data) |
95 | | - }) |
| 113 | + if (player) { |
| 114 | + player.openSound().then((data) => { |
| 115 | + console.log("openSound 获取 数据", data) |
| 116 | + }) |
| 117 | + } |
96 | 118 | } |
| 119 | + |
97 | 120 | function closeSound() { |
98 | | - var closeSoundPromise = player.closeSound(); |
99 | | - closeSoundPromise.then((data) => { |
100 | | - console.log("promise 获取 数据", data) |
101 | | - }) |
| 121 | + if (player) { |
| 122 | + player.closeSound().then((data) => { |
| 123 | + console.log("closeSound 获取 数据", data) |
| 124 | + }) |
| 125 | + } |
102 | 126 | } |
| 127 | + |
103 | 128 | function startSave() { |
104 | | - var startSavePromise = player.startSave(); |
105 | | - startSavePromise.then((data) => { |
106 | | - console.log("promise 获取 数据", data) |
107 | | - }) |
| 129 | + if (player) { |
| 130 | + player.startSave().then((data) => { |
| 131 | + console.log("startSave 获取 数据", data) |
| 132 | + }) |
| 133 | + } |
108 | 134 | } |
| 135 | + |
109 | 136 | function stopSave() { |
110 | | - var stopSavePromise = player.stopSave(); |
111 | | - stopSavePromise.then((data) => { |
112 | | - console.log("promise 获取 数据", data) |
113 | | - }) |
| 137 | + if (player) { |
| 138 | + player.stopSave().then((data) => { |
| 139 | + console.log("stopSave 获取 数据", data) |
| 140 | + }) |
| 141 | + } |
114 | 142 | } |
115 | | - function ezopenStartTalk() { |
116 | | - player.startTalk(); |
| 143 | + |
| 144 | + function startTalk() { |
| 145 | + if (player) player.startTalk(); |
117 | 146 | } |
118 | | - function ezopenStopTalk() { |
119 | | - player.stopTalk(); |
| 147 | + |
| 148 | + function stopTalk() { |
| 149 | + if (player) player.stopTalk(); |
| 150 | + } |
| 151 | + |
| 152 | + function destroy() { |
| 153 | + if (player) { |
| 154 | + player.destroy(); |
| 155 | + player = null; |
| 156 | + } |
120 | 157 | } |
121 | 158 | </script> |
122 | 159 | </body> |
|
0 commit comments