@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,314 @@
|
|
|
1
|
+
import { el } from "../dom.js";
|
|
2
|
+
import { fill } from "../labels.js";
|
|
3
|
+
import { Component } from "./component.js";
|
|
4
|
+
import { SLIDER_STYLE, number, seekRow, style } from "./shared.js";
|
|
5
|
+
import { chapterAt, chapters, followChapters } from "../controls/chapters.js";
|
|
6
|
+
import { format } from "../controls/time.js";
|
|
7
|
+
import { EMPTY, at, clip, fraction } from "../controls/ranges.js";
|
|
8
|
+
import { bufferGoal, live, optional, span, wall } from "../controls/session.js";
|
|
9
|
+
import { slider } from "../controls/slider.js";
|
|
10
|
+
//#region src/elements/seek-bar.ts
|
|
11
|
+
const STEP = 5;
|
|
12
|
+
const PAGE = 30;
|
|
13
|
+
const LIVE_WINDOW = 3;
|
|
14
|
+
/** What the tile scales down to when the page sets no `--mbx-preview-width`. */
|
|
15
|
+
const PREVIEW_WIDTH = 160;
|
|
16
|
+
/** The buffer goal assumed for a session that reports none. */
|
|
17
|
+
const BUFFER_GOAL = 30;
|
|
18
|
+
/** The gap cut at a chapter boundary, in pixels. */
|
|
19
|
+
const GAP = 2;
|
|
20
|
+
const EVENTS = [
|
|
21
|
+
"timeupdate",
|
|
22
|
+
"progress",
|
|
23
|
+
"durationchange",
|
|
24
|
+
"loadedmetadata",
|
|
25
|
+
"seeking",
|
|
26
|
+
"seeked",
|
|
27
|
+
"emptied"
|
|
28
|
+
];
|
|
29
|
+
const STYLE = `${SLIDER_STYLE}
|
|
30
|
+
:host { flex: 1; }
|
|
31
|
+
[part~="slider"] { flex: 1; }
|
|
32
|
+
[part~="thumb"] { width: 16px; height: 16px; margin: -8px 0 0 -8px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
|
|
33
|
+
[part~="buffered"] { position: absolute; top: 0; right: 0; bottom: 0; left: 0; }
|
|
34
|
+
[part~="buffered-range"] { position: absolute; top: 0; bottom: 0; background: rgba(255, 255, 255, 0.3); }
|
|
35
|
+
[part~="hover"] { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--mbx-text); }
|
|
36
|
+
[part~="edge"] { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--mbx-live); }
|
|
37
|
+
[part~="preview"] {
|
|
38
|
+
position: absolute;
|
|
39
|
+
bottom: 100%;
|
|
40
|
+
margin-bottom: 4px;
|
|
41
|
+
transform: translateX(-50%);
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: column;
|
|
44
|
+
align-items: center;
|
|
45
|
+
gap: 2px;
|
|
46
|
+
padding: 2px;
|
|
47
|
+
background: var(--mbx-surface);
|
|
48
|
+
border-radius: var(--mbx-radius);
|
|
49
|
+
font-size: 13px;
|
|
50
|
+
font-variant-numeric: tabular-nums;
|
|
51
|
+
white-space: nowrap;
|
|
52
|
+
pointer-events: none;
|
|
53
|
+
}
|
|
54
|
+
[part~="preview-image"] { position: relative; overflow: hidden; border-radius: 2px; }
|
|
55
|
+
[part~="preview-tile"] { position: absolute; top: 0; left: 0; transform-origin: top left; background-repeat: no-repeat; }
|
|
56
|
+
[part~="preview-time"] { padding: 0 4px; }
|
|
57
|
+
[part~="preview-title"] { max-width: 240px; padding: 0 4px; overflow: hidden; text-overflow: ellipsis; }
|
|
58
|
+
[hidden] { display: none; }
|
|
59
|
+
`;
|
|
60
|
+
function percent(part) {
|
|
61
|
+
return `${part * 100}%`;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A mask that cuts a gap at each boundary between chapters, as stops along
|
|
65
|
+
* the track: opaque up to a boundary, clear for the gap, opaque after.
|
|
66
|
+
*/
|
|
67
|
+
function gaps(list, span) {
|
|
68
|
+
const stops = ["#000 0"];
|
|
69
|
+
for (const chapter of list.slice(1)) {
|
|
70
|
+
const at = percent(fraction(chapter.start, span));
|
|
71
|
+
const before = `calc(${at} - ${GAP / 2}px)`;
|
|
72
|
+
const after = `calc(${at} + ${GAP / 2}px)`;
|
|
73
|
+
stops.push(`#000 ${before}`, `transparent ${before}`, `transparent ${after}`, `#000 ${after}`);
|
|
74
|
+
}
|
|
75
|
+
stops.push("#000 100%");
|
|
76
|
+
return `linear-gradient(to right, ${stops.join(", ")})`;
|
|
77
|
+
}
|
|
78
|
+
var MbxSeekBar = class extends Component {
|
|
79
|
+
static get observedAttributes() {
|
|
80
|
+
return [
|
|
81
|
+
"label",
|
|
82
|
+
"label-of",
|
|
83
|
+
"label-behind",
|
|
84
|
+
"live-window",
|
|
85
|
+
"chapters"
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
constructor() {
|
|
89
|
+
super();
|
|
90
|
+
this.range = EMPTY;
|
|
91
|
+
this.pending = null;
|
|
92
|
+
this.frame = 0;
|
|
93
|
+
this.divided = "";
|
|
94
|
+
this.list = [];
|
|
95
|
+
const root = this.attachShadow({ mode: "open" });
|
|
96
|
+
this.bar = slider({
|
|
97
|
+
step: () => number(this, "step", STEP),
|
|
98
|
+
page: () => number(this, "page", PAGE),
|
|
99
|
+
onInput: (value) => {
|
|
100
|
+
this.input(value);
|
|
101
|
+
},
|
|
102
|
+
onDrag: (on) => {
|
|
103
|
+
this.toggleAttribute("dragging", on);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
this.buffered = el("div", "buffered");
|
|
107
|
+
this.hover = el("div", "hover");
|
|
108
|
+
this.edge = el("div", "edge");
|
|
109
|
+
this.hover.hidden = true;
|
|
110
|
+
this.edge.hidden = true;
|
|
111
|
+
this.bar.track.prepend(this.buffered);
|
|
112
|
+
this.bar.track.append(this.hover, this.edge);
|
|
113
|
+
this.preview = el("div", "preview");
|
|
114
|
+
this.image = el("div", "preview-image");
|
|
115
|
+
this.tile = el("div", "preview-tile");
|
|
116
|
+
this.time = el("span", "preview-time");
|
|
117
|
+
this.caption = el("span", "preview-title");
|
|
118
|
+
this.caption.hidden = true;
|
|
119
|
+
this.image.append(this.tile);
|
|
120
|
+
this.image.hidden = true;
|
|
121
|
+
this.preview.append(this.image, this.caption, this.time);
|
|
122
|
+
this.preview.hidden = true;
|
|
123
|
+
this.bar.root.append(this.preview);
|
|
124
|
+
this.bar.root.addEventListener("pointermove", (event) => {
|
|
125
|
+
this.point(event);
|
|
126
|
+
});
|
|
127
|
+
this.bar.root.addEventListener("pointerleave", () => {
|
|
128
|
+
this.leave();
|
|
129
|
+
});
|
|
130
|
+
root.append(style(STYLE), this.bar.root);
|
|
131
|
+
}
|
|
132
|
+
connectedCallback() {
|
|
133
|
+
seekRow(this);
|
|
134
|
+
super.connectedCallback();
|
|
135
|
+
}
|
|
136
|
+
isLive() {
|
|
137
|
+
var _this$player$engine, _this$player;
|
|
138
|
+
return live((_this$player$engine = (_this$player = this.player) === null || _this$player === void 0 ? void 0 : _this$player.engine) !== null && _this$player$engine !== void 0 ? _this$player$engine : null) !== void 0;
|
|
139
|
+
}
|
|
140
|
+
/** Whether the chapters divide the track and name the preview. */
|
|
141
|
+
chaptered() {
|
|
142
|
+
return this.getAttribute("chapters") !== "none" && this.list.length > 0;
|
|
143
|
+
}
|
|
144
|
+
/** The gaps at the chapter boundaries, on every layer of the track at once. */
|
|
145
|
+
paintChapters() {
|
|
146
|
+
const mask = this.chaptered() && this.list.length > 1 ? gaps(this.list, this.range) : "";
|
|
147
|
+
const key = `${mask}|${this.range.start}|${this.range.end}`;
|
|
148
|
+
if (key === this.divided) return;
|
|
149
|
+
this.divided = key;
|
|
150
|
+
const track = this.bar.track.style;
|
|
151
|
+
track.setProperty("mask-image", mask === "" ? "" : mask);
|
|
152
|
+
track.setProperty("-webkit-mask-image", mask === "" ? "" : mask);
|
|
153
|
+
}
|
|
154
|
+
/** What a screen reader hears at a time. */
|
|
155
|
+
say(time) {
|
|
156
|
+
var _this$player$engine2, _this$player2, _this$getAttribute2;
|
|
157
|
+
const engine = (_this$player$engine2 = (_this$player2 = this.player) === null || _this$player2 === void 0 ? void 0 : _this$player2.engine) !== null && _this$player$engine2 !== void 0 ? _this$player$engine2 : null;
|
|
158
|
+
if (!this.isLive()) {
|
|
159
|
+
var _this$getAttribute;
|
|
160
|
+
const template = (_this$getAttribute = this.getAttribute("label-of")) !== null && _this$getAttribute !== void 0 ? _this$getAttribute : "{current} of {duration}";
|
|
161
|
+
return Number.isFinite(this.range.end) && this.range.end > 0 ? fill(template, {
|
|
162
|
+
current: format(time),
|
|
163
|
+
duration: format(this.range.end)
|
|
164
|
+
}) : format(time);
|
|
165
|
+
}
|
|
166
|
+
const behind = fill((_this$getAttribute2 = this.getAttribute("label-behind")) !== null && _this$getAttribute2 !== void 0 ? _this$getAttribute2 : "{time} behind live", { time: format(this.range.end - time) });
|
|
167
|
+
const clock = wall(engine, time);
|
|
168
|
+
return clock === null ? behind : `${clock}, ${behind}`;
|
|
169
|
+
}
|
|
170
|
+
/** What the preview shows at a time. */
|
|
171
|
+
label(time) {
|
|
172
|
+
var _wall, _this$player$engine3, _this$player3;
|
|
173
|
+
if (!this.isLive()) return format(time);
|
|
174
|
+
return (_wall = wall((_this$player$engine3 = (_this$player3 = this.player) === null || _this$player3 === void 0 ? void 0 : _this$player3.engine) !== null && _this$player$engine3 !== void 0 ? _this$player$engine3 : null, time)) !== null && _wall !== void 0 ? _wall : `-${format(this.range.end - time)}`;
|
|
175
|
+
}
|
|
176
|
+
input(value) {
|
|
177
|
+
var _this$player4;
|
|
178
|
+
const video = (_this$player4 = this.player) === null || _this$player4 === void 0 ? void 0 : _this$player4.video;
|
|
179
|
+
if (video === void 0) return;
|
|
180
|
+
this.bar.set(value, this.say(value));
|
|
181
|
+
if (!this.bar.dragging()) {
|
|
182
|
+
this.pending = null;
|
|
183
|
+
video.currentTime = value;
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
this.pending = value;
|
|
187
|
+
if (this.frame === 0) this.frame = requestAnimationFrame(() => {
|
|
188
|
+
this.flush();
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
flush() {
|
|
192
|
+
var _this$player5;
|
|
193
|
+
this.frame = 0;
|
|
194
|
+
const video = (_this$player5 = this.player) === null || _this$player5 === void 0 ? void 0 : _this$player5.video;
|
|
195
|
+
if (this.pending === null || video === void 0) return;
|
|
196
|
+
video.currentTime = this.pending;
|
|
197
|
+
this.pending = null;
|
|
198
|
+
}
|
|
199
|
+
/** The width the page asked for through the token, or the default. */
|
|
200
|
+
previewWidth() {
|
|
201
|
+
const set = Number.parseFloat(getComputedStyle(this.preview).getPropertyValue("--mbx-preview-width"));
|
|
202
|
+
return Number.isFinite(set) && set > 0 ? set : PREVIEW_WIDTH;
|
|
203
|
+
}
|
|
204
|
+
/** The tile for a time, if the track has one, drawn at its size and scaled to fit. */
|
|
205
|
+
paintTile(when) {
|
|
206
|
+
var _optional$thumbnails$, _optional$thumbnails, _this$player$engine4, _this$player6;
|
|
207
|
+
const found = (_optional$thumbnails$ = (_optional$thumbnails = optional((_this$player$engine4 = (_this$player6 = this.player) === null || _this$player6 === void 0 ? void 0 : _this$player6.engine) !== null && _this$player$engine4 !== void 0 ? _this$player$engine4 : null).thumbnails) === null || _optional$thumbnails === void 0 ? void 0 : _optional$thumbnails.at(when)) !== null && _optional$thumbnails$ !== void 0 ? _optional$thumbnails$ : null;
|
|
208
|
+
this.image.hidden = found === null;
|
|
209
|
+
if (found === null) return;
|
|
210
|
+
const scale = this.previewWidth() / found.width;
|
|
211
|
+
this.image.style.width = `${found.width * scale}px`;
|
|
212
|
+
this.image.style.height = `${found.height * scale}px`;
|
|
213
|
+
this.tile.style.width = `${found.width}px`;
|
|
214
|
+
this.tile.style.height = `${found.height}px`;
|
|
215
|
+
this.tile.style.backgroundImage = `url("${found.url}")`;
|
|
216
|
+
this.tile.style.backgroundPosition = `-${found.x}px -${found.y}px`;
|
|
217
|
+
this.tile.style.transform = `scale(${scale})`;
|
|
218
|
+
}
|
|
219
|
+
paintBuffered(video) {
|
|
220
|
+
var _buffered$lastElement;
|
|
221
|
+
const parts = clip(Array.from({ length: video.buffered.length }, (_, i) => ({
|
|
222
|
+
start: video.buffered.start(i),
|
|
223
|
+
end: video.buffered.end(i)
|
|
224
|
+
})), this.range);
|
|
225
|
+
const buffered = this.buffered;
|
|
226
|
+
while (buffered.childElementCount > parts.length) (_buffered$lastElement = buffered.lastElementChild) === null || _buffered$lastElement === void 0 || _buffered$lastElement.remove();
|
|
227
|
+
while (buffered.childElementCount < parts.length) buffered.append(el("div", "buffered-range"));
|
|
228
|
+
let i = 0;
|
|
229
|
+
for (const child of buffered.children) {
|
|
230
|
+
const part = parts[i];
|
|
231
|
+
i += 1;
|
|
232
|
+
if (part === void 0) break;
|
|
233
|
+
const node = child;
|
|
234
|
+
node.style.left = percent(part[0]);
|
|
235
|
+
node.style.width = percent(part[1] - part[0]);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/** Whether a live window is wide enough to be worth a bar. */
|
|
239
|
+
worthSeeking() {
|
|
240
|
+
var _bufferGoal, _this$player$engine5, _this$player7;
|
|
241
|
+
const goals = number(this, "live-window", LIVE_WINDOW);
|
|
242
|
+
if (goals === 0) return true;
|
|
243
|
+
const goal = (_bufferGoal = bufferGoal((_this$player$engine5 = (_this$player7 = this.player) === null || _this$player7 === void 0 ? void 0 : _this$player7.engine) !== null && _this$player$engine5 !== void 0 ? _this$player$engine5 : null)) !== null && _bufferGoal !== void 0 ? _bufferGoal : BUFFER_GOAL;
|
|
244
|
+
return this.range.end - this.range.start >= goals * goal;
|
|
245
|
+
}
|
|
246
|
+
/** The hover marker and the preview follow the pointer, clamped to the bar. */
|
|
247
|
+
point(event) {
|
|
248
|
+
var _chapter$title;
|
|
249
|
+
const rect = this.bar.rail.getBoundingClientRect();
|
|
250
|
+
if (rect.width === 0 || this.range.end <= this.range.start) return;
|
|
251
|
+
const part = Math.min(1, Math.max(0, (event.clientX - rect.left) / rect.width));
|
|
252
|
+
this.hover.hidden = false;
|
|
253
|
+
this.hover.style.left = percent(part);
|
|
254
|
+
this.preview.hidden = false;
|
|
255
|
+
const when = at(part, this.range);
|
|
256
|
+
this.time.textContent = this.label(when);
|
|
257
|
+
const chapter = this.chaptered() ? this.list[chapterAt(this.list, when)] : void 0;
|
|
258
|
+
this.caption.hidden = chapter === void 0 || chapter.title === "";
|
|
259
|
+
this.caption.textContent = (_chapter$title = chapter === null || chapter === void 0 ? void 0 : chapter.title) !== null && _chapter$title !== void 0 ? _chapter$title : "";
|
|
260
|
+
this.paintTile(when);
|
|
261
|
+
const whole = this.bar.root.getBoundingClientRect();
|
|
262
|
+
const half = this.preview.offsetWidth / 2;
|
|
263
|
+
const x = rect.left - whole.left + part * rect.width;
|
|
264
|
+
this.preview.style.left = `${Math.min(whole.width - half, Math.max(half, x))}px`;
|
|
265
|
+
}
|
|
266
|
+
leave() {
|
|
267
|
+
this.hover.hidden = true;
|
|
268
|
+
this.preview.hidden = true;
|
|
269
|
+
}
|
|
270
|
+
attach(player) {
|
|
271
|
+
const tick = () => {
|
|
272
|
+
this.render();
|
|
273
|
+
};
|
|
274
|
+
this.listen(player.video, EVENTS, tick);
|
|
275
|
+
this.keep(followChapters(player.video, tick));
|
|
276
|
+
this.listen(player, ["sourcechange"], () => {
|
|
277
|
+
this.leave();
|
|
278
|
+
this.render();
|
|
279
|
+
});
|
|
280
|
+
this.render();
|
|
281
|
+
}
|
|
282
|
+
detach(player) {
|
|
283
|
+
cancelAnimationFrame(this.frame);
|
|
284
|
+
this.frame = 0;
|
|
285
|
+
this.pending = null;
|
|
286
|
+
this.leave();
|
|
287
|
+
player.removeAttribute("live");
|
|
288
|
+
player.removeAttribute("seekable");
|
|
289
|
+
}
|
|
290
|
+
render() {
|
|
291
|
+
var _this$getAttribute3;
|
|
292
|
+
const player = this.player;
|
|
293
|
+
if (player === null) return;
|
|
294
|
+
const video = player.video;
|
|
295
|
+
const engine = player.engine;
|
|
296
|
+
const api = live(engine);
|
|
297
|
+
const on = api !== void 0;
|
|
298
|
+
this.range = span(video, engine);
|
|
299
|
+
this.list = chapters(video);
|
|
300
|
+
this.bar.label((_this$getAttribute3 = this.getAttribute("label")) !== null && _this$getAttribute3 !== void 0 ? _this$getAttribute3 : "Seek");
|
|
301
|
+
this.bar.range(this.range.start, this.range.end);
|
|
302
|
+
this.paintBuffered(video);
|
|
303
|
+
this.paintChapters();
|
|
304
|
+
this.edge.hidden = !on;
|
|
305
|
+
if (api !== void 0 && api.edge !== null) this.edge.style.left = percent(fraction(api.edge, this.range));
|
|
306
|
+
const seekable = !on || this.worthSeeking();
|
|
307
|
+
this.hidden = !seekable;
|
|
308
|
+
player.toggleAttribute("live", on);
|
|
309
|
+
player.toggleAttribute("seekable", seekable);
|
|
310
|
+
if (!this.bar.dragging()) this.bar.set(video.currentTime, this.say(video.currentTime));
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
//#endregion
|
|
314
|
+
export { MbxSeekBar };
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
//#region src/elements/shared.ts
|
|
2
|
+
/**
|
|
3
|
+
* The style every button control shares. Each element carries its own
|
|
4
|
+
* copy in its shadow root, so the rules are short and the tokens come
|
|
5
|
+
* through the `--mbx-*` custom properties the player sets, which inherit
|
|
6
|
+
* through light DOM into every control.
|
|
7
|
+
*
|
|
8
|
+
* Nothing carries `!important`: a page's `::part()` rule must win.
|
|
9
|
+
*/
|
|
10
|
+
const BUTTON_STYLE = `
|
|
11
|
+
:host { display: inline-flex; }
|
|
12
|
+
:host([hidden]) { display: none; }
|
|
13
|
+
[part~="button"] {
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
flex: none;
|
|
18
|
+
width: 40px;
|
|
19
|
+
height: 40px;
|
|
20
|
+
padding: 0;
|
|
21
|
+
font: inherit;
|
|
22
|
+
color: inherit;
|
|
23
|
+
background: transparent;
|
|
24
|
+
border: 0;
|
|
25
|
+
border-radius: var(--mbx-radius);
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
opacity: 0.9;
|
|
28
|
+
}
|
|
29
|
+
[part~="button"]:hover { opacity: 1; }
|
|
30
|
+
[part~="button"]:focus-visible { outline: 2px solid var(--mbx-accent); outline-offset: -2px; }
|
|
31
|
+
[part~="icon"], ::slotted(*) { width: 1.75em; height: 1.75em; fill: currentColor; }
|
|
32
|
+
slot[hidden] { display: none; }
|
|
33
|
+
`;
|
|
34
|
+
/** The style of a slider: the rail, the track with its fill, and the thumb. */
|
|
35
|
+
const SLIDER_STYLE = `
|
|
36
|
+
:host { display: block; }
|
|
37
|
+
:host([hidden]) { display: none; }
|
|
38
|
+
[part~="slider"] {
|
|
39
|
+
position: relative;
|
|
40
|
+
height: 40px;
|
|
41
|
+
border-radius: var(--mbx-radius);
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
touch-action: none;
|
|
44
|
+
}
|
|
45
|
+
[part~="slider"]:focus-visible { outline: 2px solid var(--mbx-accent); outline-offset: -2px; }
|
|
46
|
+
[part~="rail"] { position: absolute; top: 0; bottom: 0; left: 8px; right: 8px; }
|
|
47
|
+
[part~="track"] {
|
|
48
|
+
position: absolute;
|
|
49
|
+
top: 50%;
|
|
50
|
+
left: 0;
|
|
51
|
+
right: 0;
|
|
52
|
+
height: 4px;
|
|
53
|
+
transform: translateY(-50%);
|
|
54
|
+
background: rgba(255, 255, 255, 0.35);
|
|
55
|
+
border-radius: 2px;
|
|
56
|
+
overflow: hidden;
|
|
57
|
+
}
|
|
58
|
+
[part~="fill"] { position: absolute; top: 0; bottom: 0; left: 0; background: var(--mbx-accent); }
|
|
59
|
+
[part~="thumb"] {
|
|
60
|
+
position: absolute;
|
|
61
|
+
top: 50%;
|
|
62
|
+
width: 12px;
|
|
63
|
+
height: 12px;
|
|
64
|
+
margin: -6px 0 0 -6px;
|
|
65
|
+
border-radius: 50%;
|
|
66
|
+
background: var(--mbx-text);
|
|
67
|
+
pointer-events: none;
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
70
|
+
/** A non-negative number from an attribute, else the default. */
|
|
71
|
+
function number(node, name, fallback) {
|
|
72
|
+
const raw = node.getAttribute(name);
|
|
73
|
+
const value = raw === null ? NaN : Number(raw);
|
|
74
|
+
return Number.isFinite(value) && value >= 0 ? value : fallback;
|
|
75
|
+
}
|
|
76
|
+
/** The style of a menu: the button from BUTTON_STYLE, and the popup above it with its items. */
|
|
77
|
+
const MENU_STYLE = `${BUTTON_STYLE}
|
|
78
|
+
:host { position: relative; }
|
|
79
|
+
[part~="popup"] {
|
|
80
|
+
position: absolute;
|
|
81
|
+
right: 0;
|
|
82
|
+
bottom: 100%;
|
|
83
|
+
margin-bottom: 8px;
|
|
84
|
+
min-width: 160px;
|
|
85
|
+
padding: 6px;
|
|
86
|
+
display: flex;
|
|
87
|
+
flex-direction: column;
|
|
88
|
+
overflow-y: auto;
|
|
89
|
+
overscroll-behavior: contain;
|
|
90
|
+
background: rgba(16, 17, 20, 0.95);
|
|
91
|
+
border-radius: var(--mbx-radius);
|
|
92
|
+
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
|
|
93
|
+
font-size: 14px;
|
|
94
|
+
}
|
|
95
|
+
[part~="popup"][hidden] { display: none; }
|
|
96
|
+
[part~="section"] { display: flex; flex-direction: column; }
|
|
97
|
+
[part~="section"] + [part~="section"] { margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(255, 255, 255, 0.12); }
|
|
98
|
+
[part~="section-label"] { padding: 4px 12px 2px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--mbx-muted); }
|
|
99
|
+
[part~="item"] {
|
|
100
|
+
display: flex;
|
|
101
|
+
align-items: center;
|
|
102
|
+
gap: 12px;
|
|
103
|
+
width: 100%;
|
|
104
|
+
padding: 8px 12px 8px 28px;
|
|
105
|
+
font: inherit;
|
|
106
|
+
color: inherit;
|
|
107
|
+
text-align: left;
|
|
108
|
+
white-space: nowrap;
|
|
109
|
+
background: transparent;
|
|
110
|
+
border: 0;
|
|
111
|
+
border-radius: var(--mbx-radius);
|
|
112
|
+
cursor: pointer;
|
|
113
|
+
}
|
|
114
|
+
[part~="item"]:hover { background: rgba(255, 255, 255, 0.12); }
|
|
115
|
+
[part~="item-detail"] { margin-left: auto; color: var(--mbx-muted); font-variant-numeric: tabular-nums; }
|
|
116
|
+
[part~="item"]:focus-visible { outline: 2px solid var(--mbx-accent); outline-offset: -2px; }
|
|
117
|
+
[part~="page-item"] { position: relative; padding-right: 28px; }
|
|
118
|
+
[part~="page-item"]::after { content: ""; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px; margin-top: -4px; border: solid currentColor; border-width: 1.5px 1.5px 0 0; transform: rotate(45deg); opacity: 0.7; }
|
|
119
|
+
[part~="back-item"] { position: relative; font-weight: 600; border-bottom: 1px solid rgba(255, 255, 255, 0.12); border-radius: 0; margin-bottom: 6px; }
|
|
120
|
+
[part~="back-item"]::before { content: ""; position: absolute; left: 12px; top: 50%; width: 7px; height: 7px; margin-top: -4px; border: solid currentColor; border-width: 1.5px 0 0 1.5px; transform: rotate(-45deg); opacity: 0.7; }
|
|
121
|
+
[part~="checked"] { position: relative; }
|
|
122
|
+
[part~="checked"]::before { content: ""; position: absolute; left: 12px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--mbx-accent); }
|
|
123
|
+
`;
|
|
124
|
+
/** Puts a control in the bar's seek row when it is in a bar, unless the page wrote a `slot` of its own. */
|
|
125
|
+
function seekRow(node) {
|
|
126
|
+
var _node$parentElement;
|
|
127
|
+
if (((_node$parentElement = node.parentElement) === null || _node$parentElement === void 0 ? void 0 : _node$parentElement.localName) === "mbx-control-bar" && !node.hasAttribute("slot")) node.slot = "seek";
|
|
128
|
+
}
|
|
129
|
+
/** A `<style>` with `text`, for a shadow root. */
|
|
130
|
+
function style(text) {
|
|
131
|
+
const node = document.createElement("style");
|
|
132
|
+
node.textContent = text;
|
|
133
|
+
return node;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* A named slot per state with the default glyph as its fallback, so a page
|
|
137
|
+
* drops its own SVG into `slot="icon-<state>"` and the button keeps the
|
|
138
|
+
* name. Returns the slots by state; `show` hides all but one.
|
|
139
|
+
*/
|
|
140
|
+
function iconSlots(states, fallback) {
|
|
141
|
+
const out = {};
|
|
142
|
+
for (const state of states) {
|
|
143
|
+
const slot = document.createElement("slot");
|
|
144
|
+
slot.name = `icon-${state}`;
|
|
145
|
+
slot.append(fallback(state));
|
|
146
|
+
slot.hidden = true;
|
|
147
|
+
out[state] = slot;
|
|
148
|
+
}
|
|
149
|
+
return out;
|
|
150
|
+
}
|
|
151
|
+
function show(slots, state) {
|
|
152
|
+
for (const key of Object.keys(slots)) slots[key].hidden = key !== state;
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
155
|
+
export { BUTTON_STYLE, MENU_STYLE, SLIDER_STYLE, iconSlots, number, seekRow, show, style };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { icon } from "../controls/icons.js";
|
|
2
|
+
import { fill } from "../labels.js";
|
|
3
|
+
import { Component } from "./component.js";
|
|
4
|
+
import { BUTTON_STYLE, style } from "./shared.js";
|
|
5
|
+
//#region src/elements/skip-button.ts
|
|
6
|
+
const SECONDS = 10;
|
|
7
|
+
/** The glyph for a skip amount: the set draws 10 and 30, and a plain arrow says the rest. */
|
|
8
|
+
function glyphFor(back, amount) {
|
|
9
|
+
const side = back ? "seek-backward" : "seek-forward";
|
|
10
|
+
if (amount === 10 || amount === 30) return `${side}-${amount}`;
|
|
11
|
+
return side;
|
|
12
|
+
}
|
|
13
|
+
var MbxSkipButton = class extends Component {
|
|
14
|
+
static get observedAttributes() {
|
|
15
|
+
return ["seconds", "label"];
|
|
16
|
+
}
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
const root = this.attachShadow({ mode: "open" });
|
|
20
|
+
this.button = document.createElement("button");
|
|
21
|
+
this.button.type = "button";
|
|
22
|
+
this.button.setAttribute("part", "button");
|
|
23
|
+
this.glyph = document.createElement("slot");
|
|
24
|
+
this.glyph.name = "icon";
|
|
25
|
+
this.button.append(this.glyph);
|
|
26
|
+
this.button.addEventListener("click", () => {
|
|
27
|
+
this.skip();
|
|
28
|
+
});
|
|
29
|
+
root.append(style(BUTTON_STYLE), this.button);
|
|
30
|
+
}
|
|
31
|
+
/** The amount, signed. A value that is not a number is the default. */
|
|
32
|
+
seconds() {
|
|
33
|
+
var _this$getAttribute;
|
|
34
|
+
const value = Number((_this$getAttribute = this.getAttribute("seconds")) !== null && _this$getAttribute !== void 0 ? _this$getAttribute : SECONDS);
|
|
35
|
+
return Number.isFinite(value) ? value : SECONDS;
|
|
36
|
+
}
|
|
37
|
+
skip() {
|
|
38
|
+
var _this$player;
|
|
39
|
+
const video = (_this$player = this.player) === null || _this$player === void 0 ? void 0 : _this$player.video;
|
|
40
|
+
if (video === void 0) return;
|
|
41
|
+
const ranges = video.seekable;
|
|
42
|
+
const end = Number.isFinite(video.duration) ? video.duration : ranges.length > 0 ? ranges.end(ranges.length - 1) : video.currentTime;
|
|
43
|
+
video.currentTime = Math.min(end, Math.max(0, video.currentTime + this.seconds()));
|
|
44
|
+
}
|
|
45
|
+
attach(_player) {
|
|
46
|
+
this.render();
|
|
47
|
+
}
|
|
48
|
+
render() {
|
|
49
|
+
var _this$getAttribute2;
|
|
50
|
+
const seconds = this.seconds();
|
|
51
|
+
const back = seconds < 0;
|
|
52
|
+
const amount = Math.abs(seconds);
|
|
53
|
+
this.glyph.replaceChildren(icon(glyphFor(back, amount)));
|
|
54
|
+
const template = (_this$getAttribute2 = this.getAttribute("label")) !== null && _this$getAttribute2 !== void 0 ? _this$getAttribute2 : back ? "Back {seconds} seconds" : "Forward {seconds} seconds";
|
|
55
|
+
this.button.setAttribute("aria-label", fill(template, { seconds: amount }));
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
//#endregion
|
|
59
|
+
export { MbxSkipButton };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { style } from "./shared.js";
|
|
2
|
+
//#region src/elements/spacer.ts
|
|
3
|
+
/** <mbx-spacer>: takes the room in a row, so what follows sits at the far end. */
|
|
4
|
+
var MbxSpacer = class extends HTMLElement {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
this.attachShadow({ mode: "open" }).append(style(":host { display: block; flex: 1 1 auto; }"));
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { MbxSpacer };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { show } from "./shared.js";
|
|
2
|
+
import { MenuElement, single } from "./menu-element.js";
|
|
3
|
+
//#region src/elements/speed-menu.ts
|
|
4
|
+
const RATES = [
|
|
5
|
+
.5,
|
|
6
|
+
.75,
|
|
7
|
+
1,
|
|
8
|
+
1.25,
|
|
9
|
+
1.5,
|
|
10
|
+
2
|
|
11
|
+
];
|
|
12
|
+
var MbxSpeedMenu = class extends MenuElement {
|
|
13
|
+
static get observedAttributes() {
|
|
14
|
+
return [
|
|
15
|
+
"rates",
|
|
16
|
+
"label",
|
|
17
|
+
"label-normal",
|
|
18
|
+
"label-back"
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...single("playback-speed"));
|
|
23
|
+
show(this.slots, "default");
|
|
24
|
+
}
|
|
25
|
+
name() {
|
|
26
|
+
return "Playback speed";
|
|
27
|
+
}
|
|
28
|
+
rates() {
|
|
29
|
+
const raw = this.getAttribute("rates");
|
|
30
|
+
if (raw === null) return RATES;
|
|
31
|
+
const out = raw.split(/\s+/).map(Number).filter((rate) => Number.isFinite(rate) && rate > 0);
|
|
32
|
+
return out.length === 0 ? RATES : out;
|
|
33
|
+
}
|
|
34
|
+
attach(player) {
|
|
35
|
+
this.listen(player.video, ["ratechange"], () => {
|
|
36
|
+
this.render();
|
|
37
|
+
});
|
|
38
|
+
this.render();
|
|
39
|
+
}
|
|
40
|
+
render() {
|
|
41
|
+
var _this$player, _this$getAttribute;
|
|
42
|
+
super.render();
|
|
43
|
+
const video = (_this$player = this.player) === null || _this$player === void 0 ? void 0 : _this$player.video;
|
|
44
|
+
if (video === void 0) return;
|
|
45
|
+
const normal = (_this$getAttribute = this.getAttribute("label-normal")) !== null && _this$getAttribute !== void 0 ? _this$getAttribute : "Normal";
|
|
46
|
+
const items = this.rates().map((rate) => [String(rate), rate === 1 ? normal : `${rate}×`]);
|
|
47
|
+
const current = String(video.playbackRate);
|
|
48
|
+
if (!items.some(([id]) => id === current)) items.push([current, `${current}×`]);
|
|
49
|
+
this.menu.fill([{
|
|
50
|
+
name: "rate",
|
|
51
|
+
items,
|
|
52
|
+
value: current,
|
|
53
|
+
onSelect: (value) => {
|
|
54
|
+
video.playbackRate = Number(value);
|
|
55
|
+
}
|
|
56
|
+
}]);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
//#endregion
|
|
60
|
+
export { MbxSpeedMenu };
|