@srgssr/pillarbox-web 1.32.0 → 1.32.1
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/README.md +2 -0
- package/dist/pillarbox-core.cjs +146 -1
- package/dist/pillarbox-core.cjs.map +1 -1
- package/dist/pillarbox-core.es.js +146 -1
- package/dist/pillarbox-core.es.js.map +1 -1
- package/dist/pillarbox.cjs +146 -1
- package/dist/pillarbox.cjs.map +1 -1
- package/dist/pillarbox.es.js +146 -1
- package/dist/pillarbox.es.js.map +1 -1
- package/dist/pillarbox.min.css +1 -1
- package/dist/pillarbox.min.css.map +1 -1
- package/dist/pillarbox.umd.js +160 -15
- package/dist/pillarbox.umd.js.map +1 -1
- package/dist/pillarbox.umd.min.js +7 -7
- package/dist/pillarbox.umd.min.js.map +1 -1
- package/dist/types/src/components/audio-track-menu-item.d.ts +2 -0
- package/dist/types/src/components/audio-track-menu-item.d.ts.map +1 -0
- package/dist/types/src/pillarbox.d.ts.map +1 -1
- package/package.json +1 -1
- package/scss/components/_audio.scss +8 -0
- package/scss/pillarbox.scss +1 -0
package/dist/pillarbox.es.js
CHANGED
|
@@ -90,7 +90,7 @@ function _toPropertyKey(t) {
|
|
|
90
90
|
return "symbol" == typeof i ? i : i + "";
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
const version = "1.
|
|
93
|
+
const version = "1.32.0";
|
|
94
94
|
|
|
95
95
|
/** @import VJSPlayer from 'video.js/dist/types/player' */
|
|
96
96
|
/** @import AudioTrack from 'video.js/dist/types/tracks/audio-track' */
|
|
@@ -306,6 +306,151 @@ class Player extends vjsPlayer {
|
|
|
306
306
|
}
|
|
307
307
|
videojs.registerComponent('player', Player);
|
|
308
308
|
|
|
309
|
+
/** @import MenuItem from 'video.js/dist/types/menu/menu-item' */
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* @ignore
|
|
313
|
+
*/
|
|
314
|
+
const VJSAudioTrackButton = videojs.getComponent('AudioTrackButton');
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* @ignore
|
|
318
|
+
* @type {typeof MenuItem}
|
|
319
|
+
*/
|
|
320
|
+
const MenuItem = videojs.getComponent('MenuItem');
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* An {@link AudioTrack} {@link MenuItem}
|
|
324
|
+
*
|
|
325
|
+
* This is a temporary workaround.
|
|
326
|
+
*
|
|
327
|
+
* @extends MenuItem
|
|
328
|
+
*/
|
|
329
|
+
class AudioTrackMenuItem extends MenuItem {
|
|
330
|
+
/**
|
|
331
|
+
* Creates an instance of this class.
|
|
332
|
+
*
|
|
333
|
+
* @param {Player} player
|
|
334
|
+
* The `Player` that this class should be attached to.
|
|
335
|
+
*
|
|
336
|
+
* @param {Object} [options]
|
|
337
|
+
* The key/value store of player options.
|
|
338
|
+
*/
|
|
339
|
+
constructor(player, options) {
|
|
340
|
+
const track = options.track;
|
|
341
|
+
const tracks = player.audioTracks();
|
|
342
|
+
|
|
343
|
+
// Modify options for parent MenuItem class's init.
|
|
344
|
+
options.label = track.label || track.language || 'Unknown';
|
|
345
|
+
options.selected = track.enabled;
|
|
346
|
+
super(player, options);
|
|
347
|
+
this.track = track;
|
|
348
|
+
this.addClass(`vjs-${track.kind}-menu-item`);
|
|
349
|
+
const changeHandler = (...args) => {
|
|
350
|
+
this.handleTracksChange.apply(this, args);
|
|
351
|
+
};
|
|
352
|
+
tracks.addEventListener('change', changeHandler);
|
|
353
|
+
this.on('dispose', () => {
|
|
354
|
+
tracks.removeEventListener('change', changeHandler);
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
createEl(type, props, attrs) {
|
|
358
|
+
const el = super.createEl(type, props, attrs);
|
|
359
|
+
const parentSpan = el.querySelector('.vjs-menu-item-text');
|
|
360
|
+
if (['main-desc', 'descriptions', 'description'].indexOf(this.options_.track.kind) >= 0) {
|
|
361
|
+
parentSpan.appendChild(videojs.dom.createEl('span', {
|
|
362
|
+
className: 'vjs-icon-placeholder'
|
|
363
|
+
}, {
|
|
364
|
+
'aria-hidden': true
|
|
365
|
+
}));
|
|
366
|
+
parentSpan.appendChild(videojs.dom.createEl('span', {
|
|
367
|
+
className: 'vjs-control-text',
|
|
368
|
+
textContent: ' ' + this.localize('Descriptions')
|
|
369
|
+
}));
|
|
370
|
+
}
|
|
371
|
+
return el;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* This gets called when an `AudioTrackMenuItem is "clicked". See {@link ClickableComponent}
|
|
376
|
+
* for more detailed information on what a click can be.
|
|
377
|
+
*
|
|
378
|
+
* @param {Event} [event]
|
|
379
|
+
* The `keydown`, `tap`, or `click` event that caused this function to be
|
|
380
|
+
* called.
|
|
381
|
+
*
|
|
382
|
+
* @listens tap
|
|
383
|
+
* @listens click
|
|
384
|
+
*/
|
|
385
|
+
handleClick(event) {
|
|
386
|
+
super.handleClick(event);
|
|
387
|
+
|
|
388
|
+
// the audio track list will automatically toggle other tracks
|
|
389
|
+
// off for us.
|
|
390
|
+
this.track.enabled = true;
|
|
391
|
+
if (!this.player_.tech_.featuresNativeAudioTracks) return;
|
|
392
|
+
|
|
393
|
+
// when native audio tracks are used, we want to make sure that other tracks are turned off
|
|
394
|
+
const tracks = this.player_.audioTracks();
|
|
395
|
+
for (let i = 0; i < tracks.length; i++) {
|
|
396
|
+
const track = tracks[i];
|
|
397
|
+
|
|
398
|
+
// skip the current track since we enabled it above
|
|
399
|
+
if (track === this.track) {
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
402
|
+
track.enabled = track === this.track;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Handle any {@link AudioTrack} change.
|
|
408
|
+
*
|
|
409
|
+
* @param {Event} [event]
|
|
410
|
+
* The {@link AudioTrackList#change} event that caused this to run.
|
|
411
|
+
*
|
|
412
|
+
* @listens AudioTrackList#change
|
|
413
|
+
*/
|
|
414
|
+
handleTracksChange() {
|
|
415
|
+
this.selected(this.track.enabled);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* The base class for buttons that toggle specific {@link AudioTrack} types.
|
|
421
|
+
*
|
|
422
|
+
* @extends VJSAudioTrackButton
|
|
423
|
+
*/
|
|
424
|
+
class AudioTrackButton extends VJSAudioTrackButton {
|
|
425
|
+
/**
|
|
426
|
+
* Create a menu item for each audio track
|
|
427
|
+
*
|
|
428
|
+
* @param {AudioTrackMenuItem[]} [items=[]]
|
|
429
|
+
* An array of existing menu items to use.
|
|
430
|
+
*
|
|
431
|
+
* @return {AudioTrackMenuItem[]}
|
|
432
|
+
* An array of menu items
|
|
433
|
+
*/
|
|
434
|
+
createItems(items = []) {
|
|
435
|
+
// if there's only one audio track, there no point in showing it
|
|
436
|
+
this.hideThreshold_ = 1;
|
|
437
|
+
const tracks = this.player_.audioTracks();
|
|
438
|
+
for (let i = 0; i < tracks.length; i++) {
|
|
439
|
+
const track = tracks[i];
|
|
440
|
+
items.push(new AudioTrackMenuItem(this.player_, {
|
|
441
|
+
track,
|
|
442
|
+
// MenuItem is selectable
|
|
443
|
+
selectable: true,
|
|
444
|
+
// MenuItem is NOT multiSelectable (i.e. only one can be marked "selected" at a time)
|
|
445
|
+
multiSelectable: false
|
|
446
|
+
}));
|
|
447
|
+
}
|
|
448
|
+
return items;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
videojs.registerComponent('AudioTrackMenuItem', AudioTrackMenuItem);
|
|
452
|
+
videojs.registerComponent('AudioTrackButton', AudioTrackButton);
|
|
453
|
+
|
|
309
454
|
/**
|
|
310
455
|
* Pillarbox is an alias for the video.js namespace with additional options.
|
|
311
456
|
*
|