|
225 | 225 | representationsEl.selectedIndex = selectedIndex; |
226 | 226 | }; |
227 | 227 |
|
228 | | - ['debug', 'autoplay', 'muted', 'minified', 'sync-workers', 'liveui', 'partial', 'url', 'type', 'keysystems', 'buffer-water', 'override-native', 'preload'].forEach(function(name) { |
| 228 | + [ |
| 229 | + 'debug', |
| 230 | + 'autoplay', |
| 231 | + 'muted', |
| 232 | + 'minified', |
| 233 | + 'sync-workers', |
| 234 | + 'liveui', |
| 235 | + 'partial', |
| 236 | + 'url', |
| 237 | + 'type', |
| 238 | + 'keysystems', |
| 239 | + 'buffer-water', |
| 240 | + 'override-native', |
| 241 | + 'preload', |
| 242 | + 'mirror-source' |
| 243 | + ].forEach(function(name) { |
229 | 244 | stateEls[name] = document.getElementById(name); |
230 | 245 | }); |
231 | 246 |
|
|
252 | 267 | window.player.autoplay(event.target.checked); |
253 | 268 | }); |
254 | 269 |
|
| 270 | + stateEls['mirror-source'].addEventListener('change', function(event) { |
| 271 | + saveState(); |
| 272 | + |
| 273 | + // reload the player and scripts |
| 274 | + stateEls.minified.dispatchEvent(newEvent('change')); |
| 275 | + }); |
| 276 | + |
255 | 277 | stateEls['sync-workers'].addEventListener('change', function(event) { |
256 | 278 | saveState(); |
257 | 279 |
|
|
333 | 355 | videoEl.className = 'vjs-default-skin'; |
334 | 356 | fixture.appendChild(videoEl); |
335 | 357 |
|
| 358 | + const mirrorSource = getInputValue(stateEls['mirror-source']); |
| 359 | + |
336 | 360 | player = window.player = window.videojs(videoEl, { |
337 | 361 | plugins: { |
338 | 362 | httpSourceSelector: { |
339 | 363 | default: 'auto' |
340 | 364 | } |
341 | 365 | }, |
342 | 366 | liveui: stateEls.liveui.checked, |
| 367 | + enableSourceset: mirrorSource, |
343 | 368 | html5: { |
344 | 369 | vhs: { |
345 | 370 | overrideNative: getInputValue(stateEls['override-native']), |
|
349 | 374 | } |
350 | 375 | }); |
351 | 376 |
|
| 377 | + player.on('sourceset', function() { |
| 378 | + const source = player.currentSource(); |
| 379 | + |
| 380 | + if (source.keySystems) { |
| 381 | + const copy = JSON.parse(JSON.stringify(source.keySystems)); |
| 382 | + |
| 383 | + // have to delete pssh as it will often make keySystems too big |
| 384 | + // for a uri |
| 385 | + Object.keys(copy).forEach(function(key) { |
| 386 | + if (copy[key].hasOwnProperty('pssh')) { |
| 387 | + delete copy[key].pssh; |
| 388 | + } |
| 389 | + }); |
| 390 | + |
| 391 | + stateEls.keysystems.value = JSON.stringify(copy, null, 2); |
| 392 | + } |
| 393 | + |
| 394 | + if (source.src) { |
| 395 | + stateEls.url.value = source.src; |
| 396 | + } |
| 397 | + |
| 398 | + if (source.type) { |
| 399 | + stateEls.type.value = source.type; |
| 400 | + } |
| 401 | + |
| 402 | + saveState(); |
| 403 | + }); |
| 404 | + |
352 | 405 | player.width(640); |
353 | 406 | player.height(264); |
354 | 407 |
|
|
0 commit comments