wg-video-player 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +13 -0
- package/README.md +180 -0
- package/dist/style.css +1 -0
- package/dist/wg-video-player.js +165261 -0
- package/dist/wg-video-player.umd.cjs +995 -0
- package/examples/App.vue +341 -0
- package/examples/fakeData.js +743 -0
- package/examples/main.js +32 -0
- package/package.json +56 -0
- package/uno.config.ts +12 -0
- package/vite.config.js +65 -0
- package/wg-video-player.d.ts +52 -0
package/examples/App.vue
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="demo grid">
|
|
3
|
+
<div class="mvp-multi-player-container">
|
|
4
|
+
<div class="mvp-multi-player">
|
|
5
|
+
<multi-player
|
|
6
|
+
:enable-new="true"
|
|
7
|
+
:mode="targetMode"
|
|
8
|
+
:videos="videos"
|
|
9
|
+
:seekable="seekable"
|
|
10
|
+
:seek-warning="seekWarning"
|
|
11
|
+
:autoPlay="autoPlay"
|
|
12
|
+
:last-played="lastPlayed"
|
|
13
|
+
:plugins="plugins"
|
|
14
|
+
:custom-event-timestamps="timestamps"
|
|
15
|
+
:is-simple-controls="isSimpleControls"
|
|
16
|
+
:enable-play-rate="enablePlayRate"
|
|
17
|
+
@playerReady="playerReady"
|
|
18
|
+
/>
|
|
19
|
+
</div>
|
|
20
|
+
<div class="mvp-multi-player-log" v-if="false">
|
|
21
|
+
<div class="video-log">
|
|
22
|
+
<div class="video-title">{{ '多路视频log' }}</div>
|
|
23
|
+
<div class="log-content">
|
|
24
|
+
<div v-if="targetMode === 'replay'" class="log">
|
|
25
|
+
<div>{{ '播放器基本属性:' }}</div>
|
|
26
|
+
<div class="log-view">
|
|
27
|
+
<p>{{ '当前时间:' + currentTime }}</p>
|
|
28
|
+
<p>{{ '视频时长:' + duration }}</p>
|
|
29
|
+
<p>{{ '音量:' + volumeView }}</p>
|
|
30
|
+
<p>
|
|
31
|
+
{{ '倍速:' + playerRate.rate + ' 时间点:' + playerRate.position }}
|
|
32
|
+
</p>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
<div class="log">
|
|
36
|
+
<div>{{ '播放器状态追踪' }}</div>
|
|
37
|
+
<div class="log-view" ref="stateLog">
|
|
38
|
+
<div class="single-log-view" v-for="(log, index) in playerStatusLogs" :key="index">
|
|
39
|
+
<span>{{ '时间戳:' + log.timestamp }}</span>
|
|
40
|
+
<br />
|
|
41
|
+
<span>{{ '视频时间点:' + log.position }}</span>
|
|
42
|
+
<br />
|
|
43
|
+
<span>{{ '状态变更:' + log.msg }}</span>
|
|
44
|
+
<br />
|
|
45
|
+
<span v-if="targetMode === 'live'">{{ '视频Index:' + log.videoIndex }}</span>
|
|
46
|
+
<br />
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
<div class="mvp-i18n-test">
|
|
55
|
+
<div class="button" @click="paused = true" v-if="targetMode === 'replay'">暂停视频</div>
|
|
56
|
+
<div class="button" @click="paused = false" v-if="targetMode === 'replay'">播放视频</div>
|
|
57
|
+
</div>
|
|
58
|
+
<div class="mvp-i18n-test">
|
|
59
|
+
<div class="button" @click="changeMode('replay')">录播模式</div>
|
|
60
|
+
<div class="button" @click="changeMode('live')">直播模式</div>
|
|
61
|
+
</div>
|
|
62
|
+
<div class="mvp-i18n-test">
|
|
63
|
+
<div class="button" @click="closePlayer">关闭播放器</div>
|
|
64
|
+
<div class="button" @click="openPlayer">打开播放器</div>
|
|
65
|
+
</div>
|
|
66
|
+
<div class="mvp-i18n-test">
|
|
67
|
+
<div class="button" @click="changeLocale('cn')">简体中文</div>
|
|
68
|
+
<div class="button" @click="changeLocale('tw')">繁体中文</div>
|
|
69
|
+
<div class="button" @click="changeLocale('us')">英文</div>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
</template>
|
|
73
|
+
|
|
74
|
+
<script>
|
|
75
|
+
import { secondsToHms } from '@/utils/time-format';
|
|
76
|
+
import fakeData from './fakeData';
|
|
77
|
+
|
|
78
|
+
export default {
|
|
79
|
+
data() {
|
|
80
|
+
const autoPlay = false;
|
|
81
|
+
const lastPlayed = 0;
|
|
82
|
+
return {
|
|
83
|
+
multiPlayer: null,
|
|
84
|
+
plugins: fakeData.plugins,
|
|
85
|
+
isSimpleControls: false,
|
|
86
|
+
targetMode: 'replay',
|
|
87
|
+
videoLogs: {},
|
|
88
|
+
playerAttrLog: {
|
|
89
|
+
currentTime: 0,
|
|
90
|
+
duration: 0,
|
|
91
|
+
volume: 0,
|
|
92
|
+
},
|
|
93
|
+
playerRate: {
|
|
94
|
+
rate: 1,
|
|
95
|
+
position: 0,
|
|
96
|
+
},
|
|
97
|
+
playerStatusLogs: [],
|
|
98
|
+
seekable: true,
|
|
99
|
+
seekWarning: '老师已设置观看该视频时不能快进',
|
|
100
|
+
enablePlayRate: true,
|
|
101
|
+
lastThreshold: lastPlayed + 30,
|
|
102
|
+
autoPlay,
|
|
103
|
+
lastPlayed,
|
|
104
|
+
pausedAt: lastPlayed,
|
|
105
|
+
show: true,
|
|
106
|
+
show1: true,
|
|
107
|
+
paused: !autoPlay,
|
|
108
|
+
timestamps: [15, 20, 30],
|
|
109
|
+
current: 20,
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
computed: {
|
|
113
|
+
videos() {
|
|
114
|
+
return this.targetMode === 'replay' ? fakeData.replayVideos : fakeData.liveVideos;
|
|
115
|
+
},
|
|
116
|
+
multiPlayerListeners() {
|
|
117
|
+
const commonListeners = { ...this.$listeners, ...this.trackListeners };
|
|
118
|
+
return this.targetMode === 'replay' ? { ...this.pluginListeners, ...commonListeners } : commonListeners;
|
|
119
|
+
},
|
|
120
|
+
currentTime() {
|
|
121
|
+
return secondsToHms(this.playerAttrLog.currentTime);
|
|
122
|
+
},
|
|
123
|
+
duration() {
|
|
124
|
+
return secondsToHms(this.playerAttrLog.duration);
|
|
125
|
+
},
|
|
126
|
+
volumeView() {
|
|
127
|
+
return Math.floor(this.playerAttrLog.volume * 100) / 100;
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
methods: {
|
|
131
|
+
playerReady(multiPlayer) {
|
|
132
|
+
this.multiPlayer = multiPlayer;
|
|
133
|
+
// this.multiPlayer.toggleVolume();
|
|
134
|
+
if (this.targetMode === 'live') {
|
|
135
|
+
this.multiPlayer.startSyncPlayers();
|
|
136
|
+
console.log('player ready ............');
|
|
137
|
+
}
|
|
138
|
+
multiPlayer.configPlugin('caption', {
|
|
139
|
+
toggle: true,
|
|
140
|
+
mediaId: '852e07a579984725aabd78a0a52b2ec8',
|
|
141
|
+
server: 'https://incast-uat.tronclass.com.cn',
|
|
142
|
+
source:
|
|
143
|
+
'ilesson://ilesson?download_url=aHR0cDovL2xvY2FsaG9zdDo4MDAyL3ZpZGVvcy9ST09NXzNfVklERU8vMjAxOTEwMDEvMDgwMDAwLTA4NDUwMC9jYW1fZW5jb2Rlcg==',
|
|
144
|
+
organization: 'wisdomgarden-uat',
|
|
145
|
+
callback: '',
|
|
146
|
+
downloadUrl: '',
|
|
147
|
+
permissions: {
|
|
148
|
+
create: true,
|
|
149
|
+
upload: true,
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
multiPlayer.configPlugin('liveCaption', {
|
|
153
|
+
toggle: false,
|
|
154
|
+
server: 'http://localhost:21082',
|
|
155
|
+
deviceCode: 'livestream',
|
|
156
|
+
});
|
|
157
|
+
multiPlayer.configPlugin('topic', {
|
|
158
|
+
toggle: true,
|
|
159
|
+
mediaId: '852e07a579984725aabd78a0a52b2ec8',
|
|
160
|
+
server: 'https://incast-uat.tronclass.com.cn',
|
|
161
|
+
callback: 'http://localhost:8088/api/media-topic/callback',
|
|
162
|
+
organization: 'wisdomgarden-uat',
|
|
163
|
+
lang: 'zh-CN',
|
|
164
|
+
aiTopic: {
|
|
165
|
+
toggle: true,
|
|
166
|
+
category: '生物', // 知识点大类,一般是课程名称
|
|
167
|
+
asrInput:
|
|
168
|
+
'ilesson://ilesson?download_url=aHR0cDovL2xvY2FsaG9zdDo4MDAyL3ZpZGVvcy9ST09NXzNfVklERU8vMjAxOTEwMDEvMDgwMDAwLTA4NDUwMC9jYW1fZW5jb2Rlcg==', // 用来做asr分析的视频下载地址
|
|
169
|
+
ocrInput:
|
|
170
|
+
'ilesson://ilesson?download_url=aHR0cDovL2xvY2FsaG9zdDo4MDAyL3ZpZGVvcy9ST09NXzNfVklERU8vMjAxOTEwMDEvMDgwMDAwLTA4NDUwMC9jYW1fZW5jb2Rlcg==', // 用来做ocr分析的视频下载地址
|
|
171
|
+
permissions: {
|
|
172
|
+
manage: ['generate', 'delete', 'transfer', 'publish', 'recover'],
|
|
173
|
+
view: ['all'],
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
manualTopic: {
|
|
177
|
+
permissions: {
|
|
178
|
+
manage: ['create', 'delete', 'update'],
|
|
179
|
+
view: ['all'],
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
multiPlayer.configPlugin('switcher', { toggle: true });
|
|
184
|
+
multiPlayer.configPlugin('controller', {
|
|
185
|
+
toggle: false,
|
|
186
|
+
server: 'http://localhost:8088',
|
|
187
|
+
mediaId: '94',
|
|
188
|
+
organization: 'wisdomgarden',
|
|
189
|
+
permissions: {
|
|
190
|
+
manage: ['live', 'record', 'stop'],
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
multiPlayer.configPlugin('waterMark', {
|
|
194
|
+
toggle: true,
|
|
195
|
+
text: 'U00001',
|
|
196
|
+
});
|
|
197
|
+
multiPlayer.configPlugin('chat', {
|
|
198
|
+
toggle: false,
|
|
199
|
+
server: 'http://localhost:5030',
|
|
200
|
+
token:
|
|
201
|
+
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25vIjoiMiIsInVzZXJfbmFtZSI6Ilx1NzUyOFx1NjIzNzIiLCJyb29tX2lkIjoxLCJyb29tX25hbWUiOiJCaWdfUm9vbSIsInJvbGUiOiJzdHVkZW50IiwiZXhwIjoxNjMyOTg4MDQ0fQ.wZXwoyXYbNwdUczPU_9ufhhbtMLtozCxEYk6evRd5xs',
|
|
202
|
+
});
|
|
203
|
+
multiPlayer.configPlugin('note', {
|
|
204
|
+
toggle: true,
|
|
205
|
+
// server: 'http://notabene.uat.tronclass.com.cn:18888',
|
|
206
|
+
token:
|
|
207
|
+
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOiJVMDAwMyIsImRpc3BsYXlfbmFtZSI6IlNoYXduIiwidXJpIjoidXJuOnRyb25jYXN0OnJlcGxheTo3MDcyOGI0ZDkxYjE0ZGJjYTY4OGY0ZTcyYjI3NzlmNyIsInNlcnZlciI6Imh0dHA6Ly9ub3RhYmVuZS51YXQudHJvbmNsYXNzLmNvbS5jbjoxODg4OCIsInN0b3JhZ2UiOnsidHlwZSI6Ik1FRElBIiwic2VydmVyIjoiaHR0cDovL2xvY2FsaG9zdDo4MDAxIiwic2VjcmV0IjoiaW5zZWN1cmUgc2VjcmV0IGtleSJ9fQ.1zJnhWPcBqKfW7W6GbYYTPKfSDJX5Eb7zf-iLOENTus',
|
|
208
|
+
permissions: {
|
|
209
|
+
manage: ['create', 'delete', 'update'],
|
|
210
|
+
view: ['public', 'myself'],
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
multiPlayer.configPlugin('ppt', {
|
|
214
|
+
toggle: true,
|
|
215
|
+
mediaId: 'media-1',
|
|
216
|
+
server: 'http://localhost:8088',
|
|
217
|
+
source:
|
|
218
|
+
'https://minio.tronclass.com.cn/outbound/wisdomgarden/ARTS403/20230908/150000-150500-1694160880354/INSTRUCTOR-d2lzZG9tZ2FyZGVuLUFSVFM0MDMtRGV2aWNlTGFiZWwuSU5TVFJVQ1RPUi0xLTE2OTQxNTkzMTAxODM-.mp4?response-content-disposition=attachment%3B%20filename%2A%3DUTF-8%27%27INSTRUCTOR-d2lzZG9tZ2FyZGVuLUFSVFM0MDMtRGV2aWNlTGFiZWwuSU5TVFJVQ1RPUi0xLTE2OTQxNTkzMTAxODM-.mp4&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=YBQUE8NVWSQGSEZRNDUK%2F20231016%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20231016T081119Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=cbe69b3ce042afada1b6a931ff725de0a43d322240aec075c084a1b4c52e4d1a',
|
|
219
|
+
organization: 'wisdomgarden',
|
|
220
|
+
callback: '',
|
|
221
|
+
permissions: {
|
|
222
|
+
manage: ['create', 'delete', 'update', 'ai-generate'],
|
|
223
|
+
view: ['all'],
|
|
224
|
+
},
|
|
225
|
+
});
|
|
226
|
+
},
|
|
227
|
+
closePlayer() {
|
|
228
|
+
this.multiPlayer.close();
|
|
229
|
+
},
|
|
230
|
+
openPlayer() {
|
|
231
|
+
this.multiPlayer.open();
|
|
232
|
+
},
|
|
233
|
+
changeMode(mode) {
|
|
234
|
+
this.targetMode = mode;
|
|
235
|
+
},
|
|
236
|
+
changeWordCloudSpacing(num) {
|
|
237
|
+
this.replayConfig.wordCloudSettings.spacing += num;
|
|
238
|
+
},
|
|
239
|
+
changeLocale(locale) {
|
|
240
|
+
this.$i18n.locale = locale;
|
|
241
|
+
this.$forceUpdate();
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
</script>
|
|
246
|
+
|
|
247
|
+
<style lang="scss" scoped>
|
|
248
|
+
.demo {
|
|
249
|
+
width: 100%;
|
|
250
|
+
height: 100%;
|
|
251
|
+
|
|
252
|
+
.mvp-multi-player-container {
|
|
253
|
+
display: flex;
|
|
254
|
+
height: 600px;
|
|
255
|
+
|
|
256
|
+
.mvp-multi-player {
|
|
257
|
+
width: 1160px;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.mvp-multi-player-log {
|
|
261
|
+
margin-left: 20px;
|
|
262
|
+
width: 500px;
|
|
263
|
+
border: 1px solid #00bbbd;
|
|
264
|
+
display: flex;
|
|
265
|
+
|
|
266
|
+
.video-log {
|
|
267
|
+
border: 1px solid #00bbbd;
|
|
268
|
+
flex-grow: 1;
|
|
269
|
+
flex-shrink: 1;
|
|
270
|
+
display: flex;
|
|
271
|
+
flex-direction: column;
|
|
272
|
+
|
|
273
|
+
.video-title {
|
|
274
|
+
height: 40px;
|
|
275
|
+
font-size: 14px;
|
|
276
|
+
font-weight: bold;
|
|
277
|
+
border-bottom: 2px solid #00bbbd;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.log-content {
|
|
281
|
+
flex-grow: 1;
|
|
282
|
+
flex-shrink: 1;
|
|
283
|
+
overflow-y: auto;
|
|
284
|
+
white-space: pre;
|
|
285
|
+
display: flex;
|
|
286
|
+
|
|
287
|
+
.log {
|
|
288
|
+
flex: 1;
|
|
289
|
+
display: flex;
|
|
290
|
+
flex-direction: column;
|
|
291
|
+
border: 1px solid #00bbbd;
|
|
292
|
+
|
|
293
|
+
.log-view {
|
|
294
|
+
border-top: 2px solid grey;
|
|
295
|
+
height: 100%;
|
|
296
|
+
font-weight: bold;
|
|
297
|
+
overflow-y: auto;
|
|
298
|
+
|
|
299
|
+
.single-log-view {
|
|
300
|
+
border: 1px solid seagreen;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.mvp-i18n-test {
|
|
310
|
+
display: flex;
|
|
311
|
+
margin-top: 10px;
|
|
312
|
+
height: 40px;
|
|
313
|
+
|
|
314
|
+
.i18n-message {
|
|
315
|
+
margin-left: 20px;
|
|
316
|
+
display: flex;
|
|
317
|
+
align-items: center;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
.mvp-word-cloud-test {
|
|
322
|
+
display: flex;
|
|
323
|
+
flex-direction: column;
|
|
324
|
+
justify-content: space-between;
|
|
325
|
+
height: 70px;
|
|
326
|
+
margin-top: 10px;
|
|
327
|
+
|
|
328
|
+
.mvp-word-cloud-setting {
|
|
329
|
+
display: flex;
|
|
330
|
+
align-items: center;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.button {
|
|
335
|
+
border: 1px solid #00bbbd;
|
|
336
|
+
margin-left: 20px;
|
|
337
|
+
padding: 5px 20px;
|
|
338
|
+
cursor: pointer;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
</style>
|