@mattebox/player 0.1.0 → 0.3.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/README.md +4 -3
- package/dist/cdn/mattebox-player.min.js +222 -198
- package/dist/compose.d.ts +5 -0
- package/dist/compose.d.ts.map +1 -0
- package/dist/compose.js +31 -0
- package/dist/compose.js.map +1 -0
- package/dist/controls/chapters.d.ts +29 -0
- package/dist/controls/chapters.d.ts.map +1 -0
- package/dist/controls/chapters.js +81 -0
- package/dist/controls/chapters.js.map +1 -0
- package/dist/controls/cues.d.ts +8 -3
- package/dist/controls/cues.d.ts.map +1 -1
- package/dist/controls/cues.js +44 -10
- package/dist/controls/cues.js.map +1 -1
- package/dist/controls/fullscreen.d.ts +9 -9
- package/dist/controls/fullscreen.d.ts.map +1 -1
- package/dist/controls/fullscreen.js +17 -21
- package/dist/controls/fullscreen.js.map +1 -1
- package/dist/controls/icons.d.ts +1 -3
- package/dist/controls/icons.d.ts.map +1 -1
- package/dist/controls/icons.js +3 -6
- package/dist/controls/icons.js.map +1 -1
- package/dist/controls/menu.d.ts +14 -11
- package/dist/controls/menu.d.ts.map +1 -1
- package/dist/controls/menu.js +39 -34
- package/dist/controls/menu.js.map +1 -1
- package/dist/controls/session.d.ts +27 -0
- package/dist/controls/session.d.ts.map +1 -0
- package/dist/controls/session.js +36 -0
- package/dist/controls/session.js.map +1 -0
- package/dist/controls/slider.d.ts +6 -6
- package/dist/controls/slider.d.ts.map +1 -1
- package/dist/controls/slider.js +18 -13
- package/dist/controls/slider.js.map +1 -1
- package/dist/dom.d.ts +4 -10
- package/dist/dom.d.ts.map +1 -1
- package/dist/dom.js +4 -24
- package/dist/dom.js.map +1 -1
- package/dist/element-entry.d.ts +4 -0
- package/dist/element-entry.d.ts.map +1 -0
- package/dist/element-entry.js +9 -0
- package/dist/element-entry.js.map +1 -0
- package/dist/element.d.ts +54 -14
- package/dist/element.d.ts.map +1 -1
- package/dist/element.js +154 -73
- package/dist/element.js.map +1 -1
- package/dist/elements/audio-menu.d.ts +24 -0
- package/dist/elements/audio-menu.d.ts.map +1 -0
- package/dist/elements/audio-menu.js +70 -0
- package/dist/elements/audio-menu.js.map +1 -0
- package/dist/elements/chapters-menu.d.ts +12 -0
- package/dist/elements/chapters-menu.d.ts.map +1 -0
- package/dist/elements/chapters-menu.js +67 -0
- package/dist/elements/chapters-menu.js.map +1 -0
- package/dist/elements/component.d.ts +45 -0
- package/dist/elements/component.d.ts.map +1 -0
- package/dist/elements/component.js +90 -0
- package/dist/elements/component.js.map +1 -0
- package/dist/elements/control-bar.d.ts +75 -0
- package/dist/elements/control-bar.d.ts.map +1 -0
- package/dist/elements/control-bar.js +339 -0
- package/dist/elements/control-bar.js.map +1 -0
- package/dist/elements/current-time.d.ts +5 -0
- package/dist/elements/current-time.d.ts.map +1 -0
- package/dist/elements/current-time.js +27 -0
- package/dist/elements/current-time.js.map +1 -0
- package/dist/elements/drm-badge.d.ts +29 -0
- package/dist/elements/drm-badge.d.ts.map +1 -0
- package/dist/elements/drm-badge.js +145 -0
- package/dist/elements/drm-badge.js.map +1 -0
- package/dist/elements/duration.d.ts +6 -0
- package/dist/elements/duration.d.ts.map +1 -0
- package/dist/elements/duration.js +23 -0
- package/dist/elements/duration.js.map +1 -0
- package/dist/elements/error-screen.d.ts +17 -0
- package/dist/elements/error-screen.d.ts.map +1 -0
- package/dist/elements/error-screen.js +103 -0
- package/dist/elements/error-screen.js.map +1 -0
- package/dist/elements/fullscreen-button.d.ts +19 -0
- package/dist/elements/fullscreen-button.d.ts.map +1 -0
- package/dist/elements/fullscreen-button.js +55 -0
- package/dist/elements/fullscreen-button.js.map +1 -0
- package/dist/elements/live-button.d.ts +12 -0
- package/dist/elements/live-button.d.ts.map +1 -0
- package/dist/elements/live-button.js +96 -0
- package/dist/elements/live-button.js.map +1 -0
- package/dist/elements/menu-element.d.ts +22 -0
- package/dist/elements/menu-element.d.ts.map +1 -0
- package/dist/elements/menu-element.js +31 -0
- package/dist/elements/menu-element.js.map +1 -0
- package/dist/elements/mute-button.d.ts +12 -0
- package/dist/elements/mute-button.d.ts.map +1 -0
- package/dist/elements/mute-button.js +61 -0
- package/dist/elements/mute-button.js.map +1 -0
- package/dist/elements/panels.d.ts +15 -0
- package/dist/elements/panels.d.ts.map +1 -0
- package/dist/elements/panels.js +55 -0
- package/dist/elements/panels.js.map +1 -0
- package/dist/elements/pip-button.d.ts +13 -0
- package/dist/elements/pip-button.d.ts.map +1 -0
- package/dist/elements/pip-button.js +56 -0
- package/dist/elements/pip-button.js.map +1 -0
- package/dist/elements/play-button.d.ts +12 -0
- package/dist/elements/play-button.d.ts.map +1 -0
- package/dist/elements/play-button.js +60 -0
- package/dist/elements/play-button.js.map +1 -0
- package/dist/elements/quality-menu.d.ts +11 -0
- package/dist/elements/quality-menu.d.ts.map +1 -0
- package/dist/elements/quality-menu.js +72 -0
- package/dist/elements/quality-menu.js.map +1 -0
- package/dist/elements/remaining-time.d.ts +6 -0
- package/dist/elements/remaining-time.d.ts.map +1 -0
- package/dist/elements/remaining-time.js +26 -0
- package/dist/elements/remaining-time.js.map +1 -0
- package/dist/elements/seek-bar.d.ts +83 -0
- package/dist/elements/seek-bar.d.ts.map +1 -0
- package/dist/elements/seek-bar.js +352 -0
- package/dist/elements/seek-bar.js.map +1 -0
- package/dist/elements/shared.d.ts +27 -0
- package/dist/elements/shared.d.ts.map +1 -0
- package/dist/elements/shared.js +155 -0
- package/dist/elements/shared.js.map +1 -0
- package/dist/elements/skip-button.d.ts +14 -0
- package/dist/elements/skip-button.d.ts.map +1 -0
- package/dist/elements/skip-button.js +60 -0
- package/dist/elements/skip-button.js.map +1 -0
- package/dist/elements/spacer.d.ts +4 -0
- package/dist/elements/spacer.d.ts.map +1 -0
- package/dist/elements/spacer.js +9 -0
- package/dist/elements/spacer.js.map +1 -0
- package/dist/elements/speed-menu.d.ts +18 -0
- package/dist/elements/speed-menu.d.ts.map +1 -0
- package/dist/elements/speed-menu.js +56 -0
- package/dist/elements/speed-menu.js.map +1 -0
- package/dist/elements/start-button.d.ts +23 -0
- package/dist/elements/start-button.d.ts.map +1 -0
- package/dist/elements/start-button.js +120 -0
- package/dist/elements/start-button.js.map +1 -0
- package/dist/elements/subtitles-menu.d.ts +17 -0
- package/dist/elements/subtitles-menu.d.ts.map +1 -0
- package/dist/elements/subtitles-menu.js +108 -0
- package/dist/elements/subtitles-menu.js.map +1 -0
- package/dist/elements/time-element.d.ts +14 -0
- package/dist/elements/time-element.d.ts.map +1 -0
- package/dist/elements/time-element.js +29 -0
- package/dist/elements/time-element.js.map +1 -0
- package/dist/elements/volume-slider.d.ts +10 -0
- package/dist/elements/volume-slider.d.ts.map +1 -0
- package/dist/elements/volume-slider.js +46 -0
- package/dist/elements/volume-slider.js.map +1 -0
- package/dist/elements/volume.d.ts +9 -0
- package/dist/elements/volume.d.ts.map +1 -0
- package/dist/elements/volume.js +52 -0
- package/dist/elements/volume.js.map +1 -0
- package/dist/entries/audio-menu.d.ts +5 -0
- package/dist/entries/audio-menu.d.ts.map +1 -0
- package/dist/entries/audio-menu.js +8 -0
- package/dist/entries/audio-menu.js.map +1 -0
- package/dist/entries/chapters-menu.d.ts +5 -0
- package/dist/entries/chapters-menu.d.ts.map +1 -0
- package/dist/entries/chapters-menu.js +9 -0
- package/dist/entries/chapters-menu.js.map +1 -0
- package/dist/entries/control-bar.d.ts +5 -0
- package/dist/entries/control-bar.d.ts.map +1 -0
- package/dist/entries/control-bar.js +8 -0
- package/dist/entries/control-bar.js.map +1 -0
- package/dist/entries/current-time.d.ts +5 -0
- package/dist/entries/current-time.d.ts.map +1 -0
- package/dist/entries/current-time.js +8 -0
- package/dist/entries/current-time.js.map +1 -0
- package/dist/entries/drm-badge.d.ts +5 -0
- package/dist/entries/drm-badge.d.ts.map +1 -0
- package/dist/entries/drm-badge.js +8 -0
- package/dist/entries/drm-badge.js.map +1 -0
- package/dist/entries/duration.d.ts +5 -0
- package/dist/entries/duration.d.ts.map +1 -0
- package/dist/entries/duration.js +8 -0
- package/dist/entries/duration.js.map +1 -0
- package/dist/entries/error-screen.d.ts +5 -0
- package/dist/entries/error-screen.d.ts.map +1 -0
- package/dist/entries/error-screen.js +8 -0
- package/dist/entries/error-screen.js.map +1 -0
- package/dist/entries/fullscreen-button.d.ts +5 -0
- package/dist/entries/fullscreen-button.d.ts.map +1 -0
- package/dist/entries/fullscreen-button.js +8 -0
- package/dist/entries/fullscreen-button.js.map +1 -0
- package/dist/entries/live-button.d.ts +5 -0
- package/dist/entries/live-button.d.ts.map +1 -0
- package/dist/entries/live-button.js +8 -0
- package/dist/entries/live-button.js.map +1 -0
- package/dist/entries/mute-button.d.ts +5 -0
- package/dist/entries/mute-button.d.ts.map +1 -0
- package/dist/entries/mute-button.js +8 -0
- package/dist/entries/mute-button.js.map +1 -0
- package/dist/entries/panels.d.ts +5 -0
- package/dist/entries/panels.d.ts.map +1 -0
- package/dist/entries/panels.js +8 -0
- package/dist/entries/panels.js.map +1 -0
- package/dist/entries/pip-button.d.ts +5 -0
- package/dist/entries/pip-button.d.ts.map +1 -0
- package/dist/entries/pip-button.js +8 -0
- package/dist/entries/pip-button.js.map +1 -0
- package/dist/entries/play-button.d.ts +5 -0
- package/dist/entries/play-button.d.ts.map +1 -0
- package/dist/entries/play-button.js +8 -0
- package/dist/entries/play-button.js.map +1 -0
- package/dist/entries/quality-menu.d.ts +5 -0
- package/dist/entries/quality-menu.d.ts.map +1 -0
- package/dist/entries/quality-menu.js +8 -0
- package/dist/entries/quality-menu.js.map +1 -0
- package/dist/entries/remaining-time.d.ts +5 -0
- package/dist/entries/remaining-time.d.ts.map +1 -0
- package/dist/entries/remaining-time.js +9 -0
- package/dist/entries/remaining-time.js.map +1 -0
- package/dist/entries/seek-bar.d.ts +5 -0
- package/dist/entries/seek-bar.d.ts.map +1 -0
- package/dist/entries/seek-bar.js +8 -0
- package/dist/entries/seek-bar.js.map +1 -0
- package/dist/entries/skip-button.d.ts +5 -0
- package/dist/entries/skip-button.d.ts.map +1 -0
- package/dist/entries/skip-button.js +8 -0
- package/dist/entries/skip-button.js.map +1 -0
- package/dist/entries/spacer.d.ts +5 -0
- package/dist/entries/spacer.d.ts.map +1 -0
- package/dist/entries/spacer.js +8 -0
- package/dist/entries/spacer.js.map +1 -0
- package/dist/entries/speed-menu.d.ts +5 -0
- package/dist/entries/speed-menu.d.ts.map +1 -0
- package/dist/entries/speed-menu.js +8 -0
- package/dist/entries/speed-menu.js.map +1 -0
- package/dist/entries/start-button.d.ts +5 -0
- package/dist/entries/start-button.d.ts.map +1 -0
- package/dist/entries/start-button.js +8 -0
- package/dist/entries/start-button.js.map +1 -0
- package/dist/entries/subtitles-menu.d.ts +5 -0
- package/dist/entries/subtitles-menu.d.ts.map +1 -0
- package/dist/entries/subtitles-menu.js +8 -0
- package/dist/entries/subtitles-menu.js.map +1 -0
- package/dist/entries/volume-slider.d.ts +5 -0
- package/dist/entries/volume-slider.d.ts.map +1 -0
- package/dist/entries/volume-slider.js +8 -0
- package/dist/entries/volume-slider.js.map +1 -0
- package/dist/entries/volume.d.ts +7 -0
- package/dist/entries/volume.d.ts.map +1 -0
- package/dist/entries/volume.js +10 -0
- package/dist/entries/volume.js.map +1 -0
- package/dist/es2015/compose.js +33 -0
- package/dist/es2015/controls/chapters.js +61 -0
- package/dist/es2015/controls/cues.js +39 -11
- package/dist/es2015/controls/fullscreen.js +25 -23
- package/dist/es2015/controls/icons.js +5 -9
- package/dist/es2015/controls/menu.js +39 -35
- package/dist/es2015/controls/session.js +40 -0
- package/dist/es2015/controls/slider.js +18 -13
- package/dist/es2015/controls/time.js +1 -5
- package/dist/es2015/dom.js +5 -25
- package/dist/es2015/element-entry.js +10 -0
- package/dist/es2015/element.js +118 -65
- package/dist/es2015/elements/audio-menu.js +68 -0
- package/dist/es2015/elements/chapters-menu.js +68 -0
- package/dist/es2015/elements/component.js +85 -0
- package/dist/es2015/elements/control-bar.js +299 -0
- package/dist/es2015/elements/current-time.js +27 -0
- package/dist/es2015/elements/drm-badge.js +138 -0
- package/dist/es2015/elements/duration.js +23 -0
- package/dist/es2015/elements/error-screen.js +97 -0
- package/dist/es2015/elements/fullscreen-button.js +49 -0
- package/dist/es2015/elements/live-button.js +97 -0
- package/dist/es2015/elements/menu-element.js +39 -0
- package/dist/es2015/elements/mute-button.js +60 -0
- package/dist/es2015/elements/panels.js +52 -0
- package/dist/es2015/elements/pip-button.js +56 -0
- package/dist/es2015/elements/play-button.js +68 -0
- package/dist/es2015/elements/quality-menu.js +68 -0
- package/dist/es2015/elements/remaining-time.js +26 -0
- package/dist/es2015/elements/seek-bar.js +314 -0
- package/dist/es2015/elements/shared.js +155 -0
- package/dist/es2015/elements/skip-button.js +59 -0
- package/dist/es2015/elements/spacer.js +11 -0
- package/dist/es2015/elements/speed-menu.js +60 -0
- package/dist/es2015/elements/start-button.js +124 -0
- package/dist/es2015/elements/subtitles-menu.js +103 -0
- package/dist/es2015/elements/time-element.js +38 -0
- package/dist/es2015/elements/volume-slider.js +47 -0
- package/dist/es2015/elements/volume.js +52 -0
- package/dist/es2015/entries/audio-menu.js +7 -0
- package/dist/es2015/entries/chapters-menu.js +7 -0
- package/dist/es2015/entries/control-bar.js +7 -0
- package/dist/es2015/entries/current-time.js +7 -0
- package/dist/es2015/entries/drm-badge.js +7 -0
- package/dist/es2015/entries/duration.js +7 -0
- package/dist/es2015/entries/error-screen.js +7 -0
- package/dist/es2015/entries/fullscreen-button.js +7 -0
- package/dist/es2015/entries/live-button.js +7 -0
- package/dist/es2015/entries/mute-button.js +7 -0
- package/dist/es2015/entries/panels.js +7 -0
- package/dist/es2015/entries/pip-button.js +7 -0
- package/dist/es2015/entries/play-button.js +7 -0
- package/dist/es2015/entries/quality-menu.js +7 -0
- package/dist/es2015/entries/remaining-time.js +7 -0
- package/dist/es2015/entries/seek-bar.js +7 -0
- package/dist/es2015/entries/skip-button.js +7 -0
- package/dist/es2015/entries/spacer.js +7 -0
- package/dist/es2015/entries/speed-menu.js +7 -0
- package/dist/es2015/entries/start-button.js +7 -0
- package/dist/es2015/entries/subtitles-menu.js +7 -0
- package/dist/es2015/entries/volume-slider.js +7 -0
- package/dist/es2015/entries/volume.js +9 -0
- package/dist/es2015/host.js +23 -0
- package/dist/es2015/index.js +48 -9
- package/dist/es2015/labels.js +14 -0
- package/dist/es2015/style.js +40 -292
- package/dist/es2015/{panels/error.js → surface.js} +3 -3
- package/dist/es2015/tags.js +28 -0
- package/dist/host.d.ts +26 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +23 -0
- package/dist/host.js.map +1 -0
- package/dist/index.d.ts +84 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -8
- package/dist/index.js.map +1 -1
- package/dist/labels.d.ts +7 -0
- package/dist/labels.d.ts.map +1 -0
- package/dist/labels.js +12 -0
- package/dist/labels.js.map +1 -0
- package/dist/style.d.ts +10 -2
- package/dist/style.d.ts.map +1 -1
- package/dist/style.js +40 -292
- package/dist/style.js.map +1 -1
- package/dist/surface.d.ts +15 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/{panels/error.js → surface.js} +3 -3
- package/dist/surface.js.map +1 -0
- package/dist/tags.d.ts +26 -0
- package/dist/tags.d.ts.map +1 -0
- package/dist/tags.js +26 -0
- package/dist/tags.js.map +1 -0
- package/package.json +22 -2
- package/dist/controls/bar.d.ts +0 -56
- package/dist/controls/bar.d.ts.map +0 -1
- package/dist/controls/bar.js +0 -245
- package/dist/controls/bar.js.map +0 -1
- package/dist/controls/buttons.d.ts +0 -13
- package/dist/controls/buttons.d.ts.map +0 -1
- package/dist/controls/buttons.js +0 -157
- package/dist/controls/buttons.js.map +0 -1
- package/dist/controls/control.d.ts +0 -12
- package/dist/controls/control.d.ts.map +0 -1
- package/dist/controls/control.js +0 -2
- package/dist/controls/control.js.map +0 -1
- package/dist/controls/keys.d.ts +0 -26
- package/dist/controls/keys.d.ts.map +0 -1
- package/dist/controls/keys.js +0 -66
- package/dist/controls/keys.js.map +0 -1
- package/dist/controls/live.d.ts +0 -10
- package/dist/controls/live.d.ts.map +0 -1
- package/dist/controls/live.js +0 -59
- package/dist/controls/live.js.map +0 -1
- package/dist/controls/menus.d.ts +0 -43
- package/dist/controls/menus.d.ts.map +0 -1
- package/dist/controls/menus.js +0 -262
- package/dist/controls/menus.js.map +0 -1
- package/dist/controls/options.d.ts +0 -44
- package/dist/controls/options.d.ts.map +0 -1
- package/dist/controls/options.js +0 -54
- package/dist/controls/options.js.map +0 -1
- package/dist/controls/screens.d.ts +0 -22
- package/dist/controls/screens.d.ts.map +0 -1
- package/dist/controls/screens.js +0 -69
- package/dist/controls/screens.js.map +0 -1
- package/dist/controls/seek.d.ts +0 -52
- package/dist/controls/seek.d.ts.map +0 -1
- package/dist/controls/seek.js +0 -215
- package/dist/controls/seek.js.map +0 -1
- package/dist/controls/speed.d.ts +0 -8
- package/dist/controls/speed.d.ts.map +0 -1
- package/dist/controls/speed.js +0 -34
- package/dist/controls/speed.js.map +0 -1
- package/dist/controls/volume.d.ts +0 -8
- package/dist/controls/volume.d.ts.map +0 -1
- package/dist/controls/volume.js +0 -29
- package/dist/controls/volume.js.map +0 -1
- package/dist/es2015/controls/bar.js +0 -227
- package/dist/es2015/controls/buttons.js +0 -146
- package/dist/es2015/controls/keys.js +0 -60
- package/dist/es2015/controls/live.js +0 -60
- package/dist/es2015/controls/menus.js +0 -258
- package/dist/es2015/controls/options.js +0 -46
- package/dist/es2015/controls/screens.js +0 -74
- package/dist/es2015/controls/seek.js +0 -203
- package/dist/es2015/controls/speed.js +0 -41
- package/dist/es2015/controls/volume.js +0 -30
- package/dist/es2015/panels/drm.js +0 -29
- package/dist/es2015/panels/live.js +0 -48
- package/dist/es2015/panels/quality.js +0 -52
- package/dist/es2015/panels/tracks.js +0 -47
- package/dist/panels/drm.d.ts +0 -8
- package/dist/panels/drm.d.ts.map +0 -1
- package/dist/panels/drm.js +0 -36
- package/dist/panels/drm.js.map +0 -1
- package/dist/panels/error.d.ts +0 -13
- package/dist/panels/error.d.ts.map +0 -1
- package/dist/panels/error.js.map +0 -1
- package/dist/panels/live.d.ts +0 -3
- package/dist/panels/live.d.ts.map +0 -1
- package/dist/panels/live.js +0 -56
- package/dist/panels/live.js.map +0 -1
- package/dist/panels/panel.d.ts +0 -13
- package/dist/panels/panel.d.ts.map +0 -1
- package/dist/panels/panel.js +0 -2
- package/dist/panels/panel.js.map +0 -1
- package/dist/panels/quality.d.ts +0 -3
- package/dist/panels/quality.d.ts.map +0 -1
- package/dist/panels/quality.js +0 -59
- package/dist/panels/quality.js.map +0 -1
- package/dist/panels/tracks.d.ts +0 -3
- package/dist/panels/tracks.d.ts.map +0 -1
- package/dist/panels/tracks.js +0 -49
- package/dist/panels/tracks.js.map +0 -1
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { AUDIO_MENU, CHAPTERS_MENU, DRM_BADGE, MUTE_BUTTON, PIP_BUTTON, QUALITY_MENU, SKIP_BUTTON, SPEED_MENU, SUBTITLES_MENU, VOLUME, VOLUME_SLIDER } from "../tags.js";
|
|
2
|
+
import { Component } from "./component.js";
|
|
3
|
+
import { number, style } from "./shared.js";
|
|
4
|
+
import { cueLift, cueStyle } from "../controls/cues.js";
|
|
5
|
+
import { fullscreen } from "../controls/fullscreen.js";
|
|
6
|
+
//#region src/elements/control-bar.ts
|
|
7
|
+
const IDLE_MS = 3e3;
|
|
8
|
+
const SEEK_STEP = 5;
|
|
9
|
+
/**
|
|
10
|
+
* What goes first when the row is too narrow, by tag: the slider, which
|
|
11
|
+
* takes the most room for the least; then the diagnostics, the lock and
|
|
12
|
+
* the menus a viewer rarely opens; then the menus for the picture and the
|
|
13
|
+
* sound; then the skips; then the mute and the subtitles. The subtitles
|
|
14
|
+
* menu goes last of the menus because it is the one a viewer may need.
|
|
15
|
+
* The diagnostics is another package's, named here as a string. A
|
|
16
|
+
* `priority` attribute on the control replaces its default.
|
|
17
|
+
*/
|
|
18
|
+
const PRIORITY = {
|
|
19
|
+
[VOLUME_SLIDER]: 5,
|
|
20
|
+
"mbx-diagnostics": 4,
|
|
21
|
+
[DRM_BADGE]: 4,
|
|
22
|
+
[SPEED_MENU]: 4,
|
|
23
|
+
[CHAPTERS_MENU]: 4,
|
|
24
|
+
[AUDIO_MENU]: 3,
|
|
25
|
+
[QUALITY_MENU]: 3,
|
|
26
|
+
[PIP_BUTTON]: 3,
|
|
27
|
+
[SKIP_BUTTON]: 2,
|
|
28
|
+
[SUBTITLES_MENU]: 1,
|
|
29
|
+
[VOLUME]: 1,
|
|
30
|
+
[MUTE_BUTTON]: 1
|
|
31
|
+
};
|
|
32
|
+
/** The width the volume group unfolds its slider to, from volume.ts: what a folded slider is counted at. */
|
|
33
|
+
const SLIDER_WIDTH = 80;
|
|
34
|
+
/** Room kept between the last button and the edge, so nothing sits flush against it. */
|
|
35
|
+
const SLACK = 8;
|
|
36
|
+
function shown(node) {
|
|
37
|
+
return node.getClientRects().length > 0;
|
|
38
|
+
}
|
|
39
|
+
/** The slider inside a volume group child, when it has one. */
|
|
40
|
+
function slider(child) {
|
|
41
|
+
return child.localName === "mbx-volume" ? child.querySelector(VOLUME_SLIDER) : null;
|
|
42
|
+
}
|
|
43
|
+
/** A child's priority: its attribute, else its tag's default, else zero. */
|
|
44
|
+
function priority(child) {
|
|
45
|
+
var _PRIORITY$child$local;
|
|
46
|
+
const own = child.getAttribute("priority");
|
|
47
|
+
if (own !== null) {
|
|
48
|
+
const value = Number(own);
|
|
49
|
+
return Number.isFinite(value) && value > 0 ? value : 0;
|
|
50
|
+
}
|
|
51
|
+
return (_PRIORITY$child$local = PRIORITY[child.localName]) !== null && _PRIORITY$child$local !== void 0 ? _PRIORITY$child$local : 0;
|
|
52
|
+
}
|
|
53
|
+
const STYLE = `
|
|
54
|
+
:host {
|
|
55
|
+
position: absolute;
|
|
56
|
+
inset: auto 0 0 0;
|
|
57
|
+
box-sizing: border-box;
|
|
58
|
+
display: flex;
|
|
59
|
+
flex-direction: column;
|
|
60
|
+
gap: 4px;
|
|
61
|
+
padding: 40px 16px 12px;
|
|
62
|
+
color: var(--mbx-text);
|
|
63
|
+
background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
|
|
64
|
+
font: 500 16px/1.2 var(--mbx-font);
|
|
65
|
+
transition: opacity 0.2s;
|
|
66
|
+
}
|
|
67
|
+
:host([idle]) { opacity: 0; pointer-events: none; }
|
|
68
|
+
[part~="row"] { display: flex; align-items: center; gap: 8px; }
|
|
69
|
+
[part~="seek-row"] { gap: 16px; }
|
|
70
|
+
::slotted([collapsed]) { display: none; }
|
|
71
|
+
@media (prefers-reduced-motion: reduce) {
|
|
72
|
+
:host { transition: none; }
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
75
|
+
function end(video) {
|
|
76
|
+
if (Number.isFinite(video.duration)) return video.duration;
|
|
77
|
+
const ranges = video.seekable;
|
|
78
|
+
return ranges.length > 0 ? ranges.end(ranges.length - 1) : video.currentTime;
|
|
79
|
+
}
|
|
80
|
+
function toggle(video) {
|
|
81
|
+
if (video.paused) video.play().catch(() => void 0);
|
|
82
|
+
else video.pause();
|
|
83
|
+
}
|
|
84
|
+
var MbxControlBar = class extends Component {
|
|
85
|
+
static get observedAttributes() {
|
|
86
|
+
return ["idle-ms", "seek-step"];
|
|
87
|
+
}
|
|
88
|
+
constructor() {
|
|
89
|
+
super();
|
|
90
|
+
this.timer = void 0;
|
|
91
|
+
this.keyboard = false;
|
|
92
|
+
this.cues = null;
|
|
93
|
+
this.screen = null;
|
|
94
|
+
this.resizer = null;
|
|
95
|
+
const root = this.attachShadow({ mode: "open" });
|
|
96
|
+
this.seekRow = document.createElement("div");
|
|
97
|
+
this.seekRow.setAttribute("part", "row seek-row");
|
|
98
|
+
const seek = document.createElement("slot");
|
|
99
|
+
seek.name = "seek";
|
|
100
|
+
this.seekRow.append(seek);
|
|
101
|
+
this.buttonsRow = document.createElement("div");
|
|
102
|
+
this.buttonsRow.setAttribute("part", "row buttons-row");
|
|
103
|
+
this.buttons = document.createElement("slot");
|
|
104
|
+
this.buttonsRow.append(this.buttons);
|
|
105
|
+
root.append(style(STYLE), this.seekRow, this.buttonsRow);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* What the buttons need: their widths and the gaps between them, the
|
|
109
|
+
* spacer aside since it takes what is left, and a folded slider at the
|
|
110
|
+
* width it unfolds to. The row's own width says nothing, because the
|
|
111
|
+
* spacer fills it whatever the buttons take.
|
|
112
|
+
*/
|
|
113
|
+
needed(children) {
|
|
114
|
+
const gap = Number.parseFloat(getComputedStyle(this.buttonsRow).columnGap) || 0;
|
|
115
|
+
let sum = 0;
|
|
116
|
+
let count = 0;
|
|
117
|
+
for (const child of children) {
|
|
118
|
+
if (child.localName === "mbx-spacer" || !shown(child)) continue;
|
|
119
|
+
sum += child.getBoundingClientRect().width;
|
|
120
|
+
count += 1;
|
|
121
|
+
const folded = slider(child);
|
|
122
|
+
if (folded !== null && shown(folded)) sum += Math.max(0, SLIDER_WIDTH - folded.getBoundingClientRect().width);
|
|
123
|
+
}
|
|
124
|
+
return sum + gap * Math.max(0, count - 1);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Collapses the buttons row to its width. Everything is shown first, so
|
|
128
|
+
* a wider bar gets its controls back, then the highest priorities go one
|
|
129
|
+
* at a time while the buttons need more than the row has, less the
|
|
130
|
+
* slack. Each step lays the row out again; a bar carries a dozen
|
|
131
|
+
* controls, so that is cheap.
|
|
132
|
+
*/
|
|
133
|
+
collapse() {
|
|
134
|
+
const children = this.buttons.assignedElements();
|
|
135
|
+
const candidates = [];
|
|
136
|
+
for (const [index, child] of children.entries()) {
|
|
137
|
+
child.removeAttribute("collapsed");
|
|
138
|
+
const inner = slider(child);
|
|
139
|
+
inner === null || inner === void 0 || inner.removeAttribute("collapsed");
|
|
140
|
+
if (inner !== null && shown(inner)) candidates.push({
|
|
141
|
+
node: inner,
|
|
142
|
+
index: index + .5,
|
|
143
|
+
priority: priority(inner)
|
|
144
|
+
});
|
|
145
|
+
if (shown(child)) candidates.push({
|
|
146
|
+
node: child,
|
|
147
|
+
index,
|
|
148
|
+
priority: priority(child)
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
candidates.sort((a, b) => b.priority - a.priority || b.index - a.index);
|
|
152
|
+
const room = this.buttonsRow.clientWidth - SLACK;
|
|
153
|
+
for (const { node, priority: level } of candidates) {
|
|
154
|
+
if (level === 0) return;
|
|
155
|
+
if (this.needed(children) <= room) return;
|
|
156
|
+
node.setAttribute("collapsed", "");
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/** From the first row's top to the bar's bottom: what the bar covers of the picture. */
|
|
160
|
+
covered() {
|
|
161
|
+
return {
|
|
162
|
+
top: this.seekRow.getBoundingClientRect().top,
|
|
163
|
+
bottom: this.getBoundingClientRect().bottom
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
held(player) {
|
|
167
|
+
if (player.video.paused) return true;
|
|
168
|
+
if (this.querySelector("[open]") !== null) return true;
|
|
169
|
+
if (!this.keyboard) return false;
|
|
170
|
+
const active = this.getRootNode().activeElement;
|
|
171
|
+
return active !== null && this.contains(active);
|
|
172
|
+
}
|
|
173
|
+
idle(player, on) {
|
|
174
|
+
var _this$cues;
|
|
175
|
+
if (this.hasAttribute("idle") === on) return;
|
|
176
|
+
this.toggleAttribute("idle", on);
|
|
177
|
+
player.toggleAttribute("idle", on);
|
|
178
|
+
(_this$cues = this.cues) === null || _this$cues === void 0 || _this$cues.lifted(!on);
|
|
179
|
+
}
|
|
180
|
+
sleep(player) {
|
|
181
|
+
this.timer = void 0;
|
|
182
|
+
if (this.held(player)) {
|
|
183
|
+
this.timer = setTimeout(() => this.sleep(player), number(this, "idle-ms", IDLE_MS));
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
this.idle(player, true);
|
|
187
|
+
}
|
|
188
|
+
wake(player) {
|
|
189
|
+
clearTimeout(this.timer);
|
|
190
|
+
this.idle(player, false);
|
|
191
|
+
this.timer = setTimeout(() => this.sleep(player), number(this, "idle-ms", IDLE_MS));
|
|
192
|
+
}
|
|
193
|
+
key(player, event) {
|
|
194
|
+
this.keyboard = true;
|
|
195
|
+
this.wake(player);
|
|
196
|
+
if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return;
|
|
197
|
+
const video = player.video;
|
|
198
|
+
const onButton = event.composedPath()[0] instanceof HTMLButtonElement;
|
|
199
|
+
switch (event.key) {
|
|
200
|
+
case " ":
|
|
201
|
+
if (onButton) return;
|
|
202
|
+
toggle(video);
|
|
203
|
+
break;
|
|
204
|
+
case "k":
|
|
205
|
+
case "K":
|
|
206
|
+
toggle(video);
|
|
207
|
+
break;
|
|
208
|
+
case "m":
|
|
209
|
+
case "M":
|
|
210
|
+
video.muted = !video.muted;
|
|
211
|
+
break;
|
|
212
|
+
case "f":
|
|
213
|
+
case "F":
|
|
214
|
+
var _this$screen;
|
|
215
|
+
(_this$screen = this.screen) === null || _this$screen === void 0 || _this$screen.toggle();
|
|
216
|
+
break;
|
|
217
|
+
case "ArrowLeft":
|
|
218
|
+
video.currentTime = Math.max(0, video.currentTime - number(this, "seek-step", SEEK_STEP));
|
|
219
|
+
break;
|
|
220
|
+
case "ArrowRight":
|
|
221
|
+
video.currentTime = Math.min(end(video), video.currentTime + number(this, "seek-step", SEEK_STEP));
|
|
222
|
+
break;
|
|
223
|
+
default: return;
|
|
224
|
+
}
|
|
225
|
+
event.preventDefault();
|
|
226
|
+
}
|
|
227
|
+
attach(player) {
|
|
228
|
+
const video = player.video;
|
|
229
|
+
cueStyle();
|
|
230
|
+
this.cues = cueLift(video, player, () => this.covered());
|
|
231
|
+
const screen = fullscreen(player, video);
|
|
232
|
+
this.screen = screen;
|
|
233
|
+
const reflect = () => {
|
|
234
|
+
player.toggleAttribute("fullscreen", screen.active());
|
|
235
|
+
};
|
|
236
|
+
this.keep(screen.watch(reflect));
|
|
237
|
+
reflect();
|
|
238
|
+
const pointer = () => {
|
|
239
|
+
this.keyboard = false;
|
|
240
|
+
this.wake(player);
|
|
241
|
+
};
|
|
242
|
+
const key = (event) => {
|
|
243
|
+
this.key(player, event);
|
|
244
|
+
};
|
|
245
|
+
const click = (event) => {
|
|
246
|
+
if (event.composedPath()[0] === video) toggle(video);
|
|
247
|
+
};
|
|
248
|
+
this.listen(player, ["pointermove", "pointerdown"], pointer);
|
|
249
|
+
player.addEventListener("keydown", key);
|
|
250
|
+
player.addEventListener("click", click);
|
|
251
|
+
this.keep(() => {
|
|
252
|
+
player.removeEventListener("keydown", key);
|
|
253
|
+
player.removeEventListener("click", click);
|
|
254
|
+
});
|
|
255
|
+
this.listen(video, [
|
|
256
|
+
"play",
|
|
257
|
+
"pause",
|
|
258
|
+
"ended"
|
|
259
|
+
], () => {
|
|
260
|
+
this.wake(player);
|
|
261
|
+
});
|
|
262
|
+
this.wake(player);
|
|
263
|
+
this.cues.lifted(true);
|
|
264
|
+
const collapse = () => {
|
|
265
|
+
this.collapse();
|
|
266
|
+
};
|
|
267
|
+
this.listen(this.buttons, ["slotchange"], collapse);
|
|
268
|
+
this.observe(this, [
|
|
269
|
+
"hidden",
|
|
270
|
+
"priority",
|
|
271
|
+
"slot"
|
|
272
|
+
], collapse, true);
|
|
273
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
274
|
+
this.resizer = new ResizeObserver(collapse);
|
|
275
|
+
this.resizer.observe(this.buttonsRow);
|
|
276
|
+
}
|
|
277
|
+
collapse();
|
|
278
|
+
}
|
|
279
|
+
detach(player) {
|
|
280
|
+
var _this$resizer, _this$cues2;
|
|
281
|
+
clearTimeout(this.timer);
|
|
282
|
+
this.timer = void 0;
|
|
283
|
+
(_this$resizer = this.resizer) === null || _this$resizer === void 0 || _this$resizer.disconnect();
|
|
284
|
+
this.resizer = null;
|
|
285
|
+
for (const child of this.buttons.assignedElements()) {
|
|
286
|
+
var _slider;
|
|
287
|
+
child.removeAttribute("collapsed");
|
|
288
|
+
(_slider = slider(child)) === null || _slider === void 0 || _slider.removeAttribute("collapsed");
|
|
289
|
+
}
|
|
290
|
+
(_this$cues2 = this.cues) === null || _this$cues2 === void 0 || _this$cues2.dispose();
|
|
291
|
+
this.cues = null;
|
|
292
|
+
this.screen = null;
|
|
293
|
+
this.removeAttribute("idle");
|
|
294
|
+
player.removeAttribute("idle");
|
|
295
|
+
player.removeAttribute("fullscreen");
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
//#endregion
|
|
299
|
+
export { MbxControlBar };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { format } from "../controls/time.js";
|
|
2
|
+
import { live, span, wall } from "../controls/session.js";
|
|
3
|
+
import { TimeElement } from "./time-element.js";
|
|
4
|
+
//#region src/elements/current-time.ts
|
|
5
|
+
/**
|
|
6
|
+
* <mbx-current-time>: the position, "1:23". On a live stream it reads the
|
|
7
|
+
* wall clock when `engine.pdt` can say it, "14:23:05", which is what a
|
|
8
|
+
* viewer of a broadcast wants to know, and the distance behind the edge
|
|
9
|
+
* otherwise, "-0:10". While the player says the stream is live but not
|
|
10
|
+
* seekable, which the seek bar decides, there is no position to show and
|
|
11
|
+
* the element hides.
|
|
12
|
+
*/
|
|
13
|
+
var MbxCurrentTime = class extends TimeElement {
|
|
14
|
+
render() {
|
|
15
|
+
var _wall;
|
|
16
|
+
const player = this.player;
|
|
17
|
+
if (player === null) return;
|
|
18
|
+
const video = player.video;
|
|
19
|
+
const engine = player.engine;
|
|
20
|
+
const on = live(engine) !== void 0;
|
|
21
|
+
const time = video.currentTime;
|
|
22
|
+
this.text.data = on ? (_wall = wall(engine, time)) !== null && _wall !== void 0 ? _wall : `-${format(span(video, engine).end - time)}` : format(time);
|
|
23
|
+
this.hidden = on && player.hasAttribute("live") && !player.hasAttribute("seekable");
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { MbxCurrentTime };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { namespaces } from "../namespaces.js";
|
|
2
|
+
import { el } from "../dom.js";
|
|
3
|
+
import { icon } from "../controls/icons.js";
|
|
4
|
+
import { fill } from "../labels.js";
|
|
5
|
+
import { Component } from "./component.js";
|
|
6
|
+
import { style } from "./shared.js";
|
|
7
|
+
//#region src/elements/drm-badge.ts
|
|
8
|
+
const STYLE = `
|
|
9
|
+
:host { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; color: var(--mbx-muted); border-radius: var(--mbx-radius); cursor: default; }
|
|
10
|
+
:host([hidden]) { display: none; }
|
|
11
|
+
:host(:focus-visible) { outline: 2px solid var(--mbx-accent); outline-offset: -2px; }
|
|
12
|
+
[part~="icon"], ::slotted(*) { width: 1.75em; height: 1.75em; fill: currentColor; }
|
|
13
|
+
[part~="tooltip"] {
|
|
14
|
+
position: absolute;
|
|
15
|
+
right: 0;
|
|
16
|
+
bottom: 100%;
|
|
17
|
+
margin-bottom: 8px;
|
|
18
|
+
padding: 8px 10px;
|
|
19
|
+
background: rgba(16, 17, 20, 0.95);
|
|
20
|
+
border-radius: var(--mbx-radius);
|
|
21
|
+
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
|
|
22
|
+
color: var(--mbx-text);
|
|
23
|
+
font-size: 13px;
|
|
24
|
+
line-height: 1.4;
|
|
25
|
+
text-align: left;
|
|
26
|
+
white-space: nowrap;
|
|
27
|
+
pointer-events: none;
|
|
28
|
+
}
|
|
29
|
+
[part~="tooltip"][hidden] { display: none; }
|
|
30
|
+
[part~="tooltip-title"] { font-weight: 600; }
|
|
31
|
+
[part~="tooltip-text"] { color: var(--mbx-muted); }
|
|
32
|
+
`;
|
|
33
|
+
/** The name a viewer knows a key system by. */
|
|
34
|
+
function keySystemName(id) {
|
|
35
|
+
if (id.startsWith("com.widevine")) return "Widevine";
|
|
36
|
+
if (id.startsWith("com.microsoft.playready")) return "PlayReady";
|
|
37
|
+
if (id.startsWith("com.apple.fps")) return "FairPlay";
|
|
38
|
+
return id;
|
|
39
|
+
}
|
|
40
|
+
var MbxDrmBadge = class extends Component {
|
|
41
|
+
static get observedAttributes() {
|
|
42
|
+
return [
|
|
43
|
+
"label",
|
|
44
|
+
"label-key",
|
|
45
|
+
"label-keys",
|
|
46
|
+
"label-no-key"
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
constructor() {
|
|
50
|
+
super();
|
|
51
|
+
this.engine = null;
|
|
52
|
+
const root = this.attachShadow({ mode: "open" });
|
|
53
|
+
const slot = document.createElement("slot");
|
|
54
|
+
slot.name = "icon";
|
|
55
|
+
slot.append(icon("lock-closed"));
|
|
56
|
+
this.tooltip = el("div", "tooltip");
|
|
57
|
+
this.tooltip.setAttribute("role", "tooltip");
|
|
58
|
+
this.system = el("div", "tooltip-title");
|
|
59
|
+
this.system_id = el("div", "tooltip-text");
|
|
60
|
+
this.keys = el("div", "tooltip-text");
|
|
61
|
+
this.tooltip.append(this.system, this.system_id, this.keys);
|
|
62
|
+
this.tooltip.hidden = true;
|
|
63
|
+
root.append(style(STYLE), slot, this.tooltip);
|
|
64
|
+
const show = () => {
|
|
65
|
+
this.tooltip.hidden = false;
|
|
66
|
+
};
|
|
67
|
+
const hide = () => {
|
|
68
|
+
this.tooltip.hidden = true;
|
|
69
|
+
};
|
|
70
|
+
this.addEventListener("pointerenter", show);
|
|
71
|
+
this.addEventListener("pointerleave", hide);
|
|
72
|
+
this.addEventListener("focus", show);
|
|
73
|
+
this.addEventListener("blur", hide);
|
|
74
|
+
}
|
|
75
|
+
/** Named and focusable before attaching: a constructor must not add attributes. */
|
|
76
|
+
connectedCallback() {
|
|
77
|
+
if (!this.hasAttribute("role")) this.setAttribute("role", "img");
|
|
78
|
+
if (!this.hasAttribute("tabindex")) this.tabIndex = 0;
|
|
79
|
+
if (this.player === null) this.hidden = true;
|
|
80
|
+
super.connectedCallback();
|
|
81
|
+
}
|
|
82
|
+
/** "3 keys: usable ×2, expired", or "no key yet". */
|
|
83
|
+
sessionsText(sessions) {
|
|
84
|
+
var _this$getAttribute, _this$getAttribute2, _this$getAttribute3;
|
|
85
|
+
if (sessions.length === 0) return (_this$getAttribute = this.getAttribute("label-no-key")) !== null && _this$getAttribute !== void 0 ? _this$getAttribute : "no key yet";
|
|
86
|
+
const counts = /* @__PURE__ */ new Map();
|
|
87
|
+
for (const session of sessions) {
|
|
88
|
+
var _counts$get;
|
|
89
|
+
counts.set(session.status, ((_counts$get = counts.get(session.status)) !== null && _counts$get !== void 0 ? _counts$get : 0) + 1);
|
|
90
|
+
}
|
|
91
|
+
const parts = [];
|
|
92
|
+
for (const [status, count] of counts) parts.push(count > 1 ? `${status} ×${count}` : status);
|
|
93
|
+
const template = sessions.length === 1 ? (_this$getAttribute2 = this.getAttribute("label-key")) !== null && _this$getAttribute2 !== void 0 ? _this$getAttribute2 : "{count} key: {statuses}" : (_this$getAttribute3 = this.getAttribute("label-keys")) !== null && _this$getAttribute3 !== void 0 ? _this$getAttribute3 : "{count} keys: {statuses}";
|
|
94
|
+
return fill(template, {
|
|
95
|
+
count: sessions.length,
|
|
96
|
+
statuses: parts.join(", ")
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
attach(player) {
|
|
100
|
+
this.follow(player, (engine) => {
|
|
101
|
+
this.engine = engine;
|
|
102
|
+
this.render();
|
|
103
|
+
if (engine === null || namespaces(engine).drm === void 0) return void 0;
|
|
104
|
+
const tick = () => {
|
|
105
|
+
this.render();
|
|
106
|
+
};
|
|
107
|
+
const offs = [
|
|
108
|
+
engine.on("drm:keysystem", tick),
|
|
109
|
+
engine.on("drm:keystatus", tick),
|
|
110
|
+
engine.on("drm:encrypted", tick)
|
|
111
|
+
];
|
|
112
|
+
return () => {
|
|
113
|
+
for (const off of offs) off();
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
detach() {
|
|
118
|
+
this.tooltip.hidden = true;
|
|
119
|
+
}
|
|
120
|
+
render() {
|
|
121
|
+
var _drm$keySystem, _this$getAttribute4;
|
|
122
|
+
const drm = this.engine === null ? void 0 : namespaces(this.engine).drm;
|
|
123
|
+
const name = (_drm$keySystem = drm === null || drm === void 0 ? void 0 : drm.keySystem) !== null && _drm$keySystem !== void 0 ? _drm$keySystem : null;
|
|
124
|
+
this.hidden = name === null;
|
|
125
|
+
if (drm === void 0 || name === null) return;
|
|
126
|
+
const keys = this.sessionsText(drm.sessions);
|
|
127
|
+
const system = keySystemName(name);
|
|
128
|
+
this.system.textContent = system;
|
|
129
|
+
this.system_id.textContent = name;
|
|
130
|
+
this.keys.textContent = keys;
|
|
131
|
+
this.setAttribute("aria-label", fill((_this$getAttribute4 = this.getAttribute("label")) !== null && _this$getAttribute4 !== void 0 ? _this$getAttribute4 : "Protected by {system}, {keys}", {
|
|
132
|
+
system,
|
|
133
|
+
keys
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
//#endregion
|
|
138
|
+
export { MbxDrmBadge };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { format } from "../controls/time.js";
|
|
2
|
+
import { live, span } from "../controls/session.js";
|
|
3
|
+
import { TimeElement } from "./time-element.js";
|
|
4
|
+
//#region src/elements/duration.ts
|
|
5
|
+
/**
|
|
6
|
+
* <mbx-duration>: the duration, "4:56", once the metadata is in. A live
|
|
7
|
+
* stream has none, so the element hides while the stream is live.
|
|
8
|
+
*/
|
|
9
|
+
var MbxDuration = class extends TimeElement {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(":host { text-align: right; }");
|
|
12
|
+
}
|
|
13
|
+
render() {
|
|
14
|
+
const player = this.player;
|
|
15
|
+
if (player === null) return;
|
|
16
|
+
const engine = player.engine;
|
|
17
|
+
const on = live(engine) !== void 0;
|
|
18
|
+
this.hidden = on;
|
|
19
|
+
if (!on) this.text.data = format(span(player.video, engine).end);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { MbxDuration };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { el } from "../dom.js";
|
|
2
|
+
import { Component } from "./component.js";
|
|
3
|
+
import { style } from "./shared.js";
|
|
4
|
+
//#region src/elements/error-screen.ts
|
|
5
|
+
const STYLE = `
|
|
6
|
+
:host {
|
|
7
|
+
position: absolute;
|
|
8
|
+
inset: 0;
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
padding: 16px;
|
|
13
|
+
background: rgba(0, 0, 0, 0.75);
|
|
14
|
+
color: var(--mbx-text);
|
|
15
|
+
font: 400 15px/1.4 var(--mbx-font);
|
|
16
|
+
text-align: center;
|
|
17
|
+
}
|
|
18
|
+
:host([hidden]) { display: none; }
|
|
19
|
+
[part~="box"] { display: flex; flex-direction: column; align-items: center; gap: 8px; }
|
|
20
|
+
[part~="title"] { font-size: 18px; font-weight: 600; }
|
|
21
|
+
[part~="detail"] { font-family: monospace; font-size: 13px; color: var(--mbx-error); }
|
|
22
|
+
[part~="retry"] {
|
|
23
|
+
height: 36px;
|
|
24
|
+
padding: 0 16px;
|
|
25
|
+
font: inherit;
|
|
26
|
+
font-weight: 600;
|
|
27
|
+
color: inherit;
|
|
28
|
+
background: transparent;
|
|
29
|
+
border: 1px solid currentColor;
|
|
30
|
+
border-radius: var(--mbx-radius);
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
}
|
|
33
|
+
[part~="retry"]:focus-visible { outline: 2px solid var(--mbx-accent); outline-offset: -2px; }
|
|
34
|
+
`;
|
|
35
|
+
var MbxErrorScreen = class extends Component {
|
|
36
|
+
static get observedAttributes() {
|
|
37
|
+
return ["label-title", "label-retry"];
|
|
38
|
+
}
|
|
39
|
+
constructor() {
|
|
40
|
+
super();
|
|
41
|
+
const root = this.attachShadow({ mode: "open" });
|
|
42
|
+
const box = el("div", "box");
|
|
43
|
+
this.title_ = el("div", "title");
|
|
44
|
+
this.category = el("span", "category");
|
|
45
|
+
this.code = el("span", "code");
|
|
46
|
+
const detail = el("div", "detail");
|
|
47
|
+
detail.append(this.category, el("span", "separator", " · "), this.code);
|
|
48
|
+
this.retry = el("button", "retry");
|
|
49
|
+
this.retry.type = "button";
|
|
50
|
+
this.retry.addEventListener("click", () => {
|
|
51
|
+
const player = this.player;
|
|
52
|
+
const src = player === null || player === void 0 ? void 0 : player.getAttribute("src");
|
|
53
|
+
if (player !== null && player !== void 0 && src !== null && src !== void 0) player.setAttribute("src", src);
|
|
54
|
+
});
|
|
55
|
+
box.append(this.title_, detail, this.retry);
|
|
56
|
+
root.append(style(STYLE), box);
|
|
57
|
+
}
|
|
58
|
+
/** Hidden and named before attaching: a constructor must not add attributes. */
|
|
59
|
+
connectedCallback() {
|
|
60
|
+
if (this.player === null) this.hidden = true;
|
|
61
|
+
if (!this.hasAttribute("role")) this.setAttribute("role", "alert");
|
|
62
|
+
super.connectedCallback();
|
|
63
|
+
}
|
|
64
|
+
show(error) {
|
|
65
|
+
this.category.textContent = error.category;
|
|
66
|
+
this.code.textContent = error.code;
|
|
67
|
+
this.hidden = false;
|
|
68
|
+
}
|
|
69
|
+
attach(player) {
|
|
70
|
+
const failure = (event) => {
|
|
71
|
+
const error = event.detail;
|
|
72
|
+
if (error.fatal) this.show(error);
|
|
73
|
+
};
|
|
74
|
+
player.addEventListener("error", failure);
|
|
75
|
+
this.keep(() => {
|
|
76
|
+
player.removeEventListener("error", failure);
|
|
77
|
+
});
|
|
78
|
+
this.listen(player.video, ["playing", "loadstart"], () => {
|
|
79
|
+
this.hidden = true;
|
|
80
|
+
});
|
|
81
|
+
this.listen(player, ["sourcechange"], () => {
|
|
82
|
+
this.hidden = true;
|
|
83
|
+
});
|
|
84
|
+
if (player.error !== null) this.show(player.error);
|
|
85
|
+
this.render();
|
|
86
|
+
}
|
|
87
|
+
detach() {
|
|
88
|
+
this.hidden = true;
|
|
89
|
+
}
|
|
90
|
+
render() {
|
|
91
|
+
var _this$getAttribute, _this$getAttribute2;
|
|
92
|
+
this.title_.textContent = (_this$getAttribute = this.getAttribute("label-title")) !== null && _this$getAttribute !== void 0 ? _this$getAttribute : "Playback failed";
|
|
93
|
+
this.retry.textContent = (_this$getAttribute2 = this.getAttribute("label-retry")) !== null && _this$getAttribute2 !== void 0 ? _this$getAttribute2 : "Retry";
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
//#endregion
|
|
97
|
+
export { MbxErrorScreen };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { icon } from "../controls/icons.js";
|
|
2
|
+
import { Component } from "./component.js";
|
|
3
|
+
import { BUTTON_STYLE, iconSlots, show, style } from "./shared.js";
|
|
4
|
+
import { fullscreen } from "../controls/fullscreen.js";
|
|
5
|
+
//#region src/elements/fullscreen-button.ts
|
|
6
|
+
const STATES = ["enter", "exit"];
|
|
7
|
+
var MbxFullscreenButton = class extends Component {
|
|
8
|
+
static get observedAttributes() {
|
|
9
|
+
return ["label-enter", "label-exit"];
|
|
10
|
+
}
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
this.api = null;
|
|
14
|
+
const root = this.attachShadow({ mode: "open" });
|
|
15
|
+
this.button = document.createElement("button");
|
|
16
|
+
this.button.type = "button";
|
|
17
|
+
this.button.setAttribute("part", "button");
|
|
18
|
+
this.slots = iconSlots(STATES, (state) => icon(state === "enter" ? "fullscreen" : "fullscreen-exit"));
|
|
19
|
+
for (const state of STATES) this.button.append(this.slots[state]);
|
|
20
|
+
this.button.addEventListener("click", () => {
|
|
21
|
+
var _this$api;
|
|
22
|
+
(_this$api = this.api) === null || _this$api === void 0 || _this$api.toggle();
|
|
23
|
+
});
|
|
24
|
+
root.append(style(BUTTON_STYLE), this.button);
|
|
25
|
+
}
|
|
26
|
+
attach(player) {
|
|
27
|
+
const api = fullscreen(player, player.video);
|
|
28
|
+
this.api = api;
|
|
29
|
+
this.hidden = !api.supported;
|
|
30
|
+
this.keep(api.watch(() => {
|
|
31
|
+
this.render();
|
|
32
|
+
}));
|
|
33
|
+
this.render();
|
|
34
|
+
}
|
|
35
|
+
detach() {
|
|
36
|
+
this.api = null;
|
|
37
|
+
}
|
|
38
|
+
render() {
|
|
39
|
+
var _this$getAttribute, _this$getAttribute2;
|
|
40
|
+
const player = this.player;
|
|
41
|
+
if (player === null || this.api === null) return;
|
|
42
|
+
const active = this.api.active();
|
|
43
|
+
show(this.slots, active ? "exit" : "enter");
|
|
44
|
+
this.button.setAttribute("aria-label", active ? (_this$getAttribute = this.getAttribute("label-exit")) !== null && _this$getAttribute !== void 0 ? _this$getAttribute : "Exit fullscreen" : (_this$getAttribute2 = this.getAttribute("label-enter")) !== null && _this$getAttribute2 !== void 0 ? _this$getAttribute2 : "Enter fullscreen");
|
|
45
|
+
player.toggleAttribute("fullscreen", active);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
|
+
export { MbxFullscreenButton };
|