@mattebox/player 0.12.0 → 0.13.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/dist/cdn/mattebox-player.min.js +3 -3
- package/dist/controls/breaks.d.ts +24 -0
- package/dist/controls/breaks.d.ts.map +1 -0
- package/dist/controls/breaks.js +20 -0
- package/dist/controls/breaks.js.map +1 -0
- package/dist/element-entry.d.ts +1 -1
- package/dist/element-entry.d.ts.map +1 -1
- package/dist/element-entry.js.map +1 -1
- package/dist/element.d.ts +46 -1
- package/dist/element.d.ts.map +1 -1
- package/dist/element.js +89 -6
- package/dist/element.js.map +1 -1
- package/dist/elements/marker-button.d.ts +1 -0
- package/dist/elements/marker-button.d.ts.map +1 -1
- package/dist/elements/marker-button.js +12 -8
- package/dist/elements/marker-button.js.map +1 -1
- package/dist/elements/seek-bar.d.ts +4 -0
- package/dist/elements/seek-bar.d.ts.map +1 -1
- package/dist/elements/seek-bar.js +19 -3
- package/dist/elements/seek-bar.js.map +1 -1
- package/dist/es2015/controls/breaks.js +18 -0
- package/dist/es2015/element.js +160 -66
- package/dist/es2015/elements/marker-button.js +12 -8
- package/dist/es2015/elements/seek-bar.js +25 -7
- package/dist/host.d.ts +31 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/element.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.js","names":[],"sources":["../src/element.ts"],"sourcesContent":["/**\n * <mattebox-player>: a real <video> as a light-DOM child, so the integrator\n * can reach it, and the error surface in shadow DOM. The element never\n * forwards or wraps a media element member: play, pause, seek, volume and\n * the rest live on the video, where the browser, Picture-in-Picture and the\n * OS media session already find them.\n *\n * The controls are elements the page places inside, beside the video, and\n * the stage slots them over the picture. The element appends none of its\n * own: the composition is the page's in every mode, and `none` hides every\n * child but the video. The element reflects the video's state as\n * attributes on itself, `paused`, `playing`, `ended`, `muted`, `audio`,\n * `started` and `waiting`, for the page's stylesheet and the controls\n * alike.\n *\n * No class fields, `#private` or otherwise: the ES2015 build would lower\n * them into runtime helpers, and the emit check bans helpers. Statics are\n * getters and instance state is declared, then assigned in the constructor.\n */\n\nimport type {\n Connector,\n Handler,\n Player,\n PlayerError,\n Programme,\n ProgrammeSource,\n Session,\n Source,\n SourceVideoTrack,\n} from '@mattebox/player-core';\nimport {\n createPlayer,\n inferType,\n matteboxHandler,\n nativeHandler,\n preferNativeHls,\n} from '@mattebox/player-core';\nimport type { KernelConfig, Mattebox, Stage } from 'mattebox';\nimport type { AttachEmeOptions } from 'mattebox/eme';\nimport type { Announcer } from './announcer.js';\nimport { announcer } from './announcer.js';\nimport type { Marker, Markers } from './controls/markers.js';\nimport { createMarkers } from './controls/markers.js';\nimport { languageName } from './controls/track-names.js';\nimport type { Block, PlayerHost } from './host.js';\nimport type { LocaleSource } from './locales.js';\nimport { addLocale, load, onLocales, registered, wordsNow } from './locales.js';\nimport type { Messages, Words } from './messages.js';\nimport { namespaces } from './namespaces.js';\nimport { drmGuard, resolvePreset } from './presets.js';\nimport { STYLE } from './style.js';\nimport type { ErrorSurface } from './surface.js';\nimport { errorSurface } from './surface.js';\nimport { ERROR_SCREEN, PLAYER } from './tags.js';\nimport { textIn } from './text.js';\nimport type { Tracker, TrackerRunner, Trackers } from './trackers.js';\nimport { createTrackers } from './trackers.js';\nimport type { Chosen } from './video-sources.js';\nimport {\n chosen,\n holdFrame,\n markupVideoTracks,\n onNextFrame,\n restore,\n resume,\n versionSource,\n} from './video-sources.js';\n\n/**\n * `off` keeps HLS on the engine in Safari. Anything else lets Safari play\n * HLS itself: FairPlay, AirPlay, Low-Latency HLS and the platform's\n * fullscreen then work as Apple built them. Changing it reloads.\n */\nconst NATIVE_HLS = 'native-hls';\n\n/** Attributes forwarded onto the video as attributes, never as properties. */\nconst FORWARDED = ['autoplay', 'muted', 'poster', 'crossorigin'];\n\nconst LICENSE_URL = 'license-url';\n\n/** The language the page chose, over the nearest `lang`. */\nconst LANGUAGE = 'language';\n\n/** Carried through a switch: the play state from before it, `playing` or `paused`. */\nconst SWITCHING = 'switching';\n\n/** Whether the browser has EME, so a source may bring DRM. */\nfunction emeAvailable(): boolean {\n return drmGuard().without === undefined;\n}\n\n/** `source` without its DRM, for a browser without EME. */\nfunction withoutDrm({ url, type, videoTracks }: Source): Source {\n return {\n url,\n ...(type === undefined ? {} : { type }),\n ...(videoTracks === undefined ? {} : { videoTracks }),\n };\n}\nconst CERTIFICATE_URL = 'certificate-url';\n\n/** Everything else the element watches. Changing any of them reloads. */\nconst OWN = ['src', 'type', 'preset', LICENSE_URL, CERTIFICATE_URL, 'thumbnails', NATIVE_HLS];\n\n/**\n * The chapters file URL. A session with the engine's `chapters` namespace\n * loads it there: through the engine's transport, so request hooks apply,\n * and in every format the engine reads. Any other session gets a\n * `<track kind=\"chapters\">` on the video, hidden so its cues load and\n * nothing is drawn. The seek bar and the chapters menu read either.\n * Changing it never reloads the source.\n */\nconst CHAPTERS = 'chapters';\n\n/**\n * The one attribute whose meaning the element owns: `native` keeps the\n * browser's controls on the video, `custom` swaps them for the controls the\n * page placed inside, `none` takes the browser's off and hides every child\n * but the video. Anything else is `native`. Changing it never touches the\n * session.\n */\nconst CONTROLS = 'controls';\n\n/**\n * Inline playback, on until the page writes `playsinline=\"false\"`, the way\n * `spellcheck` and `draggable` are on until told otherwise. An iPhone takes\n * a video without `playsinline` to its own fullscreen on play, where no\n * control the page placed shows. Changing it never reloads.\n */\nconst PLAYSINLINE = 'playsinline';\n\n/**\n * The size tier the controls draw for: `compact` on a small player, such\n * as a phone held upright, `wide` on a large one, such as a TV or\n * fullscreen, and `regular` between. The element measures itself and sets\n * the attribute, so a stylesheet matches `mattebox-player[layout=\"compact\"]`.\n * A page that writes one of the three values fixes it, and removing the\n * attribute hands it back. The player's own box decides, not the screen:\n * a small embed on a desktop is compact, and a phone in fullscreen is not.\n */\nconst LAYOUT = 'layout';\nconst LAYOUTS = ['compact', 'regular', 'wide'];\n/** Under either, the player is compact. */\nconst COMPACT_WIDTH = 480;\nconst COMPACT_HEIGHT = 320;\n/** From both, the player is wide. */\nconst WIDE_WIDTH = 1280;\nconst WIDE_HEIGHT = 700;\n\n/** The video's state, as attributes on the element, read on the events the video fires for it. */\nconst STATE_EVENTS = [\n 'play',\n 'pause',\n 'ended',\n // A seek back from the end leaves `ended` with no play, pause or ended event.\n 'seeked',\n 'emptied',\n 'volumechange',\n 'loadedmetadata',\n 'resize',\n 'playing',\n 'waiting',\n 'canplay',\n];\n\n/**\n * How long the video waits for data before the live region says so. A\n * seek within the buffer waits for less, and saying it would only be noise.\n */\nconst LOADING_MS = 1000;\n\n/** A track's name for the live region: its name in the stream, else its language's in `locale`. */\nfunction trackName(name: string | undefined, lang: string | undefined, locale: string): string {\n return name || (lang && (languageName(lang, locale || undefined) ?? lang)) || '';\n}\n\n/** The stages that register a key system, which a native session's DRM offers. */\nconst KEY_SYSTEMS = ['eme-fairplay', 'eme-cenc'];\n\n/** Every stage the engine ships. A narrower preset is optimization. */\nconst DEFAULT_PRESET = 'full';\n\n/**\n * What the element dispatches. `error` is also a standard DOM event name, so\n * without these overloads a listener on it is typed as `ErrorEvent` and the\n * payload needs a double cast. They are declarations only: no runtime bytes.\n */\nexport interface MatteboxPlayerEventMap {\n sourcechange: CustomEvent<Session | null>;\n /** The size tier changed: `compact`, `regular` or `wide`. */\n layoutchange: CustomEvent<string>;\n error: CustomEvent<PlayerError>;\n /** The markers changed: set by the page, or cleared by a new source. */\n markerschange: CustomEvent<readonly Marker[]>;\n /** Playback reached a blocked range and moved past it. */\n blocked: CustomEvent<Marker>;\n /** The page called `block()` or `unblock()`, or a new source cleared the block: the block, or null. */\n blockchange: CustomEvent<Block | null>;\n /** A load resolved what it plays, before the session: the programme, or null at unload. */\n programmechange: CustomEvent<Programme | null>;\n /** A tracker was added, removed, started or stopped: the trackers. */\n trackerschange: CustomEvent<readonly Tracker[]>;\n}\n\nexport interface MatteboxPlayerElement {\n addEventListener<K extends keyof MatteboxPlayerEventMap>(\n type: K,\n listener: (this: MatteboxPlayerElement, event: MatteboxPlayerEventMap[K]) => void,\n options?: boolean | AddEventListenerOptions,\n ): void;\n addEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ): void;\n removeEventListener<K extends keyof MatteboxPlayerEventMap>(\n type: K,\n listener: (this: MatteboxPlayerElement, event: MatteboxPlayerEventMap[K]) => void,\n options?: boolean | EventListenerOptions,\n ): void;\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions,\n ): void;\n}\n\nexport interface MatteboxPlayerOptions {\n /** The whole chain, in order. Takes precedence over `stages` and the `preset` attribute. */\n readonly handlers?: readonly Handler[];\n /** Stages for the mattebox handler. Takes precedence over the `preset` attribute. */\n readonly stages?: readonly Stage[];\n /**\n * Kernel tuning for the engines the elements build, `traceCapacity` among\n * it. A page decision, like the stages, so not an attribute. Ignored with\n * `handlers`, which carry their own.\n */\n readonly config?: Partial<KernelConfig>;\n /**\n * DRM for a native session, as `attachEme` from `mattebox/eme` takes it:\n * `keySystems`, `licenseUrl`, `licenseUrls`, `requestHook`. Without\n * `keySystems` the session offers the key-system stages of the engine's\n * stack. The `license-url` attribute overrides `licenseUrl`, and\n * `certificate-url` gives the FairPlay certificate. Ignored\n * with `handlers`, which carry their own.\n */\n readonly drm?: AttachEmeOptions;\n /**\n * One per source type, such as `srgssr/urn`: a source of that type is a\n * programme id, or data you give, which the connector resolves to what\n * plays. Kept with `handlers`.\n */\n readonly connectors?: readonly Connector[];\n}\n\n/**\n * What `define()` recorded, for the elements the parser creates. It is the\n * one value shared across elements, because a page that writes only markup\n * still has to be able to say what the engine carries.\n */\nlet defaults: MatteboxPlayerOptions = {};\n\n/**\n * The interface above merges only `addEventListener` and `removeEventListener`\n * overloads, which the class inherits from HTMLElement. The rule it suppresses\n * guards against properties an interface declares and a constructor never\n * assigns, and there are none.\n */\n// biome-ignore lint/suspicious/noUnsafeDeclarationMerging: method overloads only, no properties\nexport class MatteboxPlayerElement extends HTMLElement implements PlayerHost {\n static get observedAttributes(): readonly string[] {\n return [...FORWARDED, ...OWN, CONTROLS, CHAPTERS, PLAYSINLINE, LAYOUT, LANGUAGE, 'lang'];\n }\n\n /**\n * Registers the words of a language for every player on the page. Each\n * source is a set of words or a function that loads one, which runs only\n * when a player shows that language. Later sources go over earlier ones,\n * so a page changes a shipped word by registering its own after it.\n * Players that show the language take the new words at once.\n */\n static addLocale(language: string, ...sources: readonly LocaleSource[]): void {\n addLocale(language, sources);\n }\n\n /**\n * Registers the element once, and records the stages markup-only pages\n * get. The controls register through their own entries, the package's\n * root entry importing every one; a control connected before its player\n * is defined waits for the definition.\n */\n static define(options?: MatteboxPlayerOptions): void {\n if (options !== undefined) defaults = options;\n if (customElements.get(PLAYER) === undefined) {\n customElements.define(PLAYER, MatteboxPlayerElement);\n }\n }\n\n declare private readonly media: HTMLVideoElement;\n /** Wraps the slot: the picture, and the controls over it or under it. */\n declare private readonly stage: HTMLDivElement;\n /** Whether the element gave itself a tabindex for the bar, to take back with it. */\n declare private focusable: boolean;\n declare private readonly surface: ErrorSurface;\n declare private readonly voice: Announcer;\n /** The words of the language shown, empty for English. */\n declare private words: Words;\n /** The language tag the player resolved, or empty without one. */\n declare private shown: string;\n /** Bumped on every resolution, so a slow loader does not win over a later choice. */\n declare private wordsEpoch: number;\n /** Ends the watch on registrations and on the page's `lang`. */\n declare private unwatch: (() => void) | null;\n /** Runs out when the video has waited `LOADING_MS`. */\n declare private slow: ReturnType<typeof setTimeout> | undefined;\n /** The audio track the live region last saw, so it says only a change. Undefined before the first play. */\n declare private heardAudio: string | undefined;\n /** The subtitle track it last saw: null for off, undefined before the first play. */\n declare private heardText: string | null | undefined;\n /** Stops listening to the current engine's track selection. */\n declare private offTracks: (() => void) | null;\n declare private readonly marks: Markers;\n /** The chapters track element, while the `chapters` attribute names one and the engine takes none. */\n declare private track: HTMLTrackElement | null;\n /** The chapters URL the current session's engine was given, or null. */\n declare private given: string | null;\n /** The sources the page set from script, or null. */\n declare private list: readonly ProgrammeSource[] | null;\n declare private readonly tracking: TrackerRunner;\n /** The sources of the last run, as text: what tells a new `<source>` child from the ones already tried. */\n declare private tried: string;\n /** The options this element was constructed with, or null for the ones `define()` recorded. */\n declare private readonly own: MatteboxPlayerOptions | null;\n declare private core: Player | null;\n declare private current: Session | null;\n declare private failure: PlayerError | null;\n /** What `block()` set, or null. */\n declare private stop: Block | null;\n /** Whether an attribute change is the element's own reflection, which must not write back to the video. */\n declare private reflecting: boolean;\n /** Watches the element's box for `layout`, while connected. */\n declare private sizes: ResizeObserver | null;\n /** Whether the page wrote `layout`, so the element leaves it alone. */\n declare private fixed: boolean;\n /** The video has played once since its source was set: `started`, which tells a first play from a pause. */\n declare private started: boolean;\n /** The video waits for data: `waiting`, set on `waiting`, cleared once it can play. */\n declare private waiting: boolean;\n declare private offs: Array<() => void>;\n /** Everything the element does to the player runs here, so it runs in order. */\n declare private queue: Promise<void>;\n /** Whether a run is queued and not yet started, so a burst of changes loads once. */\n declare private pending: boolean;\n /** The source the versions of `videoSources` belong to: the one that played before a switch. */\n declare private original: Source | null;\n /** The version that plays, or null for the programme itself. */\n declare private version: SourceVideoTrack | null;\n /** True while a version loads, so its `sourcechange` keeps the programme. */\n declare private switching: boolean;\n /** The source `switchSource` loaded, which a retry loads again, or null. */\n declare private switched: Source | null;\n /** Ends the hold of a switch: the poster and `switching` go back. Null without one. */\n declare private held: (() => void) | null;\n\n constructor(options?: MatteboxPlayerOptions) {\n super();\n this.own = options ?? null;\n this.focusable = false;\n this.track = null;\n this.given = null;\n this.list = null;\n this.tried = '';\n this.core = null;\n this.current = null;\n this.failure = null;\n this.stop = null;\n this.reflecting = false;\n this.sizes = null;\n this.fixed = false;\n this.started = false;\n this.waiting = false;\n this.offs = [];\n this.queue = Promise.resolve();\n this.pending = false;\n this.original = null;\n this.version = null;\n this.switching = false;\n this.switched = null;\n this.held = null;\n this.words = {};\n this.shown = '';\n this.wordsEpoch = 0;\n this.unwatch = null;\n this.slow = undefined;\n this.heardAudio = undefined;\n this.heardText = undefined;\n this.offTracks = null;\n\n this.media = document.createElement('video');\n // Native until the `controls` attribute says otherwise, which arrives\n // through attributeChangedCallback: a constructor must not read attributes.\n this.media.controls = true;\n // Inline is the default, and the player's own attribute has not arrived\n // yet. Set as an attribute: not every browser has the `playsInline`\n // property. The fullscreen button still reaches the iPhone's fullscreen,\n // through `webkitEnterFullscreen`.\n this.media.setAttribute(PLAYSINLINE, '');\n for (const name of STATE_EVENTS) {\n this.media.addEventListener(name, () => {\n const was = this.waiting;\n this.note(name);\n this.reflect();\n this.tell(name, was);\n });\n }\n // A native session's tracks; an engine session's are on `tracks:selected`.\n const lists = this.media as { audioTracks?: EventTarget; textTracks: EventTarget };\n for (const list of [lists.audioTracks, lists.textTracks]) {\n list?.addEventListener('change', () => {\n this.tracks();\n });\n }\n // An error over a picture that then plays is wrong by definition.\n this.media.addEventListener('playing', () => {\n this.failure = null;\n this.reflect();\n });\n this.marks = createMarkers(this.media, (name, detail) => this.emit(name, detail));\n this.tracking = createTrackers(this, () => this.emit('trackerschange', this.tracking.list));\n this.stage = document.createElement('div');\n this.stage.setAttribute('part', 'stage');\n const slot = document.createElement('slot');\n // The parser connects the element before its children exist, so the\n // first run finds no `<source>`. A video starts its selection when a\n // `<source>` arrives and nothing is loaded, and so does this.\n slot.addEventListener('slotchange', () => {\n if (this.current === null && JSON.stringify(this.wanted()) !== this.tried) this.reload();\n });\n this.stage.append(slot);\n this.surface = errorSurface(\n () => {\n this.retry();\n },\n () => this.words.retry ?? 'Retry',\n );\n\n this.voice = announcer(this, (id) => this.words[id]);\n\n const root = this.attachShadow({ mode: 'open' });\n const style = document.createElement('style');\n style.textContent = STYLE;\n root.append(style, this.stage, this.surface.root, this.voice.root);\n }\n\n /** The media element. Everything the browser already does is here. */\n get video(): HTMLVideoElement {\n return this.media;\n }\n\n /** The ranges the page named in this source: credits to skip, parts that must not play. */\n get markers(): Markers {\n return this.marks;\n }\n\n /**\n * The sources to try in order, set from script. The `src` attribute wins\n * over them, and they win over the `<source>` children. Setting them\n * loads, and null returns to the children.\n */\n get sources(): readonly ProgrammeSource[] | null {\n return this.list;\n }\n\n set sources(value: readonly ProgrammeSource[] | null) {\n this.list = value;\n // Markers and a block belong to a source, as for `src`.\n if (this.marks.list.length > 0) this.marks.set([]);\n this.unblock();\n this.reload();\n }\n\n /**\n * The language the page chose for this player, which wins over the\n * nearest `lang` attribute. Empty follows `lang`. Setting it changes the\n * words of every control at once.\n */\n get language(): string {\n return this.getAttribute(LANGUAGE) ?? '';\n }\n\n set language(value: string) {\n if (value === '') this.removeAttribute(LANGUAGE);\n else this.setAttribute(LANGUAGE, value);\n }\n\n /** The language tag the words come from: `language`, else the nearest `lang`. Empty without either. */\n get locale(): string {\n return this.shown;\n }\n\n /** The word of `id` in the player's language, or undefined, where the control's English applies. */\n message(id: keyof Messages): string | undefined {\n return this.words[id];\n }\n\n /** Follows registrations and the document's `lang` until disconnect. */\n private watchLanguage(): void {\n const off = onLocales(() => {\n this.relocale();\n });\n // The page's language usually sits on <html>; a lang on another\n // ancestor is read at connect, and `language` covers a change there.\n const watch = new MutationObserver(() => {\n this.relocale();\n });\n watch.observe(document.documentElement, { attributes: true, attributeFilter: ['lang'] });\n this.unwatch = () => {\n off();\n watch.disconnect();\n };\n this.relocale();\n }\n\n /** Resolves the language, takes its words, and tells the controls with `localechange`. */\n private relocale(): void {\n const tag = this.getAttribute(LANGUAGE) ?? this.closest('[lang]')?.getAttribute('lang') ?? '';\n const epoch = ++this.wordsEpoch;\n const take = (words: Words): void => {\n if (epoch !== this.wordsEpoch) return;\n this.shown = tag;\n this.words = words;\n this.showBlock();\n this.emit('localechange', tag);\n };\n const key = registered(tag);\n if (key === null) {\n take({});\n return;\n }\n const now = wordsNow(key);\n if (now !== null) {\n take(now);\n return;\n }\n // The words on screen stay until the language arrives; a loader that\n // fails leaves them.\n load(key).then(take, () => undefined);\n }\n\n /**\n * Loads the sources again, in the order a load reads them: the `src`\n * attribute, the `sources` property, then the `<source>` children. The\n * error screens' Retry calls it. On a version of `videoSources`, it\n * loads that version again.\n */\n retry(): void {\n const again =\n this.version === null ? this.switched : versionSource(this.version, emeAvailable());\n if (again === null) this.reload();\n else this.swap(again, null, false, null, false);\n }\n\n /**\n * Loads `source` in place of the one that plays, from the same position\n * and in the same play state, with the same audio and subtitle choice.\n * Use it for the same programme at another URL, such as its HLS and\n * DASH manifests. The last frame and the controls hold until the new\n * load shows a frame there. The markers stay, and the versions are the\n * ones `source` names. A new `src`, `sources` or `<source>` load\n * replaces it.\n */\n switchSource(source: Source): void {\n const media = this.media;\n const at = Number.isFinite(media.duration) ? media.currentTime : null;\n const playing = !media.paused;\n const had = chosen(this.current?.engine ?? null);\n const clean = emeAvailable() ? source : withoutDrm(source);\n const was = this.version;\n this.original = clean;\n this.switched = clean;\n this.version = null;\n if (was !== null) this.emit('videosourcechange', null);\n this.swap(clean, at, playing, had, true);\n }\n\n /** The other versions of the picture the source names at their own URLs, for the video menu. */\n get videoSources(): readonly SourceVideoTrack[] {\n return this.original?.videoTracks ?? [];\n }\n\n /** The version of `videoSources` that plays, or null for the source itself. */\n get videoSource(): SourceVideoTrack | null {\n return this.version;\n }\n\n /**\n * Plays a version of `videoSources`, or the source itself for null, from\n * the same position and in the same play state, with the same audio and\n * subtitle choice. A live source joins the version at its live edge.\n * Fires `videosourcechange`.\n */\n selectVideoSource(track: SourceVideoTrack | null): void {\n const programme = this.original;\n if (programme === null || track === this.version) return;\n if (track !== null && programme.videoTracks?.includes(track) !== true) return;\n const media = this.media;\n const at = Number.isFinite(media.duration) ? media.currentTime : null;\n const playing = !media.paused;\n const had = chosen(this.current?.engine ?? null);\n this.version = track;\n this.emit('videosourcechange', track);\n this.swap(\n track === null ? programme : versionSource(track, emeAvailable()),\n at,\n playing,\n had,\n true,\n );\n }\n\n /**\n * Loads `source` under the programme that plays, and puts the position,\n * play state and tracks back. With `hold`, the last frame stays as the\n * poster and the player carries `switching`, the play state from\n * before, so the controls show that state through the load.\n */\n private swap(\n source: Source,\n at: number | null,\n playing: boolean,\n had: Chosen | null,\n hold: boolean,\n ): void {\n const media = this.media;\n this.held?.();\n let release: (() => void) | null = null;\n if (hold) {\n // Taken now, while the frame of the source that played is still on screen.\n const frame = holdFrame(media);\n const done = (): void => {\n frame?.();\n if (this.held !== done) return;\n this.held = null;\n this.removeAttribute(SWITCHING);\n this.reflect();\n };\n this.held = done;\n this.setAttribute(SWITCHING, playing ? 'playing' : 'paused');\n release = done;\n }\n this.enqueue(async () => {\n const core = await this.ensure();\n this.switching = true;\n try {\n await core.load([source]);\n } catch {\n // Reported on the error event, as for any load.\n release?.();\n return;\n } finally {\n this.switching = false;\n }\n resume(media, at, playing);\n if (release !== null) onNextFrame(media, at, release);\n restore(this.current?.engine ?? null, had);\n });\n }\n\n /** The core, or null until the first source has been set up: resolving a preset is asynchronous. */\n get player(): Player | null {\n return this.core;\n }\n\n /** The engine feeding the video, or null for a native session and before the first load. */\n get engine(): Mattebox | null {\n return this.current?.engine ?? null;\n }\n\n /**\n * The fatal error of the current load, or null once a load starts or\n * playback resumes. The `error` event says when; this says what, for a\n * control that attaches after the event, such as an error screen parsed\n * after a source that failed while the page was still loading.\n */\n get error(): PlayerError | null {\n return this.failure;\n }\n\n /**\n * Shows why the programme does not play, in place of the video, and\n * stops the load: the reason the page's content API gave, such as a\n * geographic or an age restriction. The error screen shows the title,\n * else \"Not available\", and the message, with no retry. Each text can\n * be given by language tag, and follows the player's language. A new\n * `src` or `sources` clears it. Fires `blockchange`.\n */\n block(block: Block): void {\n this.refuse(block);\n this.enqueue(() => this.teardown());\n }\n\n /** Shows the block, for `block()` and for a programme a connector blocked, which loaded nothing. */\n private refuse(block: Block): void {\n this.stop = block;\n this.media.pause();\n clearTimeout(this.slow);\n const [title, message] = this.blockWords(block);\n // An error screen in the player is an alert of its own, read already.\n if (this.querySelector(ERROR_SCREEN) === null) {\n this.voice.tell(message === '' ? title : `${title}. ${message}`);\n }\n this.showBlock();\n this.reflect();\n this.emit('blockchange', block);\n }\n\n /** Removes the block. Nothing plays until a source loads: set one, or call `retry()`. */\n unblock(): void {\n if (this.stop === null) return;\n this.stop = null;\n this.surface.clear();\n this.reflect();\n this.emit('blockchange', null);\n }\n\n /** What `block()` set, or null. */\n get blocked(): Block | null {\n return this.stop;\n }\n\n /**\n * What the current load resolved to: the sources, and what a connector\n * said of the programme. Null before a load and after an unload.\n */\n get programme(): Programme | null {\n return this.core?.programme ?? null;\n }\n\n /**\n * The page's trackers. Each starts at every programme and stops at its\n * end; one added or removed during a programme starts or stops at once.\n */\n get trackers(): Trackers {\n return this.tracking;\n }\n\n /**\n * Applies what the load resolved, before any session: the markers, the\n * poster, the block. The page's own `poster` and markers set after the\n * source win. Then the trackers start on the programme.\n */\n private programmed(programme: Programme | null): void {\n const metadata = programme?.metadata;\n if (metadata?.markers !== undefined) this.marks.set(metadata.markers);\n if (!this.hasAttribute('poster')) {\n if (metadata?.poster === undefined) this.media.removeAttribute('poster');\n else this.media.poster = metadata.poster;\n }\n if (programme?.block !== undefined) this.refuse(programme.block);\n this.emit('programmechange', programme);\n this.tracking.begin(programme);\n }\n\n /** A block's title and message in the player's language: the title defaults to the `blocked` word. */\n private blockWords(block: Block): [string, string] {\n return [\n block.title === undefined\n ? (this.words.blocked ?? 'Not available')\n : textIn(block.title, this.shown),\n block.message === undefined ? '' : textIn(block.message, this.shown),\n ];\n }\n\n /** Puts the block on the row under the video, under native controls. */\n private showBlock(): void {\n if (this.stop === null || this.getAttribute(CONTROLS) === 'custom') return;\n const [title, message] = this.blockWords(this.stop);\n this.surface.inform(title, message);\n }\n\n connectedCallback(): void {\n if (this.media.parentNode !== this) this.append(this.media);\n for (const name of FORWARDED) this.forward(name);\n this.reflect();\n if (typeof ResizeObserver !== 'undefined') {\n this.sizes = new ResizeObserver(() => {\n this.measure();\n });\n this.sizes.observe(this);\n }\n this.measure();\n this.watchLanguage();\n this.reload();\n }\n\n /** Sets `layout` from the element's box, unless the page fixed it. */\n private measure(): void {\n if (this.fixed) return;\n const width = this.clientWidth;\n const height = this.clientHeight;\n // Not laid out yet: no tier until there is a box to judge.\n if (width === 0 || height === 0) return;\n const layout =\n width < COMPACT_WIDTH || height < COMPACT_HEIGHT\n ? 'compact'\n : width >= WIDE_WIDTH && height >= WIDE_HEIGHT\n ? 'wide'\n : 'regular';\n if (this.getAttribute(LAYOUT) === layout) return;\n this.reflecting = true;\n this.setAttribute(LAYOUT, layout);\n this.reflecting = false;\n this.emit('layoutchange', layout);\n }\n\n /** The two states the video does not hold: whether it has played once, and whether it waits for data. */\n private note(event: string): void {\n if (event === 'playing') {\n // The tracks the video starts playing with are what a change is from.\n if (!this.started) this.tracks();\n this.started = true;\n this.waiting = false;\n } else if (event === 'waiting') {\n // Not `stalled`: a paused video with a full buffer fires it too, when\n // nothing more is appended for three seconds. video.js reads `waiting` alone.\n this.waiting = true;\n } else if (event === 'canplay') {\n this.waiting = false;\n } else if (event === 'emptied') {\n // A new source starts over: the title shows again before its first play.\n // A switch is the same programme, so it keeps its start.\n if (this.held === null) this.started = false;\n this.waiting = false;\n this.heardAudio = undefined;\n this.heardText = undefined;\n }\n }\n\n /** Says a play or a pause, and a wait once it has lasted `LOADING_MS`. */\n private tell(event: string, was: boolean): void {\n // The load of a switch pauses and plays the video, and the viewer did neither.\n if (event === 'play' && this.held === null) this.voice.say('playing', 'saidPlaying', 'Playing');\n // The end of the video pauses it too, and that is no pause to say.\n if (event === 'pause' && !this.media.ended && this.held === null) {\n this.voice.say('paused', 'saidPaused', 'Paused');\n }\n if (this.waiting === was) return;\n clearTimeout(this.slow);\n if (this.waiting) {\n this.slow = setTimeout(() => {\n this.voice.say('loading', 'loading', 'Loading');\n }, LOADING_MS);\n }\n }\n\n /**\n * Says a change of the audio or the subtitle track, once the video has\n * played: the tracks a load starts with are no change. A forced track\n * reads as off, as in the subtitles menu.\n */\n private tracks(): void {\n const engine = this.current?.engine ?? null;\n let audio: string;\n let text: string | null;\n if (engine !== null) {\n const sound = engine.tracks.active('audio');\n const words = engine.tracks.active('text');\n audio = sound === null ? '' : trackName(sound.name, sound.lang, this.locale);\n text =\n words === null || words.forced === true\n ? null\n : trackName(words.name, words.lang, this.locale);\n } else {\n const video = this.media as {\n audioTracks?: ArrayLike<{ enabled: boolean; label: string; language: string }>;\n };\n const sound = Array.from(video.audioTracks ?? []).find((track) => track.enabled);\n const words = Array.from(this.media.textTracks).find(\n (track) =>\n (track.kind === 'subtitles' || track.kind === 'captions') && track.mode === 'showing',\n );\n audio = sound === undefined ? '' : trackName(sound.label, sound.language, this.locale);\n text = words === undefined ? null : trackName(words.label, words.language, this.locale);\n }\n const { heardAudio, heardText } = this;\n this.heardAudio = audio;\n this.heardText = text;\n if (!this.started) return;\n if (heardAudio !== undefined && audio !== heardAudio) {\n this.voice.say('audio', 'saidAudio', 'Audio: {track}', audio);\n }\n if (heardText !== undefined && text !== heardText) {\n if (text === null) this.voice.say('subtitles-off', 'saidSubtitlesOff', 'Subtitles off');\n else this.voice.say('subtitles', 'saidSubtitles', 'Subtitles: {track}', text);\n }\n }\n\n /** The video's state on the element, for `mattebox-player[paused]` and the like. */\n private reflect(): void {\n const video = this.media;\n this.reflecting = true;\n // Through a switch, the play state from before it.\n const held = this.getAttribute(SWITCHING);\n const paused = held === null ? video.paused : held === 'paused';\n this.toggleAttribute('paused', paused);\n this.toggleAttribute('playing', !paused);\n this.toggleAttribute('ended', video.ended);\n // `muted` is also forwarded: the page's attribute sets the video, and\n // the video's state sets the attribute. Reflection never forwards, so\n // a read can only ever change the attribute, never the video.\n this.toggleAttribute('muted', video.muted);\n this.toggleAttribute('audio', this.audio());\n this.toggleAttribute('started', this.started);\n this.toggleAttribute('waiting', this.waiting);\n this.toggleAttribute('error', this.failure !== null);\n this.toggleAttribute('blocked', this.stop !== null);\n this.reflecting = false;\n }\n\n /**\n * Whether the source has no picture. Once the metadata is in, the video's\n * size decides: zero by zero is sound alone, and `resize` catches a stream\n * that moves to or from an audio-only rendition. Before that, the type the\n * page wrote or the URL implies is the hint, so an mp3 is `audio` from\n * the start rather than from its metadata.\n */\n private audio(): boolean {\n const video = this.media;\n if (video.readyState >= HTMLMediaElement.HAVE_METADATA) {\n return video.videoWidth === 0 && video.videoHeight === 0;\n }\n const src = this.getAttribute('src');\n const type = this.getAttribute('type') ?? (src === null ? undefined : inferType(src));\n return type?.startsWith('audio/') === true;\n }\n\n disconnectedCallback(): void {\n this.sizes?.disconnect();\n this.sizes = null;\n this.unwatch?.();\n this.unwatch = null;\n // A single-page app must not leave a pipeline attached to a video it\n // navigated away from. Reconnecting loads the `src` again. A move is no\n // removal: as HTML's media element waits for a stable state before it\n // pauses, the teardown waits a microtask and runs only if the element is\n // still out of the document.\n queueMicrotask(() => {\n if (!this.isConnected) this.enqueue(() => this.teardown());\n });\n }\n\n attributeChangedCallback(name: string): void {\n if (name === LANGUAGE || name === 'lang') {\n this.relocale();\n return;\n }\n if (FORWARDED.includes(name)) {\n if (!this.reflecting) this.forward(name);\n return;\n }\n if (name === CONTROLS) {\n this.mode();\n return;\n }\n if (name === CHAPTERS) {\n this.chapters();\n return;\n }\n if (name === LAYOUT) {\n // The element's own write is not the page's.\n if (this.reflecting) return;\n const value = this.getAttribute(LAYOUT);\n this.fixed = value !== null && LAYOUTS.includes(value);\n if (this.fixed) this.emit('layoutchange', value);\n else this.measure();\n return;\n }\n if (name === PLAYSINLINE) {\n // On the video it is a boolean attribute, so off is absent.\n this.media.toggleAttribute(PLAYSINLINE, this.getAttribute(PLAYSINLINE) !== 'false');\n return;\n }\n // The preset decides the chain, so it is the one attribute that rebuilds it.\n if (name === 'preset') this.enqueue(() => this.discard());\n // The source's type is the hint for `audio` until its metadata arrives.\n // Only `audio`: a full reflection here would drop a `muted` the page\n // wrote before its own callback forwards it.\n if (name === 'src' || name === 'type') this.toggleAttribute('audio', this.audio());\n // Markers belong to a source. Cleared here, not on `emptied`, which\n // arrives later and would clear the ones the page sets right after.\n if (name === 'src' && this.marks.list.length > 0) this.marks.set([]);\n if (name === 'src') this.unblock();\n this.reload();\n }\n\n /**\n * Applies the `controls` attribute: the video's own controls and the\n * tabindex. The controls themselves are elements the page placed, and\n * they attach on their own; the element appends none.\n */\n private mode(): void {\n const value = this.getAttribute(CONTROLS);\n const custom = value === 'custom';\n this.media.controls = !custom && value !== 'none';\n // Under custom controls the error screen element carries a fatal error.\n if (custom) this.surface.clear();\n else this.showBlock();\n if (!custom) {\n if (this.focusable) this.removeAttribute('tabindex');\n this.focusable = false;\n } else if (!this.hasAttribute('tabindex')) {\n // A bare video is not focusable, so without this a click on it would\n // leave the shortcuts nowhere to listen. A page that set its own\n // tabindex keeps it.\n this.tabIndex = 0;\n this.focusable = true;\n }\n }\n\n /** Hands the `chapters` attribute to the engine, or keeps a hidden chapters track on the video for it. */\n private chapters(): void {\n const url = this.getAttribute(CHAPTERS);\n const engine = this.current?.engine ?? null;\n const api = engine === null ? undefined : namespaces(engine).chapters;\n if (api !== undefined) {\n this.track?.remove();\n this.track = null;\n if (url === this.given) return;\n this.given = url;\n // An empty list removes the chapters the attribute loaded.\n if (url === null) api.set([]);\n else void api.load(url).catch(() => undefined);\n return;\n }\n if (url === null) {\n this.track?.remove();\n this.track = null;\n return;\n }\n const held = this.track;\n if (held !== null && held.parentNode === this.media && held.getAttribute('src') === url) return;\n // A new element each time: one removed mid-load, as the engine's attach\n // does, stays in its error state, and neither a new `src` nor a second\n // insertion starts it loading again.\n held?.remove();\n const track = document.createElement('track');\n track.kind = 'chapters';\n track.src = url;\n this.track = track;\n this.media.append(track);\n // Set after the insertion: a track element's mode exists once it is in\n // a media element, and `hidden` is what makes its cues load unseen.\n track.track.mode = 'hidden';\n }\n\n private forward(name: string): void {\n const value = this.getAttribute(name);\n if (value === null) this.media.removeAttribute(name);\n else this.media.setAttribute(name, value);\n // A video reads `muted` into its state only when it is created, and this\n // one was created before any attribute reached it. Muted autoplay and\n // the autoplay policy read the state, so the attribute alone would not do.\n if (name === 'muted') this.media.muted = value !== null;\n }\n\n private enqueue(task: () => Promise<void>): void {\n this.queue = this.queue.then(task, task).catch(() => undefined);\n }\n\n /**\n * One run per burst. The parser sets every attribute and then connects the\n * element before any queued task starts, and each of those would load on\n * its own; the flag folds them into the one run that sees the final state.\n */\n private reload(): void {\n if (this.pending) return;\n this.pending = true;\n this.enqueue(() => {\n this.pending = false;\n return this.run();\n });\n }\n\n private emit(name: string, detail: unknown): void {\n this.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true }));\n }\n\n private report(error: PlayerError): void {\n if (error.fatal) {\n this.failure = error;\n clearTimeout(this.slow);\n // An error screen in the player is an alert of its own, read already.\n if (this.querySelector(ERROR_SCREEN) === null) {\n this.voice.say('error', 'playbackFailed', 'Playback failed');\n }\n // Under custom controls the error screen element is the surface, and\n // the element's own row under the video stays quiet.\n if (this.getAttribute(CONTROLS) !== 'custom') this.surface.show(error);\n this.reflect();\n }\n this.emit('error', error);\n }\n\n private async run(): Promise<void> {\n this.unmount();\n if (!this.isConnected) return;\n const sources = this.wanted();\n this.tried = JSON.stringify(sources);\n if (sources.length === 0) return;\n\n const core = await this.ensure();\n this.failure = null;\n this.surface.clear();\n this.reflect();\n\n try {\n await core.load(sources);\n } catch {\n // The core already reported it on the error event, which the surface\n // and the element's own event both carry. Nothing to add here.\n return;\n }\n if (!this.isConnected) await core.unload();\n }\n\n /**\n * What to load, ranked as a video ranks them: the `src` attribute, then\n * the `sources` property, then the `<source>` children in their order.\n * A child carries its own `license-url` and `certificate-url`.\n */\n private wanted(): readonly ProgrammeSource[] {\n // The `<mbx-video-track>` children are versions of the `src` or `<source>` picture.\n const versions = markupVideoTracks(this);\n const withVersions = versions.length === 0 ? {} : { videoTracks: versions };\n const url = this.getAttribute('src');\n if (url !== null) {\n const type = this.getAttribute('type');\n return [{ url, ...(type === null ? {} : { type }), ...withVersions }];\n }\n // A browser without EME gets no DRM stage, and a source must not bring DRM back.\n const eme = emeAvailable();\n if (this.list !== null) {\n return eme\n ? this.list\n : this.list.map((source) => ('url' in source ? withoutDrm(source) : source));\n }\n const found: Source[] = [];\n for (const child of Array.from(this.children)) {\n const src = child.localName === 'source' ? child.getAttribute('src') : null;\n if (src === null) continue;\n const type = child.getAttribute('type');\n const license = child.getAttribute(LICENSE_URL);\n const certificate = child.getAttribute(CERTIFICATE_URL);\n found.push({\n url: src,\n ...(type === null ? {} : { type }),\n ...withVersions,\n ...(!eme || (license === null && certificate === null)\n ? {}\n : {\n drm: {\n ...(license === null ? {} : { licenseUrl: license }),\n ...(certificate === null ? {} : { certificateUrl: certificate }),\n },\n }),\n });\n }\n return found;\n }\n\n /** Sets a session up. It runs for every session, the one that replaces a failed source included. */\n private adopt(session: Session): void {\n this.given = null;\n this.configure(session);\n // A content API's chapters, unless the `chapters` attribute names a file.\n const chapters = this.core?.programme?.metadata?.chapters;\n if (chapters !== undefined && session.engine !== null && this.getAttribute(CHAPTERS) === null) {\n namespaces(session.engine).chapters?.set(chapters);\n }\n // The engine's attach empties the media element to reset its resource\n // selection (`kernel/mse.ts`), and the chapters track goes with the\n // `<source>` children it means. Wanted: the track to survive attach.\n // Had to: put it back once the session is in. The surface that would\n // make it one call: an attach that removes `<source>` children alone.\n // A session with the engine's chapters takes the URL there instead.\n this.chapters();\n }\n\n private async ensure(): Promise<Player> {\n if (this.core !== null) return this.core;\n const connectors = this.options.connectors;\n const core = createPlayer(this.media, {\n handlers: await this.chain(),\n ...(connectors === undefined ? {} : { connectors }),\n });\n this.offs.push(\n core.on('programme', (programme) => {\n this.programmed(programme);\n }),\n core.on('sourcechange', (session) => {\n // Before the event goes out, so a control that reads `engine` on\n // `sourcechange` sees the session the event is about.\n this.current = session;\n // A version loads under the programme it belongs to; any other load is a programme of its own.\n if (!this.switching) {\n const was = this.version;\n this.original = session?.source ?? null;\n this.switched = null;\n this.version = null;\n this.held?.();\n if (was !== null) this.emit('videosourcechange', null);\n }\n this.offTracks?.();\n this.offTracks = session?.engine?.on('tracks:selected', () => this.tracks()) ?? null;\n if (session !== null && this.isConnected) this.adopt(session);\n this.emit('sourcechange', session);\n }),\n core.on('error', (error) => {\n this.report(error);\n }),\n );\n this.core = core;\n return core;\n }\n\n /**\n * Read at each use, not once in the constructor. Importing the package\n * registers the element, and the parser's elements are constructed then,\n * before the page's own `define()` call can run.\n */\n private get options(): MatteboxPlayerOptions {\n return this.own ?? defaults;\n }\n\n private async chain(): Promise<readonly Handler[]> {\n if (this.options.handlers !== undefined) return this.options.handlers;\n const config = this.options.config === undefined ? {} : { config: this.options.config };\n // The stack is read at load time: a preset builds its stages only when asked.\n const native = (stages: () => readonly Stage[]): Handler =>\n nativeHandler({\n // Read on every load, so the attribute applies without a new chain.\n prefer: (source, env) =>\n this.getAttribute(NATIVE_HLS) !== 'off' && preferNativeHls(source, env),\n drm: () => this.drm(stages),\n });\n if (this.options.stages !== undefined) {\n return [\n matteboxHandler({ stages: this.options.stages, ...config }),\n native(() => this.options.stages ?? []),\n ];\n }\n const name = this.getAttribute('preset') ?? DEFAULT_PRESET;\n const preset = await resolvePreset(name);\n if (preset === null) {\n this.report({\n category: 'config',\n code: 'CONFIG_INVALID',\n fatal: true,\n recoverable: false,\n handler: null,\n context: { preset: name },\n });\n return [nativeHandler()];\n }\n return [matteboxHandler({ preset, ...config, ...drmGuard() }), native(() => preset.stages())];\n }\n\n /**\n * The DRM a native session attaches: the page's `drm` option, the\n * key-system stages of the engine's stack, and the `license-url`\n * attribute. None on a browser without EME, as for the engine.\n */\n private drm(stages: () => readonly Stage[]): AttachEmeOptions | undefined {\n if (drmGuard().without !== undefined) return undefined;\n const keySystems = stages().filter((stage) => KEY_SYSTEMS.includes(stage.name));\n const license = this.getAttribute(LICENSE_URL);\n const certificate = this.getAttribute(CERTIFICATE_URL);\n const page = this.options.drm;\n if (keySystems.length === 0 && license === null && page === undefined) return undefined;\n return {\n keySystems,\n ...page,\n ...(license === null ? {} : { licenseUrl: license }),\n ...(certificate === null ? {} : { certificateUrl: certificate }),\n };\n }\n\n /** What the attributes ask of the session's namespaces, once there is one. */\n private configure(session: Session): void {\n const engine = session.engine;\n if (engine === null) return;\n\n const optional = namespaces(engine);\n\n // The attributes are the default. A source's own URL is already on the\n // engine: the handler set it from `source.drm` before the load.\n const own = session.source.drm;\n const license = this.getAttribute(LICENSE_URL);\n // After the session exists, not before: passing a license URL up front\n // means constructing eme-core, and importing a stage to configure it\n // would bundle it.\n if (license !== null && own?.licenseUrl === undefined) optional.drm?.setLicenseUrl(license);\n const certificate = this.getAttribute(CERTIFICATE_URL);\n if (certificate !== null && own?.certificateUrl === undefined) {\n optional.drm?.setCertificateUrl(certificate);\n }\n\n const track = this.getAttribute('thumbnails');\n if (track !== null && optional.thumbnails !== undefined) {\n // Loaded here; drawn by the seek bar's preview under `controls=\"custom\"`.\n // Native controls expose no scrub position to anchor a preview to, so\n // under `native` the track only answers `engine.thumbnails.at(time)` for\n // the app. See docs/guide/03-the-element.md.\n void optional.thumbnails.load(track).catch(() => undefined);\n }\n }\n\n private unmount(): void {\n this.current = null;\n }\n\n private async teardown(): Promise<void> {\n this.unmount();\n if (this.core !== null) await this.core.unload();\n }\n\n /** Drops the player itself, so the next run builds a chain from the new preset. */\n private async discard(): Promise<void> {\n await this.teardown();\n for (const off of this.offs) off();\n this.offs = [];\n this.core = null;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0EA,MAAM,aAAa;;AAGnB,MAAM,YAAY;CAAC;CAAY;CAAS;CAAU;AAAa;AAE/D,MAAM,cAAc;;AAGpB,MAAM,WAAW;;AAGjB,MAAM,YAAY;;AAGlB,SAAS,eAAwB;CAC/B,OAAO,SAAS,CAAC,CAAC,YAAY,KAAA;AAChC;;AAGA,SAAS,WAAW,EAAE,KAAK,MAAM,eAA+B;CAC9D,OAAO;EACL;EACA,GAAI,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE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M,cAAc,KAAK,aAAa,eAAe;EACrD,IAAI,gBAAgB,QAAQ,KAAK,mBAAmB,KAAA,GAClD,SAAS,KAAK,kBAAkB,WAAW;EAG7C,MAAM,QAAQ,KAAK,aAAa,YAAY;EAC5C,IAAI,UAAU,QAAQ,SAAS,eAAe,KAAA,GAK5C,SAAc,WAAW,KAAK,KAAK,CAAC,CAAC,YAAY,KAAA,CAAS;CAE9D;CAEA,UAAwB;EACtB,KAAK,UAAU;CACjB;CAEA,MAAc,WAA0B;EACtC,KAAK,QAAQ;EACb,IAAI,KAAK,SAAS,MAAM,MAAM,KAAK,KAAK,OAAO;CACjD;;CAGA,MAAc,UAAyB;EACrC,MAAM,KAAK,SAAS;EACpB,KAAK,MAAM,OAAO,KAAK,MAAM,IAAI;EACjC,KAAK,OAAO,CAAC;EACb,KAAK,OAAO;CACd;AACF"}
|
|
1
|
+
{"version":3,"file":"element.js","names":[],"sources":["../src/element.ts"],"sourcesContent":["/**\n * <mattebox-player>: a real <video> as a light-DOM child, so the integrator\n * can reach it, and the error surface in shadow DOM. The element never\n * forwards or wraps a media element member: play, pause, seek, volume and\n * the rest live on the video, where the browser, Picture-in-Picture and the\n * OS media session already find them.\n *\n * The controls are elements the page places inside, beside the video, and\n * the stage slots them over the picture. The element appends none of its\n * own: the composition is the page's in every mode, and `none` hides every\n * child but the video. The element reflects the video's state as\n * attributes on itself, `paused`, `playing`, `ended`, `muted`, `audio`,\n * `started` and `waiting`, for the page's stylesheet and the controls\n * alike.\n *\n * No class fields, `#private` or otherwise: the ES2015 build would lower\n * them into runtime helpers, and the emit check bans helpers. Statics are\n * getters and instance state is declared, then assigned in the constructor.\n */\n\nimport type {\n Connector,\n Handler,\n Player,\n PlayerError,\n Programme,\n ProgrammeSource,\n Session,\n Source,\n SourceVideoTrack,\n} from '@mattebox/player-core';\nimport {\n createPlayer,\n inferType,\n matteboxHandler,\n nativeHandler,\n preferNativeHls,\n} from '@mattebox/player-core';\nimport type { KernelConfig, Mattebox, Stage } from 'mattebox';\nimport type { AttachEmeOptions } from 'mattebox/eme';\nimport type { Announcer } from './announcer.js';\nimport { announcer } from './announcer.js';\nimport { type BreakMarks, createBreakMarks } from './controls/breaks.js';\nimport type { Marker, Markers } from './controls/markers.js';\nimport { createMarkers } from './controls/markers.js';\nimport { languageName } from './controls/track-names.js';\nimport type { Block, PlayerAddon, PlayerHost } from './host.js';\nimport type { LocaleSource } from './locales.js';\nimport { addLocale, load, onLocales, registered, wordsNow } from './locales.js';\nimport type { Messages, Words } from './messages.js';\nimport { namespaces } from './namespaces.js';\nimport { drmGuard, resolvePreset } from './presets.js';\nimport { STYLE } from './style.js';\nimport type { ErrorSurface } from './surface.js';\nimport { errorSurface } from './surface.js';\nimport { ERROR_SCREEN, PLAYER } from './tags.js';\nimport { textIn } from './text.js';\nimport type { Tracker, TrackerRunner, Trackers } from './trackers.js';\nimport { createTrackers } from './trackers.js';\nimport type { Chosen } from './video-sources.js';\nimport {\n chosen,\n holdFrame,\n markupVideoTracks,\n onNextFrame,\n restore,\n resume,\n versionSource,\n} from './video-sources.js';\n\n/**\n * `off` keeps HLS on the engine in Safari. Anything else lets Safari play\n * HLS itself: FairPlay, AirPlay, Low-Latency HLS and the platform's\n * fullscreen then work as Apple built them. Changing it reloads.\n */\nconst NATIVE_HLS = 'native-hls';\n\n/** Attributes forwarded onto the video as attributes, never as properties. */\nconst FORWARDED = ['autoplay', 'muted', 'poster', 'crossorigin'];\n\nconst LICENSE_URL = 'license-url';\n\n/** The language the page chose, over the nearest `lang`. */\nconst LANGUAGE = 'language';\n\n/** Carried through a switch: the play state from before it, `playing` or `paused`. */\nconst SWITCHING = 'switching';\n\n/** Whether the browser has EME, so a source may bring DRM. */\nfunction emeAvailable(): boolean {\n return drmGuard().without === undefined;\n}\n\n/** `source` without its DRM, for a browser without EME. */\nfunction withoutDrm({ url, type, videoTracks }: Source): Source {\n return {\n url,\n ...(type === undefined ? {} : { type }),\n ...(videoTracks === undefined ? {} : { videoTracks }),\n };\n}\nconst CERTIFICATE_URL = 'certificate-url';\n\n/** Everything else the element watches. Changing any of them reloads. */\nconst OWN = ['src', 'type', 'preset', LICENSE_URL, CERTIFICATE_URL, 'thumbnails', NATIVE_HLS];\n\n/**\n * The chapters file URL. A session with the engine's `chapters` namespace\n * loads it there: through the engine's transport, so request hooks apply,\n * and in every format the engine reads. Any other session gets a\n * `<track kind=\"chapters\">` on the video, hidden so its cues load and\n * nothing is drawn. The seek bar and the chapters menu read either.\n * Changing it never reloads the source.\n */\nconst CHAPTERS = 'chapters';\n\n/**\n * The one attribute whose meaning the element owns: `native` keeps the\n * browser's controls on the video, `custom` swaps them for the controls the\n * page placed inside, `none` takes the browser's off and hides every child\n * but the video. Anything else is `native`. Changing it never touches the\n * session.\n */\nconst CONTROLS = 'controls';\n\n/**\n * Inline playback, on until the page writes `playsinline=\"false\"`, the way\n * `spellcheck` and `draggable` are on until told otherwise. An iPhone takes\n * a video without `playsinline` to its own fullscreen on play, where no\n * control the page placed shows. Changing it never reloads.\n */\nconst PLAYSINLINE = 'playsinline';\n\n/**\n * The size tier the controls draw for: `compact` on a small player, such\n * as a phone held upright, `wide` on a large one, such as a TV or\n * fullscreen, and `regular` between. The element measures itself and sets\n * the attribute, so a stylesheet matches `mattebox-player[layout=\"compact\"]`.\n * A page that writes one of the three values fixes it, and removing the\n * attribute hands it back. The player's own box decides, not the screen:\n * a small embed on a desktop is compact, and a phone in fullscreen is not.\n */\nconst LAYOUT = 'layout';\nconst LAYOUTS = ['compact', 'regular', 'wide'];\n/** Under either, the player is compact. */\nconst COMPACT_WIDTH = 480;\nconst COMPACT_HEIGHT = 320;\n/** From both, the player is wide. */\nconst WIDE_WIDTH = 1280;\nconst WIDE_HEIGHT = 700;\n\n/** The video's state, as attributes on the element, read on the events the video fires for it. */\nconst STATE_EVENTS = [\n 'play',\n 'pause',\n 'ended',\n // A seek back from the end leaves `ended` with no play, pause or ended event.\n 'seeked',\n 'emptied',\n 'volumechange',\n 'loadedmetadata',\n 'resize',\n 'playing',\n 'waiting',\n 'canplay',\n];\n\n/**\n * How long the video waits for data before the live region says so. A\n * seek within the buffer waits for less, and saying it would only be noise.\n */\nconst LOADING_MS = 1000;\n\n/** A track's name for the live region: its name in the stream, else its language's in `locale`. */\nfunction trackName(name: string | undefined, lang: string | undefined, locale: string): string {\n return name || (lang && (languageName(lang, locale || undefined) ?? lang)) || '';\n}\n\n/** The stages that register a key system, which a native session's DRM offers. */\nconst KEY_SYSTEMS = ['eme-fairplay', 'eme-cenc'];\n\n/** Every stage the engine ships. A narrower preset is optimization. */\nconst DEFAULT_PRESET = 'full';\n\n/**\n * What the element dispatches. `error` is also a standard DOM event name, so\n * without these overloads a listener on it is typed as `ErrorEvent` and the\n * payload needs a double cast. They are declarations only: no runtime bytes.\n */\nexport interface MatteboxPlayerEventMap {\n sourcechange: CustomEvent<Session | null>;\n /** The size tier changed: `compact`, `regular` or `wide`. */\n layoutchange: CustomEvent<string>;\n error: CustomEvent<PlayerError>;\n /** The markers changed: set by the page, or cleared by a new source. */\n markerschange: CustomEvent<readonly Marker[]>;\n /** Playback reached a blocked range and moved past it. */\n blocked: CustomEvent<Marker>;\n /** The page called `block()` or `unblock()`, or a new source cleared the block: the block, or null. */\n blockchange: CustomEvent<Block | null>;\n /** A load resolved what it plays, before the session: the programme, or null at unload. */\n programmechange: CustomEvent<Programme | null>;\n /** A tracker was added, removed, started or stopped: the trackers. */\n trackerschange: CustomEvent<readonly Tracker[]>;\n}\n\nexport interface MatteboxPlayerElement {\n addEventListener<K extends keyof MatteboxPlayerEventMap>(\n type: K,\n listener: (this: MatteboxPlayerElement, event: MatteboxPlayerEventMap[K]) => void,\n options?: boolean | AddEventListenerOptions,\n ): void;\n addEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ): void;\n removeEventListener<K extends keyof MatteboxPlayerEventMap>(\n type: K,\n listener: (this: MatteboxPlayerElement, event: MatteboxPlayerEventMap[K]) => void,\n options?: boolean | EventListenerOptions,\n ): void;\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions,\n ): void;\n}\n\nexport interface MatteboxPlayerOptions {\n /** The whole chain, in order. Takes precedence over `stages` and the `preset` attribute. */\n readonly handlers?: readonly Handler[];\n /** Stages for the mattebox handler. Takes precedence over the `preset` attribute. */\n readonly stages?: readonly Stage[];\n /**\n * Kernel tuning for the engines the elements build, `traceCapacity` among\n * it. A page decision, like the stages, so not an attribute. Ignored with\n * `handlers`, which carry their own.\n */\n readonly config?: Partial<KernelConfig>;\n /**\n * DRM for a native session, as `attachEme` from `mattebox/eme` takes it:\n * `keySystems`, `licenseUrl`, `licenseUrls`, `requestHook`. Without\n * `keySystems` the session offers the key-system stages of the engine's\n * stack. The `license-url` attribute overrides `licenseUrl`, and\n * `certificate-url` gives the FairPlay certificate. Ignored\n * with `handlers`, which carry their own.\n */\n readonly drm?: AttachEmeOptions;\n /**\n * One per source type, such as `srgssr/urn`: a source of that type is a\n * programme id, or data you give, which the connector resolves to what\n * plays. Kept with `handlers`.\n */\n readonly connectors?: readonly Connector[];\n /**\n * Packages that add to every player, such as `ads()` from\n * `@mattebox/player-ads`: their stages join the stack, and each runs on\n * every player that connects. Ignored with `handlers`, apart from what\n * they run on the player.\n */\n readonly addons?: readonly PlayerAddon[];\n}\n\n/**\n * What `define()` recorded, for the elements the parser creates. It is the\n * one value shared across elements, because a page that writes only markup\n * still has to be able to say what the engine carries.\n */\nlet defaults: MatteboxPlayerOptions = {};\n\n/**\n * The interface above merges only `addEventListener` and `removeEventListener`\n * overloads, which the class inherits from HTMLElement. The rule it suppresses\n * guards against properties an interface declares and a constructor never\n * assigns, and there are none.\n */\n// biome-ignore lint/suspicious/noUnsafeDeclarationMerging: method overloads only, no properties\nexport class MatteboxPlayerElement extends HTMLElement implements PlayerHost {\n static get observedAttributes(): readonly string[] {\n return [...FORWARDED, ...OWN, CONTROLS, CHAPTERS, PLAYSINLINE, LAYOUT, LANGUAGE, 'lang'];\n }\n\n /**\n * Registers the words of a language for every player on the page. Each\n * source is a set of words or a function that loads one, which runs only\n * when a player shows that language. Later sources go over earlier ones,\n * so a page changes a shipped word by registering its own after it.\n * Players that show the language take the new words at once.\n */\n static addLocale(language: string, ...sources: readonly LocaleSource[]): void {\n addLocale(language, sources);\n }\n\n /**\n * Registers the element once, and records the stages markup-only pages\n * get. The controls register through their own entries, the package's\n * root entry importing every one; a control connected before its player\n * is defined waits for the definition.\n */\n static define(options?: MatteboxPlayerOptions): void {\n if (options !== undefined) defaults = options;\n if (customElements.get(PLAYER) === undefined) {\n customElements.define(PLAYER, MatteboxPlayerElement);\n }\n }\n\n declare private readonly media: HTMLVideoElement;\n /** Wraps the slot: the picture, and the controls over it or under it. */\n declare private readonly stage: HTMLDivElement;\n /** Whether the element gave itself a tabindex for the bar, to take back with it. */\n declare private focusable: boolean;\n declare private readonly surface: ErrorSurface;\n declare private readonly voice: Announcer;\n /** The words of the language shown, empty for English. */\n declare private words: Words;\n /** The language tag the player resolved, or empty without one. */\n declare private shown: string;\n /** Bumped on every resolution, so a slow loader does not win over a later choice. */\n declare private wordsEpoch: number;\n /** Ends the watch on registrations and on the page's `lang`. */\n declare private unwatch: (() => void) | null;\n /** Runs out when the video has waited `LOADING_MS`. */\n declare private slow: ReturnType<typeof setTimeout> | undefined;\n /** The audio track the live region last saw, so it says only a change. Undefined before the first play. */\n declare private heardAudio: string | undefined;\n /** The subtitle track it last saw: null for off, undefined before the first play. */\n declare private heardText: string | null | undefined;\n /** Stops listening to the current engine's track selection. */\n declare private offTracks: (() => void) | null;\n declare private readonly marks: Markers;\n declare private readonly breakMarks: BreakMarks;\n /** The chapters track element, while the `chapters` attribute names one and the engine takes none. */\n declare private track: HTMLTrackElement | null;\n /** The chapters URL the current session's engine was given, or null. */\n declare private given: string | null;\n /** The sources the page set from script, or null. */\n declare private list: readonly ProgrammeSource[] | null;\n declare private readonly tracking: TrackerRunner;\n /** The sources of the last run, as text: what tells a new `<source>` child from the ones already tried. */\n declare private tried: string;\n /** The options this element was constructed with, or null for the ones `define()` recorded. */\n declare private readonly own: MatteboxPlayerOptions | null;\n declare private core: Player | null;\n declare private current: Session | null;\n declare private failure: PlayerError | null;\n /** What `block()` set, or null. */\n declare private stop: Block | null;\n /** Whether an attribute change is the element's own reflection, which must not write back to the video. */\n declare private reflecting: boolean;\n /** Watches the element's box for `layout`, while connected. */\n declare private sizes: ResizeObserver | null;\n /** Whether the page wrote `layout`, so the element leaves it alone. */\n declare private fixed: boolean;\n /** The video has played once since its source was set: `started`, which tells a first play from a pause. */\n declare private started: boolean;\n /** The video waits for data: `waiting`, set on `waiting`, cleared once it can play. */\n declare private waiting: boolean;\n declare private offs: Array<() => void>;\n /** Where `interrupt` left the programme: its time, whether it played, its tracks. */\n declare private interruption: { at: number | null; playing: boolean; had: Chosen | null } | null;\n /** The add-ons attached to this player, with what each returned, run when it leaves the page. */\n declare private attached: Map<PlayerAddon, (() => void) | undefined>;\n /** Everything the element does to the player runs here, so it runs in order. */\n declare private queue: Promise<void>;\n /** Whether a run is queued and not yet started, so a burst of changes loads once. */\n declare private pending: boolean;\n /** The source the versions of `videoSources` belong to: the one that played before a switch. */\n declare private original: Source | null;\n /** The version that plays, or null for the programme itself. */\n declare private version: SourceVideoTrack | null;\n /** True while a version loads, so its `sourcechange` keeps the programme. */\n declare private switching: boolean;\n /** The source `switchSource` loaded, which a retry loads again, or null. */\n declare private switched: Source | null;\n /** Ends the hold of a switch: the poster and `switching` go back. Null without one. */\n declare private held: (() => void) | null;\n\n constructor(options?: MatteboxPlayerOptions) {\n super();\n this.own = options ?? null;\n this.focusable = false;\n this.track = null;\n this.given = null;\n this.list = null;\n this.tried = '';\n this.core = null;\n this.current = null;\n this.failure = null;\n this.stop = null;\n this.reflecting = false;\n this.sizes = null;\n this.fixed = false;\n this.started = false;\n this.waiting = false;\n this.offs = [];\n this.attached = new Map();\n this.interruption = null;\n this.queue = Promise.resolve();\n this.pending = false;\n this.original = null;\n this.version = null;\n this.switching = false;\n this.switched = null;\n this.held = null;\n this.words = {};\n this.shown = '';\n this.wordsEpoch = 0;\n this.unwatch = null;\n this.slow = undefined;\n this.heardAudio = undefined;\n this.heardText = undefined;\n this.offTracks = null;\n\n this.media = document.createElement('video');\n // Native until the `controls` attribute says otherwise, which arrives\n // through attributeChangedCallback: a constructor must not read attributes.\n this.media.controls = true;\n // Inline is the default, and the player's own attribute has not arrived\n // yet. Set as an attribute: not every browser has the `playsInline`\n // property. The fullscreen button still reaches the iPhone's fullscreen,\n // through `webkitEnterFullscreen`.\n this.media.setAttribute(PLAYSINLINE, '');\n for (const name of STATE_EVENTS) {\n this.media.addEventListener(name, () => {\n const was = this.waiting;\n this.note(name);\n this.reflect();\n this.tell(name, was);\n });\n }\n // A native session's tracks; an engine session's are on `tracks:selected`.\n const lists = this.media as { audioTracks?: EventTarget; textTracks: EventTarget };\n for (const list of [lists.audioTracks, lists.textTracks]) {\n list?.addEventListener('change', () => {\n this.tracks();\n });\n }\n // An error over a picture that then plays is wrong by definition.\n this.media.addEventListener('playing', () => {\n this.failure = null;\n this.reflect();\n });\n this.marks = createMarkers(this.media, (name, detail) => this.emit(name, detail));\n this.breakMarks = createBreakMarks((list) => this.emit('breakschange', list));\n this.tracking = createTrackers(this, () => this.emit('trackerschange', this.tracking.list));\n this.stage = document.createElement('div');\n this.stage.setAttribute('part', 'stage');\n const slot = document.createElement('slot');\n // The parser connects the element before its children exist, so the\n // first run finds no `<source>`. A video starts its selection when a\n // `<source>` arrives and nothing is loaded, and so does this.\n slot.addEventListener('slotchange', () => {\n if (this.current === null && JSON.stringify(this.wanted()) !== this.tried) this.reload();\n });\n this.stage.append(slot);\n this.surface = errorSurface(\n () => {\n this.retry();\n },\n () => this.words.retry ?? 'Retry',\n );\n\n this.voice = announcer(this, (id) => this.words[id]);\n\n const root = this.attachShadow({ mode: 'open' });\n const style = document.createElement('style');\n style.textContent = STYLE;\n root.append(style, this.stage, this.surface.root, this.voice.root);\n }\n\n /** The media element. Everything the browser already does is here. */\n get video(): HTMLVideoElement {\n return this.media;\n }\n\n /** The ranges the page named in this source: credits to skip, parts that must not play. */\n get markers(): Markers {\n return this.marks;\n }\n\n /** Where the programme's ad breaks are, which the seek bar draws: each add-on gives its own. */\n get breaks(): BreakMarks {\n return this.breakMarks;\n }\n\n /**\n * The sources to try in order, set from script. The `src` attribute wins\n * over them, and they win over the `<source>` children. Setting them\n * loads, and null returns to the children.\n */\n get sources(): readonly ProgrammeSource[] | null {\n return this.list;\n }\n\n set sources(value: readonly ProgrammeSource[] | null) {\n this.list = value;\n // Markers, a block and an interruption belong to a source, as for `src`.\n if (this.marks.list.length > 0) this.marks.set([]);\n this.interruption = null;\n this.unblock();\n this.reload();\n }\n\n /**\n * The language the page chose for this player, which wins over the\n * nearest `lang` attribute. Empty follows `lang`. Setting it changes the\n * words of every control at once.\n */\n get language(): string {\n return this.getAttribute(LANGUAGE) ?? '';\n }\n\n set language(value: string) {\n if (value === '') this.removeAttribute(LANGUAGE);\n else this.setAttribute(LANGUAGE, value);\n }\n\n /** The language tag the words come from: `language`, else the nearest `lang`. Empty without either. */\n get locale(): string {\n return this.shown;\n }\n\n /** The word of `id` in the player's language, or undefined, where the control's English applies. */\n message(id: keyof Messages): string | undefined {\n return this.words[id];\n }\n\n /** Follows registrations and the document's `lang` until disconnect. */\n private watchLanguage(): void {\n const off = onLocales(() => {\n this.relocale();\n });\n // The page's language usually sits on <html>; a lang on another\n // ancestor is read at connect, and `language` covers a change there.\n const watch = new MutationObserver(() => {\n this.relocale();\n });\n watch.observe(document.documentElement, { attributes: true, attributeFilter: ['lang'] });\n this.unwatch = () => {\n off();\n watch.disconnect();\n };\n this.relocale();\n }\n\n /** Resolves the language, takes its words, and tells the controls with `localechange`. */\n private relocale(): void {\n const tag = this.getAttribute(LANGUAGE) ?? this.closest('[lang]')?.getAttribute('lang') ?? '';\n const epoch = ++this.wordsEpoch;\n const take = (words: Words): void => {\n if (epoch !== this.wordsEpoch) return;\n this.shown = tag;\n this.words = words;\n this.showBlock();\n this.emit('localechange', tag);\n };\n const key = registered(tag);\n if (key === null) {\n take({});\n return;\n }\n const now = wordsNow(key);\n if (now !== null) {\n take(now);\n return;\n }\n // The words on screen stay until the language arrives; a loader that\n // fails leaves them.\n load(key).then(take, () => undefined);\n }\n\n /**\n * Loads the sources again, in the order a load reads them: the `src`\n * attribute, the `sources` property, then the `<source>` children. The\n * error screens' Retry calls it. On a version of `videoSources`, it\n * loads that version again.\n */\n retry(): void {\n const again =\n this.version === null ? this.switched : versionSource(this.version, emeAvailable());\n if (again === null) this.reload();\n else this.swap(again, null, false, null, false);\n }\n\n /**\n * Loads `source` in place of the one that plays, from the same position\n * and in the same play state, with the same audio and subtitle choice.\n * Use it for the same programme at another URL, such as its HLS and\n * DASH manifests. The last frame and the controls hold until the new\n * load shows a frame there. The markers stay, and the versions are the\n * ones `source` names. A new `src`, `sources` or `<source>` load\n * replaces it.\n */\n switchSource(source: Source): void {\n const media = this.media;\n const at = Number.isFinite(media.duration) ? media.currentTime : null;\n const playing = !media.paused;\n const had = chosen(this.current?.engine ?? null);\n const clean = emeAvailable() ? source : withoutDrm(source);\n const was = this.version;\n this.original = clean;\n this.switched = clean;\n this.version = null;\n if (was !== null) this.emit('videosourcechange', null);\n this.swap(clean, at, playing, had, true);\n }\n\n /**\n * Plays `source` on the video in the programme's place, such as an ad of\n * `@mattebox/player-ads`. The programme, its markers and its trackers\n * stay, no `sourcechange` fires, and the controls drive the source as\n * they drive the programme. An error of the source is not the\n * programme's: listen to the video. `resume()` plays the programme again\n * where it stopped. Resolves once the source is loaded; rejects when no\n * handler plays it.\n */\n interrupt(source: Source): Promise<void> {\n const media = this.media;\n this.interruption ??= {\n at: Number.isFinite(media.duration) ? media.currentTime : null,\n playing: !media.paused,\n had: chosen(this.current?.engine ?? null),\n };\n return this.queued(async () => {\n const core = await this.ensure();\n await core.interrupt(source);\n this.current = core.session;\n media.play().catch(() => undefined);\n });\n }\n\n /**\n * Plays the programme again where `interrupt` left it, in the play state\n * it had, or as `options` says: `at` another position, such as its end\n * after a post-roll, and `playing`.\n */\n resume(options: { readonly at?: number | null; readonly playing?: boolean } = {}): Promise<void> {\n const left = this.interruption;\n if (left === null) return Promise.resolve();\n this.interruption = null;\n const at = options.at === undefined ? left.at : options.at;\n const playing = options.playing ?? left.playing;\n return this.queued(async () => {\n const core = await this.ensure();\n await core.resume(at ?? undefined);\n this.current = core.session;\n restore(this.current?.engine ?? null, left.had);\n if (playing) this.media.play().catch(() => undefined);\n });\n }\n\n /** `interrupt` plays in the programme's place. */\n get interrupted(): boolean {\n return this.interruption !== null;\n }\n\n /** Runs `task` in the element's queue, and says how it went. */\n private queued(task: () => Promise<void>): Promise<void> {\n return new Promise((resolve, reject) => {\n this.enqueue(() => task().then(resolve, reject));\n });\n }\n\n /** The other versions of the picture the source names at their own URLs, for the video menu. */\n get videoSources(): readonly SourceVideoTrack[] {\n return this.original?.videoTracks ?? [];\n }\n\n /** The version of `videoSources` that plays, or null for the source itself. */\n get videoSource(): SourceVideoTrack | null {\n return this.version;\n }\n\n /**\n * Plays a version of `videoSources`, or the source itself for null, from\n * the same position and in the same play state, with the same audio and\n * subtitle choice. A live source joins the version at its live edge.\n * Fires `videosourcechange`.\n */\n selectVideoSource(track: SourceVideoTrack | null): void {\n const programme = this.original;\n if (programme === null || track === this.version) return;\n if (track !== null && programme.videoTracks?.includes(track) !== true) return;\n const media = this.media;\n const at = Number.isFinite(media.duration) ? media.currentTime : null;\n const playing = !media.paused;\n const had = chosen(this.current?.engine ?? null);\n this.version = track;\n this.emit('videosourcechange', track);\n this.swap(\n track === null ? programme : versionSource(track, emeAvailable()),\n at,\n playing,\n had,\n true,\n );\n }\n\n /**\n * Loads `source` under the programme that plays, and puts the position,\n * play state and tracks back. With `hold`, the last frame stays as the\n * poster and the player carries `switching`, the play state from\n * before, so the controls show that state through the load.\n */\n private swap(\n source: Source,\n at: number | null,\n playing: boolean,\n had: Chosen | null,\n hold: boolean,\n ): void {\n const media = this.media;\n this.held?.();\n let release: (() => void) | null = null;\n if (hold) {\n // Taken now, while the frame of the source that played is still on screen.\n const frame = holdFrame(media);\n const done = (): void => {\n frame?.();\n if (this.held !== done) return;\n this.held = null;\n this.removeAttribute(SWITCHING);\n this.reflect();\n };\n this.held = done;\n this.setAttribute(SWITCHING, playing ? 'playing' : 'paused');\n release = done;\n }\n this.enqueue(async () => {\n const core = await this.ensure();\n this.switching = true;\n try {\n await core.load([source]);\n } catch {\n // Reported on the error event, as for any load.\n release?.();\n return;\n } finally {\n this.switching = false;\n }\n resume(media, at, playing);\n if (release !== null) onNextFrame(media, at, release);\n restore(this.current?.engine ?? null, had);\n });\n }\n\n /** The core, or null until the first source has been set up: resolving a preset is asynchronous. */\n get player(): Player | null {\n return this.core;\n }\n\n /** The engine feeding the video, or null for a native session and before the first load. */\n get engine(): Mattebox | null {\n return this.current?.engine ?? null;\n }\n\n /**\n * The fatal error of the current load, or null once a load starts or\n * playback resumes. The `error` event says when; this says what, for a\n * control that attaches after the event, such as an error screen parsed\n * after a source that failed while the page was still loading.\n */\n get error(): PlayerError | null {\n return this.failure;\n }\n\n /**\n * Shows why the programme does not play, in place of the video, and\n * stops the load: the reason the page's content API gave, such as a\n * geographic or an age restriction. The error screen shows the title,\n * else \"Not available\", and the message, with no retry. Each text can\n * be given by language tag, and follows the player's language. A new\n * `src` or `sources` clears it. Fires `blockchange`.\n */\n block(block: Block): void {\n this.refuse(block);\n this.enqueue(() => this.teardown());\n }\n\n /** Shows the block, for `block()` and for a programme a connector blocked, which loaded nothing. */\n private refuse(block: Block): void {\n this.stop = block;\n this.media.pause();\n clearTimeout(this.slow);\n const [title, message] = this.blockWords(block);\n // An error screen in the player is an alert of its own, read already.\n if (this.querySelector(ERROR_SCREEN) === null) {\n this.voice.tell(message === '' ? title : `${title}. ${message}`);\n }\n this.showBlock();\n this.reflect();\n this.emit('blockchange', block);\n }\n\n /** Removes the block. Nothing plays until a source loads: set one, or call `retry()`. */\n unblock(): void {\n if (this.stop === null) return;\n this.stop = null;\n this.surface.clear();\n this.reflect();\n this.emit('blockchange', null);\n }\n\n /** What `block()` set, or null. */\n get blocked(): Block | null {\n return this.stop;\n }\n\n /**\n * What the current load resolved to: the sources, and what a connector\n * said of the programme. Null before a load and after an unload.\n */\n get programme(): Programme | null {\n return this.core?.programme ?? null;\n }\n\n /**\n * The page's trackers. Each starts at every programme and stops at its\n * end; one added or removed during a programme starts or stops at once.\n */\n get trackers(): Trackers {\n return this.tracking;\n }\n\n /**\n * Applies what the load resolved, before any session: the markers, the\n * poster, the block. The page's own `poster` and markers set after the\n * source win. Then the trackers start on the programme.\n */\n private programmed(programme: Programme | null): void {\n const metadata = programme?.metadata;\n if (metadata?.markers !== undefined) this.marks.set(metadata.markers);\n if (!this.hasAttribute('poster')) {\n if (metadata?.poster === undefined) this.media.removeAttribute('poster');\n else this.media.poster = metadata.poster;\n }\n if (programme?.block !== undefined) this.refuse(programme.block);\n this.emit('programmechange', programme);\n this.tracking.begin(programme);\n }\n\n /** A block's title and message in the player's language: the title defaults to the `blocked` word. */\n private blockWords(block: Block): [string, string] {\n return [\n block.title === undefined\n ? (this.words.blocked ?? 'Not available')\n : textIn(block.title, this.shown),\n block.message === undefined ? '' : textIn(block.message, this.shown),\n ];\n }\n\n /** Puts the block on the row under the video, under native controls. */\n private showBlock(): void {\n if (this.stop === null || this.getAttribute(CONTROLS) === 'custom') return;\n const [title, message] = this.blockWords(this.stop);\n this.surface.inform(title, message);\n }\n\n connectedCallback(): void {\n if (this.media.parentNode !== this) this.append(this.media);\n for (const name of FORWARDED) this.forward(name);\n this.reflect();\n if (typeof ResizeObserver !== 'undefined') {\n this.sizes = new ResizeObserver(() => {\n this.measure();\n });\n this.sizes.observe(this);\n }\n this.measure();\n this.watchLanguage();\n this.attachAddons();\n this.reload();\n }\n\n /**\n * Attaches each add-on of the options once. At connect, and again at each\n * load: a page that imports the player registers it before its own\n * `define()` gives the add-ons, and the players already on the page\n * connected then.\n */\n private attachAddons(): void {\n for (const addon of this.options.addons ?? []) {\n if (!this.attached.has(addon)) this.attached.set(addon, addon.attach?.(this));\n }\n }\n\n /** Sets `layout` from the element's box, unless the page fixed it. */\n private measure(): void {\n if (this.fixed) return;\n const width = this.clientWidth;\n const height = this.clientHeight;\n // Not laid out yet: no tier until there is a box to judge.\n if (width === 0 || height === 0) return;\n const layout =\n width < COMPACT_WIDTH || height < COMPACT_HEIGHT\n ? 'compact'\n : width >= WIDE_WIDTH && height >= WIDE_HEIGHT\n ? 'wide'\n : 'regular';\n if (this.getAttribute(LAYOUT) === layout) return;\n this.reflecting = true;\n this.setAttribute(LAYOUT, layout);\n this.reflecting = false;\n this.emit('layoutchange', layout);\n }\n\n /** The two states the video does not hold: whether it has played once, and whether it waits for data. */\n private note(event: string): void {\n if (event === 'playing') {\n // The tracks the video starts playing with are what a change is from.\n if (!this.started) this.tracks();\n this.started = true;\n this.waiting = false;\n } else if (event === 'waiting') {\n // Not `stalled`: a paused video with a full buffer fires it too, when\n // nothing more is appended for three seconds. video.js reads `waiting` alone.\n this.waiting = true;\n } else if (event === 'canplay') {\n this.waiting = false;\n } else if (event === 'emptied') {\n // A new source starts over: the title shows again before its first play.\n // A switch is the same programme, so it keeps its start.\n if (this.held === null) this.started = false;\n this.waiting = false;\n this.heardAudio = undefined;\n this.heardText = undefined;\n }\n }\n\n /** Says a play or a pause, and a wait once it has lasted `LOADING_MS`. */\n private tell(event: string, was: boolean): void {\n // The load of a switch pauses and plays the video, and the viewer did neither.\n if (event === 'play' && this.held === null) this.voice.say('playing', 'saidPlaying', 'Playing');\n // The end of the video pauses it too, and that is no pause to say.\n if (event === 'pause' && !this.media.ended && this.held === null) {\n this.voice.say('paused', 'saidPaused', 'Paused');\n }\n if (this.waiting === was) return;\n clearTimeout(this.slow);\n if (this.waiting) {\n this.slow = setTimeout(() => {\n this.voice.say('loading', 'loading', 'Loading');\n }, LOADING_MS);\n }\n }\n\n /**\n * Says a change of the audio or the subtitle track, once the video has\n * played: the tracks a load starts with are no change. A forced track\n * reads as off, as in the subtitles menu.\n */\n private tracks(): void {\n const engine = this.current?.engine ?? null;\n let audio: string;\n let text: string | null;\n if (engine !== null) {\n const sound = engine.tracks.active('audio');\n const words = engine.tracks.active('text');\n audio = sound === null ? '' : trackName(sound.name, sound.lang, this.locale);\n text =\n words === null || words.forced === true\n ? null\n : trackName(words.name, words.lang, this.locale);\n } else {\n const video = this.media as {\n audioTracks?: ArrayLike<{ enabled: boolean; label: string; language: string }>;\n };\n const sound = Array.from(video.audioTracks ?? []).find((track) => track.enabled);\n const words = Array.from(this.media.textTracks).find(\n (track) =>\n (track.kind === 'subtitles' || track.kind === 'captions') && track.mode === 'showing',\n );\n audio = sound === undefined ? '' : trackName(sound.label, sound.language, this.locale);\n text = words === undefined ? null : trackName(words.label, words.language, this.locale);\n }\n const { heardAudio, heardText } = this;\n this.heardAudio = audio;\n this.heardText = text;\n if (!this.started) return;\n if (heardAudio !== undefined && audio !== heardAudio) {\n this.voice.say('audio', 'saidAudio', 'Audio: {track}', audio);\n }\n if (heardText !== undefined && text !== heardText) {\n if (text === null) this.voice.say('subtitles-off', 'saidSubtitlesOff', 'Subtitles off');\n else this.voice.say('subtitles', 'saidSubtitles', 'Subtitles: {track}', text);\n }\n }\n\n /** The video's state on the element, for `mattebox-player[paused]` and the like. */\n private reflect(): void {\n const video = this.media;\n this.reflecting = true;\n // Through a switch, the play state from before it.\n const held = this.getAttribute(SWITCHING);\n const paused = held === null ? video.paused : held === 'paused';\n this.toggleAttribute('paused', paused);\n this.toggleAttribute('playing', !paused);\n this.toggleAttribute('ended', video.ended);\n // `muted` is also forwarded: the page's attribute sets the video, and\n // the video's state sets the attribute. Reflection never forwards, so\n // a read can only ever change the attribute, never the video.\n this.toggleAttribute('muted', video.muted);\n this.toggleAttribute('audio', this.audio());\n this.toggleAttribute('started', this.started);\n this.toggleAttribute('waiting', this.waiting);\n this.toggleAttribute('error', this.failure !== null);\n this.toggleAttribute('blocked', this.stop !== null);\n this.reflecting = false;\n }\n\n /**\n * Whether the source has no picture. Once the metadata is in, the video's\n * size decides: zero by zero is sound alone, and `resize` catches a stream\n * that moves to or from an audio-only rendition. Before that, the type the\n * page wrote or the URL implies is the hint, so an mp3 is `audio` from\n * the start rather than from its metadata.\n */\n private audio(): boolean {\n const video = this.media;\n if (video.readyState >= HTMLMediaElement.HAVE_METADATA) {\n return video.videoWidth === 0 && video.videoHeight === 0;\n }\n const src = this.getAttribute('src');\n const type = this.getAttribute('type') ?? (src === null ? undefined : inferType(src));\n return type?.startsWith('audio/') === true;\n }\n\n disconnectedCallback(): void {\n this.sizes?.disconnect();\n this.sizes = null;\n this.unwatch?.();\n this.unwatch = null;\n // A single-page app must not leave a pipeline attached to a video it\n // navigated away from. Reconnecting loads the `src` again. A move is no\n // removal: as HTML's media element waits for a stable state before it\n // pauses, the teardown waits a microtask and runs only if the element is\n // still out of the document.\n queueMicrotask(() => {\n if (this.isConnected) return;\n for (const off of this.attached.values()) off?.();\n this.attached.clear();\n this.enqueue(() => this.teardown());\n });\n }\n\n attributeChangedCallback(name: string): void {\n if (name === LANGUAGE || name === 'lang') {\n this.relocale();\n return;\n }\n if (FORWARDED.includes(name)) {\n if (!this.reflecting) this.forward(name);\n return;\n }\n if (name === CONTROLS) {\n this.mode();\n return;\n }\n if (name === CHAPTERS) {\n this.chapters();\n return;\n }\n if (name === LAYOUT) {\n // The element's own write is not the page's.\n if (this.reflecting) return;\n const value = this.getAttribute(LAYOUT);\n this.fixed = value !== null && LAYOUTS.includes(value);\n if (this.fixed) this.emit('layoutchange', value);\n else this.measure();\n return;\n }\n if (name === PLAYSINLINE) {\n // On the video it is a boolean attribute, so off is absent.\n this.media.toggleAttribute(PLAYSINLINE, this.getAttribute(PLAYSINLINE) !== 'false');\n return;\n }\n // The preset decides the chain, so it is the one attribute that rebuilds it.\n if (name === 'preset') this.enqueue(() => this.discard());\n // The source's type is the hint for `audio` until its metadata arrives.\n // Only `audio`: a full reflection here would drop a `muted` the page\n // wrote before its own callback forwards it.\n if (name === 'src' || name === 'type') this.toggleAttribute('audio', this.audio());\n // Markers belong to a source. Cleared here, not on `emptied`, which\n // arrives later and would clear the ones the page sets right after.\n if (name === 'src' && this.marks.list.length > 0) this.marks.set([]);\n if (name === 'src') this.interruption = null;\n if (name === 'src') this.unblock();\n this.reload();\n }\n\n /**\n * Applies the `controls` attribute: the video's own controls and the\n * tabindex. The controls themselves are elements the page placed, and\n * they attach on their own; the element appends none.\n */\n private mode(): void {\n const value = this.getAttribute(CONTROLS);\n const custom = value === 'custom';\n this.media.controls = !custom && value !== 'none';\n // Under custom controls the error screen element carries a fatal error.\n if (custom) this.surface.clear();\n else this.showBlock();\n if (!custom) {\n if (this.focusable) this.removeAttribute('tabindex');\n this.focusable = false;\n } else if (!this.hasAttribute('tabindex')) {\n // A bare video is not focusable, so without this a click on it would\n // leave the shortcuts nowhere to listen. A page that set its own\n // tabindex keeps it.\n this.tabIndex = 0;\n this.focusable = true;\n }\n }\n\n /** Hands the `chapters` attribute to the engine, or keeps a hidden chapters track on the video for it. */\n private chapters(): void {\n const url = this.getAttribute(CHAPTERS);\n const engine = this.current?.engine ?? null;\n const api = engine === null ? undefined : namespaces(engine).chapters;\n if (api !== undefined) {\n this.track?.remove();\n this.track = null;\n if (url === this.given) return;\n this.given = url;\n // An empty list removes the chapters the attribute loaded.\n if (url === null) api.set([]);\n else void api.load(url).catch(() => undefined);\n return;\n }\n if (url === null) {\n this.track?.remove();\n this.track = null;\n return;\n }\n const held = this.track;\n if (held !== null && held.parentNode === this.media && held.getAttribute('src') === url) return;\n // A new element each time: one removed mid-load, as the engine's attach\n // does, stays in its error state, and neither a new `src` nor a second\n // insertion starts it loading again.\n held?.remove();\n const track = document.createElement('track');\n track.kind = 'chapters';\n track.src = url;\n this.track = track;\n this.media.append(track);\n // Set after the insertion: a track element's mode exists once it is in\n // a media element, and `hidden` is what makes its cues load unseen.\n track.track.mode = 'hidden';\n }\n\n private forward(name: string): void {\n const value = this.getAttribute(name);\n if (value === null) this.media.removeAttribute(name);\n else this.media.setAttribute(name, value);\n // A video reads `muted` into its state only when it is created, and this\n // one was created before any attribute reached it. Muted autoplay and\n // the autoplay policy read the state, so the attribute alone would not do.\n if (name === 'muted') this.media.muted = value !== null;\n }\n\n private enqueue(task: () => Promise<void>): void {\n this.queue = this.queue.then(task, task).catch(() => undefined);\n }\n\n /**\n * One run per burst. The parser sets every attribute and then connects the\n * element before any queued task starts, and each of those would load on\n * its own; the flag folds them into the one run that sees the final state.\n */\n private reload(): void {\n if (this.pending) return;\n this.pending = true;\n this.enqueue(() => {\n this.pending = false;\n return this.run();\n });\n }\n\n private emit(name: string, detail: unknown): void {\n this.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true }));\n }\n\n private report(error: PlayerError): void {\n if (error.fatal) {\n this.failure = error;\n clearTimeout(this.slow);\n // An error screen in the player is an alert of its own, read already.\n if (this.querySelector(ERROR_SCREEN) === null) {\n this.voice.say('error', 'playbackFailed', 'Playback failed');\n }\n // Under custom controls the error screen element is the surface, and\n // the element's own row under the video stays quiet.\n if (this.getAttribute(CONTROLS) !== 'custom') this.surface.show(error);\n this.reflect();\n }\n this.emit('error', error);\n }\n\n private async run(): Promise<void> {\n this.unmount();\n if (!this.isConnected) return;\n const sources = this.wanted();\n this.tried = JSON.stringify(sources);\n if (sources.length === 0) return;\n\n const core = await this.ensure();\n this.failure = null;\n this.surface.clear();\n this.reflect();\n\n try {\n await core.load(sources);\n } catch {\n // The core already reported it on the error event, which the surface\n // and the element's own event both carry. Nothing to add here.\n return;\n }\n if (!this.isConnected) await core.unload();\n }\n\n /**\n * What to load, ranked as a video ranks them: the `src` attribute, then\n * the `sources` property, then the `<source>` children in their order.\n * A child carries its own `license-url` and `certificate-url`.\n */\n private wanted(): readonly ProgrammeSource[] {\n // The `<mbx-video-track>` children are versions of the `src` or `<source>` picture.\n const versions = markupVideoTracks(this);\n const withVersions = versions.length === 0 ? {} : { videoTracks: versions };\n const url = this.getAttribute('src');\n if (url !== null) {\n const type = this.getAttribute('type');\n return [{ url, ...(type === null ? {} : { type }), ...withVersions }];\n }\n // A browser without EME gets no DRM stage, and a source must not bring DRM back.\n const eme = emeAvailable();\n if (this.list !== null) {\n return eme\n ? this.list\n : this.list.map((source) => ('url' in source ? withoutDrm(source) : source));\n }\n const found: Source[] = [];\n for (const child of Array.from(this.children)) {\n const src = child.localName === 'source' ? child.getAttribute('src') : null;\n if (src === null) continue;\n const type = child.getAttribute('type');\n const license = child.getAttribute(LICENSE_URL);\n const certificate = child.getAttribute(CERTIFICATE_URL);\n found.push({\n url: src,\n ...(type === null ? {} : { type }),\n ...withVersions,\n ...(!eme || (license === null && certificate === null)\n ? {}\n : {\n drm: {\n ...(license === null ? {} : { licenseUrl: license }),\n ...(certificate === null ? {} : { certificateUrl: certificate }),\n },\n }),\n });\n }\n return found;\n }\n\n /** Sets a session up. It runs for every session, the one that replaces a failed source included. */\n private adopt(session: Session): void {\n this.given = null;\n this.configure(session);\n // A content API's chapters, unless the `chapters` attribute names a file.\n const chapters = this.core?.programme?.metadata?.chapters;\n if (chapters !== undefined && session.engine !== null && this.getAttribute(CHAPTERS) === null) {\n namespaces(session.engine).chapters?.set(chapters);\n }\n // The engine's attach empties the media element to reset its resource\n // selection (`kernel/mse.ts`), and the chapters track goes with the\n // `<source>` children it means. Wanted: the track to survive attach.\n // Had to: put it back once the session is in. The surface that would\n // make it one call: an attach that removes `<source>` children alone.\n // A session with the engine's chapters takes the URL there instead.\n this.chapters();\n }\n\n private async ensure(): Promise<Player> {\n if (this.core !== null) return this.core;\n const connectors = this.options.connectors;\n const core = createPlayer(this.media, {\n handlers: await this.chain(),\n ...(connectors === undefined ? {} : { connectors }),\n });\n this.offs.push(\n core.on('programme', (programme) => {\n this.programmed(programme);\n }),\n core.on('sourcechange', (session) => {\n // Before the event goes out, so a control that reads `engine` on\n // `sourcechange` sees the session the event is about.\n this.current = session;\n // A version loads under the programme it belongs to; any other load is a programme of its own.\n if (!this.switching) {\n const was = this.version;\n this.original = session?.source ?? null;\n this.switched = null;\n this.version = null;\n this.held?.();\n if (was !== null) this.emit('videosourcechange', null);\n }\n this.offTracks?.();\n this.offTracks = session?.engine?.on('tracks:selected', () => this.tracks()) ?? null;\n if (session !== null && this.isConnected) this.adopt(session);\n this.emit('sourcechange', session);\n }),\n core.on('error', (error) => {\n this.report(error);\n }),\n );\n this.core = core;\n return core;\n }\n\n /**\n * Read at each use, not once in the constructor. Importing the package\n * registers the element, and the parser's elements are constructed then,\n * before the page's own `define()` call can run.\n */\n private get options(): MatteboxPlayerOptions {\n return this.own ?? defaults;\n }\n\n private async chain(): Promise<readonly Handler[]> {\n if (this.options.handlers !== undefined) return this.options.handlers;\n const config = this.options.config === undefined ? {} : { config: this.options.config };\n // The stack is read at load time: a preset builds its stages only when asked.\n const native = (stages: () => readonly Stage[]): Handler =>\n nativeHandler({\n // Read on every load, so the attribute applies without a new chain.\n prefer: (source, env) =>\n this.getAttribute(NATIVE_HLS) !== 'off' &&\n !(this.options.addons ?? []).some((addon) => addon.engine === true) &&\n preferNativeHls(source, env),\n drm: () => this.drm(stages),\n });\n if (this.isConnected) this.attachAddons();\n // The add-ons' stages, fresh for this chain, join whatever stack it builds.\n const added = (this.options.addons ?? []).flatMap((addon) => addon.stages?.() ?? []);\n if (this.options.stages !== undefined) {\n const own = this.options.stages;\n const stages = [...own, ...added.filter((stage) => !own.some((o) => o.name === stage.name))];\n return [matteboxHandler({ stages, ...config }), native(() => stages)];\n }\n const name = this.getAttribute('preset') ?? DEFAULT_PRESET;\n const preset = await resolvePreset(name);\n if (preset === null) {\n this.report({\n category: 'config',\n code: 'CONFIG_INVALID',\n fatal: true,\n recoverable: false,\n handler: null,\n context: { preset: name },\n });\n return [nativeHandler()];\n }\n // With a preset, the handler merges these stages into its own by name.\n const extra = added.length === 0 ? {} : { stages: added };\n return [\n matteboxHandler({ preset, ...extra, ...config, ...drmGuard() }),\n native(() => preset.stages()),\n ];\n }\n\n /**\n * The DRM a native session attaches: the page's `drm` option, the\n * key-system stages of the engine's stack, and the `license-url`\n * attribute. None on a browser without EME, as for the engine.\n */\n private drm(stages: () => readonly Stage[]): AttachEmeOptions | undefined {\n if (drmGuard().without !== undefined) return undefined;\n const keySystems = stages().filter((stage) => KEY_SYSTEMS.includes(stage.name));\n const license = this.getAttribute(LICENSE_URL);\n const certificate = this.getAttribute(CERTIFICATE_URL);\n const page = this.options.drm;\n if (keySystems.length === 0 && license === null && page === undefined) return undefined;\n return {\n keySystems,\n ...page,\n ...(license === null ? {} : { licenseUrl: license }),\n ...(certificate === null ? {} : { certificateUrl: certificate }),\n };\n }\n\n /** What the attributes ask of the session's namespaces, once there is one. */\n private configure(session: Session): void {\n const engine = session.engine;\n if (engine === null) return;\n\n const optional = namespaces(engine);\n\n // The attributes are the default. A source's own URL is already on the\n // engine: the handler set it from `source.drm` before the load.\n const own = session.source.drm;\n const license = this.getAttribute(LICENSE_URL);\n // After the session exists, not before: passing a license URL up front\n // means constructing eme-core, and importing a stage to configure it\n // would bundle it.\n if (license !== null && own?.licenseUrl === undefined) optional.drm?.setLicenseUrl(license);\n const certificate = this.getAttribute(CERTIFICATE_URL);\n if (certificate !== null && own?.certificateUrl === undefined) {\n optional.drm?.setCertificateUrl(certificate);\n }\n\n const track = this.getAttribute('thumbnails');\n if (track !== null && optional.thumbnails !== undefined) {\n // Loaded here; drawn by the seek bar's preview under `controls=\"custom\"`.\n // Native controls expose no scrub position to anchor a preview to, so\n // under `native` the track only answers `engine.thumbnails.at(time)` for\n // the app. See docs/guide/03-the-element.md.\n void optional.thumbnails.load(track).catch(() => undefined);\n }\n }\n\n private unmount(): void {\n this.current = null;\n }\n\n private async teardown(): Promise<void> {\n this.unmount();\n if (this.core !== null) await this.core.unload();\n }\n\n /** Drops the player itself, so the next run builds a chain from the new preset. */\n private async discard(): Promise<void> {\n await this.teardown();\n for (const off of this.offs) off();\n this.offs = [];\n this.core = null;\n }\n}\n"],"m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AAI,UAAU,QAAQ,SAAS,eAAe,KAAA,GAK5C,SAAc,WAAW,KAAK,KAAK,CAAC,CAAC,YAAY,KAAA,CAAS;CAE9D;CAEA,UAAwB;EACtB,KAAK,UAAU;CACjB;CAEA,MAAc,WAA0B;EACtC,KAAK,QAAQ;EACb,IAAI,KAAK,SAAS,MAAM,MAAM,KAAK,KAAK,OAAO;CACjD;;CAGA,MAAc,UAAyB;EACrC,MAAM,KAAK,SAAS;EACpB,KAAK,MAAM,OAAO,KAAK,MAAM,IAAI;EACjC,KAAK,OAAO,CAAC;EACb,KAAK,OAAO;CACd;AACF"}
|
|
@@ -3,6 +3,7 @@ import { Component } from './component.js';
|
|
|
3
3
|
export declare class MbxMarkerButton extends Component {
|
|
4
4
|
static get observedAttributes(): readonly string[];
|
|
5
5
|
private readonly button;
|
|
6
|
+
private readonly text;
|
|
6
7
|
/** The range the button skips, or null while playback is in none. */
|
|
7
8
|
private marker;
|
|
8
9
|
/** Watches the bar and the title: the button sits above whichever is taller. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marker-button.d.ts","sourceRoot":"","sources":["../../src/elements/marker-button.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAU3C,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,MAAM,CAAoB;IACnD,qEAAqE;IACrE,QAAgB,MAAM,CAAgB;IACtC,gFAAgF;IAChF,QAAgB,OAAO,CAAwB;;
|
|
1
|
+
{"version":3,"file":"marker-button.d.ts","sourceRoot":"","sources":["../../src/elements/marker-button.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAU3C,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,MAAM,CAAoB;IACnD,iBAAyB,IAAI,CAAkB;IAC/C,qEAAqE;IACrE,QAAgB,MAAM,CAAgB;IACtC,gFAAgF;IAChF,QAAgB,OAAO,CAAwB;;IA2BtC,iBAAiB,IAAI,IAAI;cAMf,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAuBhC,MAAM,IAAI,IAAI;IAKjC;;;;OAIG;IACH,OAAO,CAAC,GAAG;cAOQ,MAAM,IAAI,IAAI;CAsBlC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Component } from "./component.js";
|
|
2
2
|
import { BUTTON_STYLE, style } from "./shared.js";
|
|
3
3
|
// src/elements/marker-button.ts
|
|
4
|
-
const STYLE_CSS = ":host{right:calc(var(--mbx-pad,.5em) + .5em);bottom:calc(var(--mbx-marker-lift,3.5em) + .75em);z-index:1;
|
|
4
|
+
const STYLE_CSS = ":host{right:calc(var(--mbx-pad,.5em) + .5em);bottom:calc(var(--mbx-marker-lift,3.5em) + .75em);z-index:1;position:absolute}:host([hidden]){display:none}[part~=button]{border-radius:var(--mbx-radius);backdrop-filter:blur(12px);width:auto;height:2.75em;color:var(--mbx-text);font:inherit;white-space:nowrap;background:#1c1c20b8;border:0;align-items:center;padding:0 .85em 0 1.1em;font-size:1.07em;font-weight:600;display:inline-flex}[part~=button]:hover{background:#1c1c20e6}[part~=icon]{fill:none;stroke:currentColor;stroke-width:3px;stroke-linecap:round;stroke-linejoin:round;width:1.25em;height:1.25em;margin-inline-start:.3em}";
|
|
5
5
|
/** The id and the English of the button over each kind of range. */
|
|
6
6
|
const WORDS = {
|
|
7
7
|
"opening-credits": ["skipIntro", "Skip intro"],
|
|
@@ -23,7 +23,16 @@ var MbxMarkerButton = class extends Component {
|
|
|
23
23
|
this.button = document.createElement("button");
|
|
24
24
|
this.button.type = "button";
|
|
25
25
|
this.button.setAttribute("part", "button");
|
|
26
|
-
this.
|
|
26
|
+
this.text = document.createElement("span");
|
|
27
|
+
this.text.textContent = "Skip";
|
|
28
|
+
const chevron = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
29
|
+
chevron.setAttribute("viewBox", "0 0 32 32");
|
|
30
|
+
chevron.setAttribute("aria-hidden", "true");
|
|
31
|
+
chevron.setAttribute("part", "icon");
|
|
32
|
+
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
33
|
+
path.setAttribute("d", "M12 8l8 8l-8 8");
|
|
34
|
+
chevron.append(path);
|
|
35
|
+
this.button.append(this.text, chevron);
|
|
27
36
|
this.button.addEventListener("click", () => {
|
|
28
37
|
const video = this.player?.video;
|
|
29
38
|
if (video !== void 0 && this.marker !== null) video.currentTime = this.marker.end;
|
|
@@ -48,11 +57,6 @@ var MbxMarkerButton = class extends Component {
|
|
|
48
57
|
this.observe(player, ["upnext"], () => {
|
|
49
58
|
this.render();
|
|
50
59
|
});
|
|
51
|
-
const idle = () => {
|
|
52
|
-
this.toggleAttribute("idle", player.hasAttribute("idle"));
|
|
53
|
-
};
|
|
54
|
-
this.observe(player, ["idle"], idle);
|
|
55
|
-
idle();
|
|
56
60
|
if (typeof ResizeObserver !== "undefined") {
|
|
57
61
|
this.resizer = new ResizeObserver(() => {
|
|
58
62
|
this.fit(player);
|
|
@@ -88,7 +92,7 @@ var MbxMarkerButton = class extends Component {
|
|
|
88
92
|
const kind = this.marker.kind;
|
|
89
93
|
const skip = this.word("label-skip", "skip", "Skip");
|
|
90
94
|
const known = WORDS[kind];
|
|
91
|
-
this.
|
|
95
|
+
this.text.textContent = known !== void 0 ? this.word(`label-${kind}`, ...known) : this.getAttribute(`label-${kind}`) ?? (this.marker.label === void 0 ? skip : `${skip} ${this.pageText(this.marker.label)}`);
|
|
92
96
|
}
|
|
93
97
|
};
|
|
94
98
|
export { MbxMarkerButton };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marker-button.js","names":[],"sources":["../../src/elements/marker-button.ts"],"sourcesContent":["/**\n * <mbx-marker-button>: \"Skip intro\" over the picture while playback is in\n * the opening credits, \"Skip credits\" in the closing ones, and \"Skip\" with\n * the marker's own label in any other range the page named. A press moves\n * the playhead to the range's end. Blocked ranges never show it: the\n * player moves past those itself. The words come from\n * `label-opening-credits`, `label-closing-credits` and `label-skip`.\n *\n * While the player carries `upnext`, set by a card that offers the next\n * item, the button leaves the closing credits to it.\n */\nimport type { Marker } from '../controls/markers.js';\nimport type { PlayerHost } from '../host.js';\nimport type { Messages } from '../messages.js';\nimport { Component } from './component.js';\nimport STYLE_CSS from './marker-button.css?inline';\nimport { BUTTON_STYLE, style } from './shared.js';\n\n/** The id and the English of the button over each kind of range. */\nconst WORDS: Readonly<Record<string, readonly [keyof Messages, string]>> = {\n 'opening-credits': ['skipIntro', 'Skip intro'],\n 'closing-credits': ['skipCredits', 'Skip credits'],\n};\n\nexport class MbxMarkerButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label-opening-credits', 'label-closing-credits', 'label-skip'];\n }\n\n declare private readonly button: HTMLButtonElement;\n /** The range the button skips, or null while playback is in none. */\n declare private marker: Marker | null;\n /** Watches the bar and the title: the button sits above whichever is taller. */\n declare private resizer: ResizeObserver | null;\n\n constructor() {\n super();\n this.marker = null;\n this.resizer = null;\n const root = this.attachShadow({ mode: 'open' });\n this.button = document.createElement('button');\n this.button.type = 'button';\n this.button.setAttribute('part', 'button');\n this.
|
|
1
|
+
{"version":3,"file":"marker-button.js","names":[],"sources":["../../src/elements/marker-button.ts"],"sourcesContent":["/**\n * <mbx-marker-button>: \"Skip intro\" over the picture while playback is in\n * the opening credits, \"Skip credits\" in the closing ones, and \"Skip\" with\n * the marker's own label in any other range the page named. A press moves\n * the playhead to the range's end. Blocked ranges never show it: the\n * player moves past those itself. The words come from\n * `label-opening-credits`, `label-closing-credits` and `label-skip`.\n *\n * While the player carries `upnext`, set by a card that offers the next\n * item, the button leaves the closing credits to it.\n */\nimport type { Marker } from '../controls/markers.js';\nimport type { PlayerHost } from '../host.js';\nimport type { Messages } from '../messages.js';\nimport { Component } from './component.js';\nimport STYLE_CSS from './marker-button.css?inline';\nimport { BUTTON_STYLE, style } from './shared.js';\n\n/** The id and the English of the button over each kind of range. */\nconst WORDS: Readonly<Record<string, readonly [keyof Messages, string]>> = {\n 'opening-credits': ['skipIntro', 'Skip intro'],\n 'closing-credits': ['skipCredits', 'Skip credits'],\n};\n\nexport class MbxMarkerButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label-opening-credits', 'label-closing-credits', 'label-skip'];\n }\n\n declare private readonly button: HTMLButtonElement;\n declare private readonly text: HTMLSpanElement;\n /** The range the button skips, or null while playback is in none. */\n declare private marker: Marker | null;\n /** Watches the bar and the title: the button sits above whichever is taller. */\n declare private resizer: ResizeObserver | null;\n\n constructor() {\n super();\n this.marker = null;\n this.resizer = null;\n const root = this.attachShadow({ mode: 'open' });\n this.button = document.createElement('button');\n this.button.type = 'button';\n this.button.setAttribute('part', 'button');\n this.text = document.createElement('span');\n this.text.textContent = 'Skip';\n const chevron = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n chevron.setAttribute('viewBox', '0 0 32 32');\n chevron.setAttribute('aria-hidden', 'true');\n chevron.setAttribute('part', 'icon');\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('d', 'M12 8l8 8l-8 8');\n chevron.append(path);\n this.button.append(this.text, chevron);\n this.button.addEventListener('click', () => {\n const video = this.player?.video;\n if (video !== undefined && this.marker !== null) video.currentTime = this.marker.end;\n });\n root.append(style(BUTTON_STYLE + STYLE_CSS), this.button);\n }\n\n override connectedCallback(): void {\n // Hidden until playback is in a marker; a constructor may not set attributes.\n this.hidden = true;\n super.connectedCallback();\n }\n\n protected override attach(player: PlayerHost): void {\n this.listen(player.video, ['timeupdate', 'seeking', 'emptied'], () => {\n this.render();\n });\n this.listen(player, ['markerschange'], () => {\n this.render();\n });\n // An up next card, from a playlist, takes over the closing credits.\n this.observe(player, ['upnext'], () => {\n this.render();\n });\n if (typeof ResizeObserver !== 'undefined') {\n this.resizer = new ResizeObserver(() => {\n this.fit(player);\n });\n this.resizer.observe(player);\n const bar = player.querySelector('mbx-control-bar');\n if (bar !== null) this.resizer.observe(bar);\n }\n this.fit(player);\n this.render();\n }\n\n protected override detach(): void {\n this.resizer?.disconnect();\n this.resizer = null;\n }\n\n /**\n * Lifts the button above the bar's rows: the bar's box less the padding\n * over them, its fade. The title sits on the other side, so the button\n * stays where it is while the title shows.\n */\n private fit(player: PlayerHost): void {\n const bar = player.querySelector('mbx-control-bar');\n const fade = bar === null ? 0 : Number.parseFloat(getComputedStyle(bar).paddingTop) || 0;\n const lift = bar === null ? 0 : bar.getBoundingClientRect().height - fade;\n this.style.setProperty('--mbx-marker-lift', `${Math.max(0, lift)}px`);\n }\n\n protected override render(): void {\n const player = this.player;\n this.marker =\n player?.markers\n .within(player.video.currentTime)\n .find((marker) => marker.kind !== 'blocked') ?? null;\n // A playlist's up next card offers the next item over the closing\n // credits, so this button steps aside while the player carries `upnext`.\n if (this.marker?.kind === 'closing-credits' && player?.hasAttribute('upnext') === true) {\n this.marker = null;\n }\n this.hidden = this.marker === null;\n if (this.marker === null) return;\n const kind = this.marker.kind;\n const skip = this.word('label-skip', 'skip', 'Skip');\n const known = WORDS[kind];\n this.text.textContent =\n known !== undefined\n ? this.word(`label-${kind}`, ...known)\n : (this.getAttribute(`label-${kind}`) ??\n (this.marker.label === undefined ? skip : `${skip} ${this.pageText(this.marker.label)}`));\n }\n}\n"],"mappings":";;;AAeA,MAAA,YAAA;;AAIA,MAAA,QAAA;CACA,mBAAA,CAAA,aAAA,YAAA;CACA,mBAAA,CAAA,eAAA,cAAA;AACA;AAEA,IAAA,kBAAA,cAAA,UAAA;CACA,WAAA,qBAAA;EACA,OAAA;GAAA;GAAA;GAAA;EAAA;CACA;CASA,cAAA;EACA,MAAA;EACA,K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KAAA,OAAA;CACA;CAEA,SAAA;EACA,KAAA,SAAA,WAAA;EACA,KAAA,UAAA;CACA;;;;;;CAOA,IAAA,QAAA;EACA,MAAA,MAAA,OAAA,cAAA,iBAAA;EACA,MAAA,OAAA,QAAA,OAAA,IAAA,OAAA,WAAA,iBAAA,GAAA,CAAA,CAAA,UAAA,KAAA;EACA,MAAA,OAAA,QAAA,OAAA,IAAA,IAAA,sBAAA,CAAA,CAAA,SAAA;EACA,KAAA,MAAA,YAAA,qBAAA,GAAA,KAAA,IAAA,GAAA,IAAA,EAAA,GAAA;CACA;CAEA,SAAA;EACA,MAAA,SAAA,KAAA;EACA,KAAA,SACA,QAAA,QACA,OAAA,OAAA,MAAA,WAAA,CAAA,CACA,MAAA,WAAA,OAAA,SAAA,SAAA,KAAA;EAGA,IAAA,KAAA,QAAA,SAAA,qBAAA,QAAA,aAAA,QAAA,MAAA,MACA,KAAA,SAAA;EAEA,KAAA,SAAA,KAAA,WAAA;EACA,IAAA,KAAA,WAAA,MAAA;EACA,MAAA,OAAA,KAAA,OAAA;EACA,MAAA,OAAA,KAAA,KAAA,cAAA,QAAA,MAAA;EACA,MAAA,QAAA,MAAA;EACA,KAAA,KAAA,cACA,UAAA,KAAA,IACA,KAAA,KAAA,SAAA,QAAA,GAAA,KAAA,IACA,KAAA,aAAA,SAAA,MAAA,MACA,KAAA,OAAA,UAAA,KAAA,IAAA,OAAA,GAAA,KAAA,GAAA,KAAA,SAAA,KAAA,OAAA,KAAA;CACA;AACA"}
|
|
@@ -63,6 +63,8 @@ export declare class MbxSeekBar extends Component {
|
|
|
63
63
|
private readonly buffered;
|
|
64
64
|
/** The ranges the page marked blocked, drawn as a broken line: they never play. */
|
|
65
65
|
private readonly blocked;
|
|
66
|
+
/** The ad breaks, as ticks, and as spans where a break replaces a part. */
|
|
67
|
+
private readonly breaks;
|
|
66
68
|
private readonly hover;
|
|
67
69
|
private readonly edge;
|
|
68
70
|
private readonly preview;
|
|
@@ -155,6 +157,8 @@ export declare class MbxSeekBar extends Component {
|
|
|
155
157
|
private blockedRanges;
|
|
156
158
|
/** One child of `layer` per range, each named `part`, placed along the track. */
|
|
157
159
|
private paintRanges;
|
|
160
|
+
/** The ad breaks inside the bar's range: a tick at each start, a span where one replaces a part. */
|
|
161
|
+
private paintBreaks;
|
|
158
162
|
/** Whether a live window is wide enough to be worth a bar. */
|
|
159
163
|
private worthSeeking;
|
|
160
164
|
/** The hover marker and the preview follow the pointer, clamped to the bar. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seek-bar.d.ts","sourceRoot":"","sources":["../../src/elements/seek-bar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAYH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAoE3C,qBAAa,UAAW,SAAQ,SAAS;IACvC,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAYjD;IAED,iBAAyB,GAAG,CAAS;IACrC,iBAAyB,QAAQ,CAAc;IAC/C,mFAAmF;IACnF,iBAAyB,OAAO,CAAc;IAC9C,iBAAyB,KAAK,CAAc;IAC5C,iBAAyB,IAAI,CAAc;IAC3C,iBAAyB,OAAO,CAAc;IAC9C,iBAAyB,KAAK,CAAc;IAC5C,iBAAyB,IAAI,CAAc;IAC3C,iBAAyB,IAAI,CAAc;IAC3C,iBAAyB,OAAO,CAAc;IAC9C,iBAAyB,WAAW,CAAoB;IACxD,QAAgB,IAAI,CAAO;IAC3B,wEAAwE;IACxE,QAAgB,OAAO,CAAgB;IACvC,qFAAqF;IACrF,QAAgB,MAAM,CAAU;IAChC,kGAAkG;IAClG,QAAgB,KAAK,CAAS;IAC9B,kFAAkF;IAClF,QAAgB,MAAM,CAAgB;IACtC,QAAgB,WAAW,CAAS;IACpC,iEAAiE;I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IAC/E,OAAO,CAAC,KAAK;IASb,kFAAkF;IAClF,OAAO,CAAC,SAAS;IA2BjB,OAAO,CAAC,KAAK;cAOM,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAqChC,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAWhC,MAAM,IAAI,IAAI;CA2BlC"}
|
|
@@ -8,7 +8,7 @@ import { bufferGoal, live, optional, span, wall } from "../controls/session.js";
|
|
|
8
8
|
import { chapterAt, chapters, followChapters } from "../controls/chapters.js";
|
|
9
9
|
import { slider } from "../controls/slider.js";
|
|
10
10
|
// src/elements/seek-bar.ts
|
|
11
|
-
const STYLE_CSS = ":host,[part~=slider]{flex:1}[part~=thumb]{width:1em;height:1em;margin:-.5em 0 0 -.5em;box-shadow:0 1px 3px #0006}[part~=buffered]{position:absolute;top:0;bottom:0;left:0;right:0}[part~=blocked]{pointer-events:none;position:absolute;top:0;bottom:0;left:0;right:0}[part~=blocked-range]{background:var(--mbx-blocked,#000000bf);position:absolute;top:0;bottom:0}[part~=buffered-range]{background:#ffffff4d;position:absolute;top:0;bottom:0}[part~=hover]{background:var(--mbx-text);width:.125em;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=edge]{background:var(--mbx-live);width:.125em;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=preview]{background:var(--mbx-surface);border-radius:var(--mbx-radius);font-variant-numeric:tabular-nums;white-space:nowrap;pointer-events:none;flex-direction:column;align-items:center;margin-bottom:.3077em;padding:.1538em;font-size:.8125em;display:flex;position:absolute;bottom:100%;transform:translate(-50%)}[part~=preview]>:not([hidden])~:not([hidden]){margin-top:.125em}[part~=preview-image]{border-radius:2px;position:relative;overflow:hidden}[part~=preview-frame]{border-radius:2px;display:block}[part~=preview-tile]{transform-origin:0 0;background-repeat:no-repeat;position:absolute;top:0;left:0}[part~=preview-time]{padding:0 .3077em}[part~=preview-title]{text-overflow:ellipsis;max-width:18.4615em;padding:0 .3077em;overflow:hidden}[hidden]{display:none}";
|
|
11
|
+
const STYLE_CSS = ":host,[part~=slider]{flex:1}[part~=thumb]{width:1em;height:1em;margin:-.5em 0 0 -.5em;box-shadow:0 1px 3px #0006}[part~=buffered]{position:absolute;top:0;bottom:0;left:0;right:0}[part~=blocked]{pointer-events:none;position:absolute;top:0;bottom:0;left:0;right:0}[part~=blocked-range]{background:var(--mbx-blocked,#000000bf);position:absolute;top:0;bottom:0}[part~=break]{background:var(--mbx-ad,#f5c518);width:.25em;margin-left:-.125em;position:absolute;top:0;bottom:0}[part~=break][part~=span]{margin-left:0}[part~=break][part~=played]{opacity:.4}[part~=buffered-range]{background:#ffffff4d;position:absolute;top:0;bottom:0}[part~=hover]{background:var(--mbx-text);width:.125em;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=edge]{background:var(--mbx-live);width:.125em;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=preview]{background:var(--mbx-surface);border-radius:var(--mbx-radius);font-variant-numeric:tabular-nums;white-space:nowrap;pointer-events:none;flex-direction:column;align-items:center;margin-bottom:.3077em;padding:.1538em;font-size:.8125em;display:flex;position:absolute;bottom:100%;transform:translate(-50%)}[part~=preview]>:not([hidden])~:not([hidden]){margin-top:.125em}[part~=preview-image]{border-radius:2px;position:relative;overflow:hidden}[part~=preview-frame]{border-radius:2px;display:block}[part~=preview-tile]{transform-origin:0 0;background-repeat:no-repeat;position:absolute;top:0;left:0}[part~=preview-time]{padding:0 .3077em}[part~=preview-title]{text-overflow:ellipsis;max-width:18.4615em;padding:0 .3077em;overflow:hidden}[hidden]{display:none}";
|
|
12
12
|
const STEP = 5;
|
|
13
13
|
/** Under `key-mode="preview"`, a target seeks this long after the last key. */
|
|
14
14
|
const KEY_COMMIT_MS = 1e3;
|
|
@@ -108,12 +108,13 @@ var MbxSeekBar = class extends Component {
|
|
|
108
108
|
});
|
|
109
109
|
this.buffered = el("div", "buffered");
|
|
110
110
|
this.blocked = el("div", "blocked");
|
|
111
|
+
this.breaks = el("div", "breaks");
|
|
111
112
|
this.hover = el("div", "hover");
|
|
112
113
|
this.edge = el("div", "edge");
|
|
113
114
|
this.hover.hidden = true;
|
|
114
115
|
this.edge.hidden = true;
|
|
115
116
|
this.bar.track.prepend(this.buffered);
|
|
116
|
-
this.bar.track.append(this.blocked, this.hover, this.edge);
|
|
117
|
+
this.bar.track.append(this.blocked, this.breaks, this.hover, this.edge);
|
|
117
118
|
this.preview = el("div", "preview");
|
|
118
119
|
this.image = el("div", "preview-image");
|
|
119
120
|
this.tile = el("div", "preview-tile");
|
|
@@ -399,6 +400,20 @@ var MbxSeekBar = class extends Component {
|
|
|
399
400
|
node.style.width = percent(part[1] - part[0]);
|
|
400
401
|
}
|
|
401
402
|
}
|
|
403
|
+
/** The ad breaks inside the bar's range: a tick at each start, a span where one replaces a part. */
|
|
404
|
+
paintBreaks() {
|
|
405
|
+
const { start, end } = this.range;
|
|
406
|
+
const marks = (this.player?.breaks.list ?? []).filter((mark) => mark.start >= start && mark.start <= end);
|
|
407
|
+
while (this.breaks.childElementCount > marks.length) this.breaks.lastElementChild?.remove();
|
|
408
|
+
while (this.breaks.childElementCount < marks.length) this.breaks.append(el("div", "break"));
|
|
409
|
+
marks.forEach((mark, i) => {
|
|
410
|
+
const node = this.breaks.children[i];
|
|
411
|
+
const span = mark.end !== void 0 && mark.end > mark.start;
|
|
412
|
+
node.setAttribute("part", `break${span ? " span" : ""}${mark.played === true ? " played" : ""}`);
|
|
413
|
+
node.style.left = percent(fraction(mark.start, this.range));
|
|
414
|
+
node.style.width = span ? percent(fraction(Math.min(mark.end ?? end, end), this.range) - fraction(mark.start, this.range)) : "";
|
|
415
|
+
});
|
|
416
|
+
}
|
|
402
417
|
/** Whether a live window is wide enough to be worth a bar. */
|
|
403
418
|
worthSeeking() {
|
|
404
419
|
const goals = number(this, "live-window", LIVE_WINDOW);
|
|
@@ -447,7 +462,7 @@ var MbxSeekBar = class extends Component {
|
|
|
447
462
|
};
|
|
448
463
|
this.listen(player.video, EVENTS, tick);
|
|
449
464
|
this.keep(followChapters(player, tick));
|
|
450
|
-
this.listen(player, ["markerschange"], tick);
|
|
465
|
+
this.listen(player, ["markerschange", "breakschange"], tick);
|
|
451
466
|
this.listen(player, ["sourcechange"], () => {
|
|
452
467
|
this.drag = "none";
|
|
453
468
|
this.stopAiming();
|
|
@@ -492,6 +507,7 @@ var MbxSeekBar = class extends Component {
|
|
|
492
507
|
this.bar.range(this.range.start, this.range.end);
|
|
493
508
|
this.paintRanges(this.buffered, spans(video.buffered), "buffered-range");
|
|
494
509
|
this.paintRanges(this.blocked, this.blockedRanges(), "blocked-range");
|
|
510
|
+
this.paintBreaks();
|
|
495
511
|
this.paintChapters();
|
|
496
512
|
this.edge.hidden = !on;
|
|
497
513
|
if (api !== void 0 && api.edge !== null) this.edge.style.left = percent(fraction(api.edge, this.range));
|