@mux/mux-audio 0.6.1 → 0.6.2-canary.2-830286f
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/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/mux-audio.js +1 -1
- package/dist/mux-audio.js.map +1 -1
- package/dist/mux-audio.mjs +1 -1
- package/dist/mux-audio.mjs.map +1 -1
- package/package.json +3 -4
- package/LICENSE +0 -9
- package/coverage/lcov-report/CustomAudioElement.js.html +0 -865
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/env.ts.html +0 -130
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -146
- package/coverage/lcov-report/index.ts.html +0 -1045
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov.info +0 -754
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _=Object.create;var c=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var f=i=>c(i,"__esModule",{value:!0});var I=(i,t)=>{f(i);for(var s in t)c(i,s,{get:t[s],enumerable:!0})},P=(i,t,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of M(t))!C.call(i,e)&&e!=="default"&&c(i,e,{get:()=>t[e],enumerable:!(s=T(t,e))||s.enumerable});return i},x=i=>P(f(c(i!=null?_(O(i)):{},"default",i&&i.__esModule&&"default"in i?{get:()=>i.default,enumerable:!0}:{value:i,enumerable:!0})),i);I(exports,{AudioEvents:()=>m,MediaError:()=>r.MediaError,default:()=>w});var r=x(require("@mux/playback-core"));var v=()=>{try{return"0.6.
|
|
1
|
+
var _=Object.create;var c=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var f=i=>c(i,"__esModule",{value:!0});var I=(i,t)=>{f(i);for(var s in t)c(i,s,{get:t[s],enumerable:!0})},P=(i,t,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of M(t))!C.call(i,e)&&e!=="default"&&c(i,e,{get:()=>t[e],enumerable:!(s=T(t,e))||s.enumerable});return i},x=i=>P(f(c(i!=null?_(O(i)):{},"default",i&&i.__esModule&&"default"in i?{get:()=>i.default,enumerable:!0}:{value:i,enumerable:!0})),i);I(exports,{AudioEvents:()=>m,MediaError:()=>r.MediaError,default:()=>w});var r=x(require("@mux/playback-core"));var v=()=>{try{return"0.6.2-canary.2-830286f"}catch{}return"UNKNOWN"},D=v(),p=()=>D;var m=["abort","canplay","canplaythrough","durationchange","emptied","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"],b=document.createElement("template");b.innerHTML=`
|
|
2
2
|
<style>
|
|
3
3
|
:host {
|
|
4
4
|
/* display:inline (like the native el) makes it so you can't fill
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/env.ts", "../src/CustomAudioElement.js"],
|
|
4
4
|
"sourcesContent": ["import {\n initialize,\n setupAutoplay,\n MuxMediaProps,\n StreamTypes,\n ValueOf,\n toMuxVideoURL,\n teardown,\n Metadata,\n mux,\n generatePlayerInitTime,\n MediaError,\n} from '@mux/playback-core';\nimport type { PlaybackEngine, UpdateAutoplay, ExtensionMimeTypeMap } from '@mux/playback-core';\nimport { getPlayerVersion } from './env';\n// this must be imported after playback-core for the polyfill to be included\nimport CustomAudioElement, { AudioEvents } from './CustomAudioElement';\n\n/** @TODO make the relationship between name+value smarter and more deriveable (CJP) */\ntype AttributeNames = {\n ENV_KEY: 'env-key';\n DEBUG: 'debug';\n METADATA_URL: 'metadata-url';\n METADATA_VIDEO_ID: 'metadata-video-id';\n METADATA_VIDEO_TITLE: 'metadata-video-title';\n METADATA_VIEWER_USER_ID: 'metadata-viewer-user-id';\n BEACON_COLLECTION_DOMAIN: 'beacon-collection-domain';\n PLAYBACK_ID: 'playback-id';\n PREFER_MSE: 'prefer-mse';\n TYPE: 'type';\n STREAM_TYPE: 'stream-type';\n START_TIME: 'start-time';\n};\n\nconst Attributes: AttributeNames = {\n ENV_KEY: 'env-key',\n DEBUG: 'debug',\n PLAYBACK_ID: 'playback-id',\n METADATA_URL: 'metadata-url',\n PREFER_MSE: 'prefer-mse',\n METADATA_VIDEO_ID: 'metadata-video-id',\n METADATA_VIDEO_TITLE: 'metadata-video-title',\n METADATA_VIEWER_USER_ID: 'metadata-viewer-user-id',\n BEACON_COLLECTION_DOMAIN: 'beacon-collection-domain',\n TYPE: 'type',\n STREAM_TYPE: 'stream-type',\n START_TIME: 'start-time',\n};\n\nconst AttributeNameValues = Object.values(Attributes);\n\nconst playerSoftwareVersion = getPlayerVersion();\nconst playerSoftwareName = 'mux-audio';\n\nclass MuxAudioElement extends CustomAudioElement<HTMLAudioElement> implements Partial<MuxMediaProps> {\n static get observedAttributes() {\n return [...AttributeNameValues, ...(CustomAudioElement.observedAttributes ?? [])];\n }\n\n // Keeping this named \"__hls\" since it's exposed for unadvertised \"advanced usage\" via getter that assumes specifically hls.js (CJP)\n protected __hls?: PlaybackEngine;\n protected __playerInitTime: number;\n protected __metadata: Readonly<Metadata> = {};\n protected __updateAutoplay?: UpdateAutoplay;\n\n constructor() {\n super();\n this.__playerInitTime = generatePlayerInitTime();\n }\n\n get playerInitTime() {\n return this.__playerInitTime;\n }\n\n get playerSoftwareName() {\n return playerSoftwareName;\n }\n\n get playerSoftwareVersion() {\n return playerSoftwareVersion;\n }\n\n /**\n * @deprecated please use ._hls instead\n */\n get hls() {\n console.warn('<mux-audio>.hls is deprecated, please use ._hls instead');\n return this._hls;\n }\n\n get _hls() {\n return this.__hls;\n }\n\n get mux(): Readonly<HTMLAudioElement['mux']> | undefined {\n return this.nativeEl.mux;\n }\n\n get src() {\n // Use the attribute value as the source of truth.\n // No need to store it in two places.\n // This avoids needing a to read the attribute initially and update the src.\n return this.getAttribute('src') as string;\n }\n\n set src(val: string) {\n // If being set by attributeChangedCallback,\n // dont' cause an infinite loop\n if (val === this.src) return;\n\n if (val == null) {\n this.removeAttribute('src');\n } else {\n this.setAttribute('src', val);\n }\n }\n\n /** @TODO write a generic module for well defined primitive types -> attribute getter/setters/removers (CJP) */\n get debug(): boolean {\n return this.getAttribute(Attributes.DEBUG) != null;\n }\n\n set debug(val: boolean) {\n // dont' cause an infinite loop\n if (val === this.debug) return;\n\n if (val) {\n this.setAttribute(Attributes.DEBUG, '');\n } else {\n this.removeAttribute(Attributes.DEBUG);\n }\n }\n\n get startTime(): number | undefined {\n const val = this.getAttribute(Attributes.START_TIME);\n if (val == null) return undefined;\n const num = +val;\n return !Number.isNaN(num) ? num : undefined;\n }\n\n set startTime(val: number | undefined) {\n // dont' cause an infinite loop\n if (val === this.startTime) return;\n\n if (val == null) {\n this.removeAttribute(Attributes.START_TIME);\n } else {\n this.setAttribute(Attributes.START_TIME, `${val}`);\n }\n }\n\n get playbackId(): string | undefined {\n return this.getAttribute(Attributes.PLAYBACK_ID) ?? undefined;\n }\n\n set playbackId(val: string | undefined) {\n // dont' cause an infinite loop\n if (val === this.playbackId) return;\n\n if (val) {\n this.setAttribute(Attributes.PLAYBACK_ID, val);\n } else {\n this.removeAttribute(Attributes.PLAYBACK_ID);\n }\n }\n\n get envKey(): string | undefined {\n return this.getAttribute(Attributes.ENV_KEY) ?? undefined;\n }\n\n set envKey(val: string | undefined) {\n // dont' cause an infinite loop\n if (val === this.envKey) return;\n\n if (val) {\n this.setAttribute(Attributes.ENV_KEY, val);\n } else {\n this.removeAttribute(Attributes.ENV_KEY);\n }\n }\n\n get beaconCollectionDomain(): string | undefined {\n return this.getAttribute(Attributes.BEACON_COLLECTION_DOMAIN) ?? undefined;\n }\n\n set beaconCollectionDomain(val: string | undefined) {\n // dont' cause an infinite loop\n if (val === this.beaconCollectionDomain) return;\n\n if (val) {\n this.setAttribute(Attributes.BEACON_COLLECTION_DOMAIN, val);\n } else {\n this.removeAttribute(Attributes.BEACON_COLLECTION_DOMAIN);\n }\n }\n\n get streamType(): ValueOf<StreamTypes> | undefined {\n // getAttribute doesn't know that this attribute is well defined. Should explore extending for MuxVideo (CJP)\n return (this.getAttribute(Attributes.STREAM_TYPE) as ValueOf<StreamTypes>) ?? undefined;\n }\n\n set streamType(val: ValueOf<StreamTypes> | undefined) {\n // dont' cause an infinite loop\n if (val === this.streamType) return;\n\n if (val) {\n this.setAttribute(Attributes.STREAM_TYPE, val);\n } else {\n this.removeAttribute(Attributes.STREAM_TYPE);\n }\n }\n\n /** @TODO Followup: naming convention: all lower (common per HTMLElement props) vs. camel (common per JS convention) (CJP) */\n get preferMse(): boolean {\n return this.getAttribute(Attributes.PREFER_MSE) != null;\n }\n\n set preferMse(val: boolean) {\n if (val) {\n this.setAttribute(Attributes.PREFER_MSE, '');\n } else {\n this.removeAttribute(Attributes.PREFER_MSE);\n }\n }\n\n get metadata() {\n return this.__metadata;\n }\n\n set metadata(val: Readonly<Metadata> | undefined) {\n this.__metadata = val ?? {};\n if (!!this.mux) {\n /** @TODO Link to docs for a more detailed discussion (CJP) */\n console.info(\n 'Some metadata values may not be overridable at this time. Make sure you set all metadata to override before setting the src.'\n );\n this.mux.emit('hb', this.__metadata);\n }\n }\n\n load() {\n const nextHlsInstance = initialize(this as Partial<MuxMediaProps>, this.nativeEl, this.__hls);\n this.__hls = nextHlsInstance;\n const updateAutoplay = setupAutoplay(this.nativeEl, this.autoplay, nextHlsInstance);\n this.__updateAutoplay = updateAutoplay;\n }\n\n unload() {\n teardown(this.nativeEl, this.__hls);\n this.__hls = undefined;\n }\n\n attributeChangedCallback(attrName: string, oldValue: string | null, newValue: string | null) {\n switch (attrName) {\n case 'src':\n const hadSrc = !!oldValue;\n const hasSrc = !!newValue;\n if (!hadSrc && hasSrc) {\n this.load();\n } else if (hadSrc && !hasSrc) {\n this.unload();\n /** @TODO Test this thoroughly (async?) and confirm unload() necessary (CJP) */\n } else if (hadSrc && hasSrc) {\n this.unload();\n this.load();\n }\n break;\n case 'autoplay':\n this.__updateAutoplay?.(newValue);\n break;\n case Attributes.PLAYBACK_ID:\n /** @TODO Improv+Discuss - how should playback-id update wrt src attr changes (and vice versa) (CJP) */\n this.src = toMuxVideoURL(newValue ?? undefined) as string;\n break;\n case Attributes.DEBUG:\n const debug = this.debug;\n if (!!this.mux) {\n /** @TODO Link to docs for a more detailed discussion (CJP) */\n console.info(\n 'Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src.'\n );\n }\n if (!!this._hls) {\n this._hls.config.debug = debug;\n }\n break;\n case Attributes.METADATA_URL:\n if (newValue) {\n fetch(newValue)\n .then((resp) => resp.json())\n .then((json) => (this.metadata = json))\n .catch((_err) => console.error(`Unable to load or parse metadata JSON from metadata-url ${newValue}!`));\n }\n break;\n default:\n break;\n }\n\n super.attributeChangedCallback(attrName, oldValue, newValue);\n }\n\n disconnectedCallback() {\n this.unload();\n }\n}\n\ntype MuxAudioElementType = typeof MuxAudioElement;\ndeclare global {\n var MuxAudioElement: MuxAudioElementType;\n}\n\nif (!globalThis.customElements.get('mux-audio')) {\n globalThis.customElements.define('mux-audio', MuxAudioElement);\n /** @TODO consider externalizing this (breaks standard modularity) */\n globalThis.MuxAudioElement = MuxAudioElement;\n}\n\nexport { PlaybackEngine, PlaybackEngine as Hls, ExtensionMimeTypeMap as MimeTypes, MediaError, AudioEvents };\n\nexport default MuxAudioElement;\n", "export const isMaybeBrowser = () => typeof window != 'undefined';\n// @ts-ignore\nexport const isMaybeServer = () => typeof global != 'undefined';\n\nconst getEnvPlayerVersion = () => {\n try {\n // @ts-ignore\n return PLAYER_VERSION as string;\n } catch {}\n return 'UNKNOWN';\n};\n\nconst player_version: string = getEnvPlayerVersion();\n\nexport const getPlayerVersion = () => player_version;\n", "/**\n * Custom Audio Element\n * The goal is to create an element that works just like the audio element\n * but can be extended/sub-classed, because native elements cannot be\n * extended today across browsers.\n */\n\nexport const AudioEvents = [\n 'abort',\n 'canplay',\n 'canplaythrough',\n 'durationchange',\n 'emptied',\n 'ended',\n 'error',\n 'loadeddata',\n 'loadedmetadata',\n 'loadstart',\n 'pause',\n 'play',\n 'playing',\n 'progress',\n 'ratechange',\n 'seeked',\n 'seeking',\n 'stalled',\n 'suspend',\n 'timeupdate',\n 'volumechange',\n 'waiting',\n];\n\nconst template = document.createElement('template');\n// Could you get styles to apply by passing a global button from global to shadow?\n\ntemplate.innerHTML = `\n<style>\n :host {\n /* display:inline (like the native el) makes it so you can't fill\n the container with the native el */\n display: inline-block;\n box-sizing: border-box;\n\n width: auto;\n height: auto;\n }\n\n audio {\n max-width: 100%;\n max-height: 100%;\n min-width: 100%;\n min-height: 100%;\n }\n\n</style>\n\n<audio part=\"audio\" crossorigin></audio>\n<slot></slot>\n`;\n\nclass CustomAudioElement extends HTMLElement {\n constructor() {\n super();\n\n this.attachShadow({ mode: 'open' });\n this.shadowRoot.appendChild(template.content.cloneNode(true));\n const nativeEl = (this.nativeEl = this.shadowRoot.querySelector('audio'));\n\n // Initialize all the attribute properties\n // This is required before attributeChangedCallback is called after construction\n // so the initial state of all the attributes are forwarded to the native element.\n Array.from(this.attributes).forEach((attrNode) => {\n this.forwardAttribute(attrNode.name, null, attrNode.value);\n });\n\n // Neither Chrome or Firefox support setting the muted attribute\n // after using document.createElement.\n // One way to get around this would be to build the native tag as a string.\n // But just fixing it manually for now.\n // Apparently this may also be an issue with <input checked> for buttons\n if (nativeEl.defaultMuted) {\n nativeEl.muted = true;\n }\n\n // The audio events are dispatched on the CustomAudioElement instance.\n // This makes it possible to add event listeners before the element is upgraded.\n AudioEvents.forEach((type) => {\n nativeEl.addEventListener(type, (evt) => {\n this.dispatchEvent(new CustomEvent(evt.type, { detail: evt.detail }));\n });\n });\n\n const slotEl = this.shadowRoot.querySelector('slot');\n slotEl.addEventListener('slotchange', () => {\n slotEl.assignedElements().forEach((el) => {\n nativeEl.appendChild(el);\n });\n });\n }\n\n // observedAttributes is required to trigger attributeChangedCallback\n // for any attributes on the custom element.\n // Attributes need to be the lowercase word, e.g. crossorigin, not crossOrigin\n static get observedAttributes() {\n let attrs = [];\n\n // Instead of manually creating a list of all observed attributes,\n // observe any getter/setter prop name (lowercased)\n Object.getOwnPropertyNames(this.prototype).forEach((propName) => {\n let isFunc = false;\n\n // Non-func properties throw errors because it's not an instance\n try {\n if (typeof this.prototype[propName] === 'function') {\n isFunc = true;\n }\n } catch (e) {}\n\n // Exclude functions and constants\n if (!isFunc && propName !== propName.toUpperCase()) {\n attrs.push(propName.toLowerCase());\n }\n });\n\n // Include any attributes from the super class (recursive)\n const supAttrs = Object.getPrototypeOf(this).observedAttributes;\n\n if (supAttrs) {\n attrs = attrs.concat(supAttrs);\n }\n\n return attrs;\n }\n\n // We need to handle sub-class custom attributes differently from\n // attrs meant to be passed to the internal native el.\n attributeChangedCallback(attrName, oldValue, newValue) {\n this.forwardAttribute(attrName, oldValue, newValue);\n }\n\n forwardAttribute(attrName, oldValue, newValue) {\n // Find the matching prop for custom attributes\n const ownProps = Object.getOwnPropertyNames(Object.getPrototypeOf(this));\n const propName = arrayFindAnyCase(ownProps, attrName);\n\n // Check if this is the original custom native elemnt or a subclass\n const isBaseElement = Object.getPrototypeOf(this.constructor).toString().indexOf('function HTMLElement') === 0;\n\n // If this is a subclass custom attribute we want to set the\n // matching property on the subclass\n if (propName && !isBaseElement) {\n // Boolean props should never start as null\n if (typeof this[propName] == 'boolean') {\n // null is returned when attributes are removed i.e. boolean attrs\n if (newValue === null) {\n this[propName] = false;\n } else {\n // The new value might be an empty string, which is still true\n // for boolean attributes\n this[propName] = true;\n }\n } else {\n this[propName] = newValue;\n }\n } else {\n // When this is the original Custom Element, or the subclass doesn't\n // have a matching prop, pass it through.\n if (newValue === null) {\n this.nativeEl.removeAttribute(attrName);\n } else {\n // Ignore a few that don't need to be passed through just in case\n // it creates unexpected behavior.\n if (['id', 'class'].indexOf(attrName) === -1) {\n this.nativeEl.setAttribute(attrName, newValue);\n }\n }\n }\n }\n\n connectedCallback() {}\n}\n\n// Map all native element properties to the custom element\n// so that they're applied to the native element.\n// Skipping HTMLElement because of things like \"attachShadow\"\n// causing issues. Most of those props still need to apply to\n// the custom element.\n// But includign EventTarget props because most events emit from\n// the native element.\nlet nativeElProps = [];\n\n// Can't check typeof directly on element prototypes without\n// throwing Illegal Invocation errors, so creating an element\n// to check on instead.\nconst nativeElTest = document.createElement('audio');\n\n// Deprecated props throw warnings if used, so exclude them\nconst deprecatedProps = ['webkitDisplayingFullscreen', 'webkitSupportsFullscreen'];\n\n// Walk the prototype chain up to HTMLElement.\n// This will grab all super class props in between.\n// i.e. AudioElement and MediaElement\nfor (\n let proto = Object.getPrototypeOf(nativeElTest);\n proto && proto !== HTMLElement.prototype;\n proto = Object.getPrototypeOf(proto)\n) {\n Object.keys(proto).forEach((key) => {\n if (deprecatedProps.indexOf(key) === -1) {\n nativeElProps.push(key);\n }\n });\n}\n\n// Passthrough native el functions from the custom el to the native el\nnativeElProps.forEach((prop) => {\n const type = typeof nativeElTest[prop];\n\n if (type == 'function') {\n // Function\n CustomAudioElement.prototype[prop] = function () {\n return this.nativeEl[prop].apply(this.nativeEl, arguments);\n };\n } else {\n // Getter\n let config = {\n get() {\n return this.nativeEl[prop];\n },\n };\n\n if (prop !== prop.toUpperCase()) {\n // Setter (not a CONSTANT)\n config.set = function (val) {\n this.nativeEl[prop] = val;\n };\n }\n\n Object.defineProperty(CustomAudioElement.prototype, prop, config);\n }\n});\n\nfunction arrayFindAnyCase(arr, word) {\n let found = null;\n\n arr.forEach((item) => {\n if (item.toLowerCase() == word.toLowerCase()) {\n found = item;\n }\n });\n\n return found;\n}\n\nif (!globalThis.customElements.get('custom-audio')) {\n globalThis.customElements.define('custom-audio', CustomAudioElement);\n globalThis.CustomAudioElement = CustomAudioElement;\n}\n\nexport default CustomAudioElement;\n"],
|
|
5
|
-
"mappings": "mlBAAA,+EAYO,iCCRP,GAAM,GAAsB,IAAM,CAChC,GAAI,CAEF,MAAO,
|
|
5
|
+
"mappings": "mlBAAA,+EAYO,iCCRP,GAAM,GAAsB,IAAM,CAChC,GAAI,CAEF,MAAO,8BACP,EACF,MAAO,WAGH,EAAyB,IAElB,EAAmB,IAAM,ECP/B,GAAM,GAAc,CACzB,QACA,UACA,iBACA,iBACA,UACA,QACA,QACA,aACA,iBACA,YACA,QACA,OACA,UACA,WACA,aACA,SACA,UACA,UACA,UACA,aACA,eACA,WAGI,EAAW,SAAS,cAAc,YAGxC,EAAS,UAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAyBrB,mBAAiC,YAAY,CAC3C,aAAc,CACZ,QAEA,KAAK,aAAa,CAAE,KAAM,SAC1B,KAAK,WAAW,YAAY,EAAS,QAAQ,UAAU,KACvD,GAAM,GAAY,KAAK,SAAW,KAAK,WAAW,cAAc,SAKhE,MAAM,KAAK,KAAK,YAAY,QAAQ,AAAC,GAAa,CAChD,KAAK,iBAAiB,EAAS,KAAM,KAAM,EAAS,SAQlD,EAAS,cACX,GAAS,MAAQ,IAKnB,EAAY,QAAQ,AAAC,GAAS,CAC5B,EAAS,iBAAiB,EAAM,AAAC,GAAQ,CACvC,KAAK,cAAc,GAAI,aAAY,EAAI,KAAM,CAAE,OAAQ,EAAI,cAI/D,GAAM,GAAS,KAAK,WAAW,cAAc,QAC7C,EAAO,iBAAiB,aAAc,IAAM,CAC1C,EAAO,mBAAmB,QAAQ,AAAC,GAAO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O,teardown as C,generatePlayerInitTime as I,MediaError as Y}from"@mux/playback-core";var A=()=>{try{return"0.6.
|
|
1
|
+
import{initialize as T,setupAutoplay as M,toMuxVideoURL as O,teardown as C,generatePlayerInitTime as I,MediaError as Y}from"@mux/playback-core";var A=()=>{try{return"0.6.2-canary.2-830286f"}catch{}return"UNKNOWN"},y=A(),h=()=>y;var m=["abort","canplay","canplaythrough","durationchange","emptied","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"],E=document.createElement("template");E.innerHTML=`
|
|
2
2
|
<style>
|
|
3
3
|
:host {
|
|
4
4
|
/* display:inline (like the native el) makes it so you can't fill
|
package/dist/index.mjs.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/env.ts", "../src/CustomAudioElement.js"],
|
|
4
4
|
"sourcesContent": ["import {\n initialize,\n setupAutoplay,\n MuxMediaProps,\n StreamTypes,\n ValueOf,\n toMuxVideoURL,\n teardown,\n Metadata,\n mux,\n generatePlayerInitTime,\n MediaError,\n} from '@mux/playback-core';\nimport type { PlaybackEngine, UpdateAutoplay, ExtensionMimeTypeMap } from '@mux/playback-core';\nimport { getPlayerVersion } from './env';\n// this must be imported after playback-core for the polyfill to be included\nimport CustomAudioElement, { AudioEvents } from './CustomAudioElement';\n\n/** @TODO make the relationship between name+value smarter and more deriveable (CJP) */\ntype AttributeNames = {\n ENV_KEY: 'env-key';\n DEBUG: 'debug';\n METADATA_URL: 'metadata-url';\n METADATA_VIDEO_ID: 'metadata-video-id';\n METADATA_VIDEO_TITLE: 'metadata-video-title';\n METADATA_VIEWER_USER_ID: 'metadata-viewer-user-id';\n BEACON_COLLECTION_DOMAIN: 'beacon-collection-domain';\n PLAYBACK_ID: 'playback-id';\n PREFER_MSE: 'prefer-mse';\n TYPE: 'type';\n STREAM_TYPE: 'stream-type';\n START_TIME: 'start-time';\n};\n\nconst Attributes: AttributeNames = {\n ENV_KEY: 'env-key',\n DEBUG: 'debug',\n PLAYBACK_ID: 'playback-id',\n METADATA_URL: 'metadata-url',\n PREFER_MSE: 'prefer-mse',\n METADATA_VIDEO_ID: 'metadata-video-id',\n METADATA_VIDEO_TITLE: 'metadata-video-title',\n METADATA_VIEWER_USER_ID: 'metadata-viewer-user-id',\n BEACON_COLLECTION_DOMAIN: 'beacon-collection-domain',\n TYPE: 'type',\n STREAM_TYPE: 'stream-type',\n START_TIME: 'start-time',\n};\n\nconst AttributeNameValues = Object.values(Attributes);\n\nconst playerSoftwareVersion = getPlayerVersion();\nconst playerSoftwareName = 'mux-audio';\n\nclass MuxAudioElement extends CustomAudioElement<HTMLAudioElement> implements Partial<MuxMediaProps> {\n static get observedAttributes() {\n return [...AttributeNameValues, ...(CustomAudioElement.observedAttributes ?? [])];\n }\n\n // Keeping this named \"__hls\" since it's exposed for unadvertised \"advanced usage\" via getter that assumes specifically hls.js (CJP)\n protected __hls?: PlaybackEngine;\n protected __playerInitTime: number;\n protected __metadata: Readonly<Metadata> = {};\n protected __updateAutoplay?: UpdateAutoplay;\n\n constructor() {\n super();\n this.__playerInitTime = generatePlayerInitTime();\n }\n\n get playerInitTime() {\n return this.__playerInitTime;\n }\n\n get playerSoftwareName() {\n return playerSoftwareName;\n }\n\n get playerSoftwareVersion() {\n return playerSoftwareVersion;\n }\n\n /**\n * @deprecated please use ._hls instead\n */\n get hls() {\n console.warn('<mux-audio>.hls is deprecated, please use ._hls instead');\n return this._hls;\n }\n\n get _hls() {\n return this.__hls;\n }\n\n get mux(): Readonly<HTMLAudioElement['mux']> | undefined {\n return this.nativeEl.mux;\n }\n\n get src() {\n // Use the attribute value as the source of truth.\n // No need to store it in two places.\n // This avoids needing a to read the attribute initially and update the src.\n return this.getAttribute('src') as string;\n }\n\n set src(val: string) {\n // If being set by attributeChangedCallback,\n // dont' cause an infinite loop\n if (val === this.src) return;\n\n if (val == null) {\n this.removeAttribute('src');\n } else {\n this.setAttribute('src', val);\n }\n }\n\n /** @TODO write a generic module for well defined primitive types -> attribute getter/setters/removers (CJP) */\n get debug(): boolean {\n return this.getAttribute(Attributes.DEBUG) != null;\n }\n\n set debug(val: boolean) {\n // dont' cause an infinite loop\n if (val === this.debug) return;\n\n if (val) {\n this.setAttribute(Attributes.DEBUG, '');\n } else {\n this.removeAttribute(Attributes.DEBUG);\n }\n }\n\n get startTime(): number | undefined {\n const val = this.getAttribute(Attributes.START_TIME);\n if (val == null) return undefined;\n const num = +val;\n return !Number.isNaN(num) ? num : undefined;\n }\n\n set startTime(val: number | undefined) {\n // dont' cause an infinite loop\n if (val === this.startTime) return;\n\n if (val == null) {\n this.removeAttribute(Attributes.START_TIME);\n } else {\n this.setAttribute(Attributes.START_TIME, `${val}`);\n }\n }\n\n get playbackId(): string | undefined {\n return this.getAttribute(Attributes.PLAYBACK_ID) ?? undefined;\n }\n\n set playbackId(val: string | undefined) {\n // dont' cause an infinite loop\n if (val === this.playbackId) return;\n\n if (val) {\n this.setAttribute(Attributes.PLAYBACK_ID, val);\n } else {\n this.removeAttribute(Attributes.PLAYBACK_ID);\n }\n }\n\n get envKey(): string | undefined {\n return this.getAttribute(Attributes.ENV_KEY) ?? undefined;\n }\n\n set envKey(val: string | undefined) {\n // dont' cause an infinite loop\n if (val === this.envKey) return;\n\n if (val) {\n this.setAttribute(Attributes.ENV_KEY, val);\n } else {\n this.removeAttribute(Attributes.ENV_KEY);\n }\n }\n\n get beaconCollectionDomain(): string | undefined {\n return this.getAttribute(Attributes.BEACON_COLLECTION_DOMAIN) ?? undefined;\n }\n\n set beaconCollectionDomain(val: string | undefined) {\n // dont' cause an infinite loop\n if (val === this.beaconCollectionDomain) return;\n\n if (val) {\n this.setAttribute(Attributes.BEACON_COLLECTION_DOMAIN, val);\n } else {\n this.removeAttribute(Attributes.BEACON_COLLECTION_DOMAIN);\n }\n }\n\n get streamType(): ValueOf<StreamTypes> | undefined {\n // getAttribute doesn't know that this attribute is well defined. Should explore extending for MuxVideo (CJP)\n return (this.getAttribute(Attributes.STREAM_TYPE) as ValueOf<StreamTypes>) ?? undefined;\n }\n\n set streamType(val: ValueOf<StreamTypes> | undefined) {\n // dont' cause an infinite loop\n if (val === this.streamType) return;\n\n if (val) {\n this.setAttribute(Attributes.STREAM_TYPE, val);\n } else {\n this.removeAttribute(Attributes.STREAM_TYPE);\n }\n }\n\n /** @TODO Followup: naming convention: all lower (common per HTMLElement props) vs. camel (common per JS convention) (CJP) */\n get preferMse(): boolean {\n return this.getAttribute(Attributes.PREFER_MSE) != null;\n }\n\n set preferMse(val: boolean) {\n if (val) {\n this.setAttribute(Attributes.PREFER_MSE, '');\n } else {\n this.removeAttribute(Attributes.PREFER_MSE);\n }\n }\n\n get metadata() {\n return this.__metadata;\n }\n\n set metadata(val: Readonly<Metadata> | undefined) {\n this.__metadata = val ?? {};\n if (!!this.mux) {\n /** @TODO Link to docs for a more detailed discussion (CJP) */\n console.info(\n 'Some metadata values may not be overridable at this time. Make sure you set all metadata to override before setting the src.'\n );\n this.mux.emit('hb', this.__metadata);\n }\n }\n\n load() {\n const nextHlsInstance = initialize(this as Partial<MuxMediaProps>, this.nativeEl, this.__hls);\n this.__hls = nextHlsInstance;\n const updateAutoplay = setupAutoplay(this.nativeEl, this.autoplay, nextHlsInstance);\n this.__updateAutoplay = updateAutoplay;\n }\n\n unload() {\n teardown(this.nativeEl, this.__hls);\n this.__hls = undefined;\n }\n\n attributeChangedCallback(attrName: string, oldValue: string | null, newValue: string | null) {\n switch (attrName) {\n case 'src':\n const hadSrc = !!oldValue;\n const hasSrc = !!newValue;\n if (!hadSrc && hasSrc) {\n this.load();\n } else if (hadSrc && !hasSrc) {\n this.unload();\n /** @TODO Test this thoroughly (async?) and confirm unload() necessary (CJP) */\n } else if (hadSrc && hasSrc) {\n this.unload();\n this.load();\n }\n break;\n case 'autoplay':\n this.__updateAutoplay?.(newValue);\n break;\n case Attributes.PLAYBACK_ID:\n /** @TODO Improv+Discuss - how should playback-id update wrt src attr changes (and vice versa) (CJP) */\n this.src = toMuxVideoURL(newValue ?? undefined) as string;\n break;\n case Attributes.DEBUG:\n const debug = this.debug;\n if (!!this.mux) {\n /** @TODO Link to docs for a more detailed discussion (CJP) */\n console.info(\n 'Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src.'\n );\n }\n if (!!this._hls) {\n this._hls.config.debug = debug;\n }\n break;\n case Attributes.METADATA_URL:\n if (newValue) {\n fetch(newValue)\n .then((resp) => resp.json())\n .then((json) => (this.metadata = json))\n .catch((_err) => console.error(`Unable to load or parse metadata JSON from metadata-url ${newValue}!`));\n }\n break;\n default:\n break;\n }\n\n super.attributeChangedCallback(attrName, oldValue, newValue);\n }\n\n disconnectedCallback() {\n this.unload();\n }\n}\n\ntype MuxAudioElementType = typeof MuxAudioElement;\ndeclare global {\n var MuxAudioElement: MuxAudioElementType;\n}\n\nif (!globalThis.customElements.get('mux-audio')) {\n globalThis.customElements.define('mux-audio', MuxAudioElement);\n /** @TODO consider externalizing this (breaks standard modularity) */\n globalThis.MuxAudioElement = MuxAudioElement;\n}\n\nexport { PlaybackEngine, PlaybackEngine as Hls, ExtensionMimeTypeMap as MimeTypes, MediaError, AudioEvents };\n\nexport default MuxAudioElement;\n", "export const isMaybeBrowser = () => typeof window != 'undefined';\n// @ts-ignore\nexport const isMaybeServer = () => typeof global != 'undefined';\n\nconst getEnvPlayerVersion = () => {\n try {\n // @ts-ignore\n return PLAYER_VERSION as string;\n } catch {}\n return 'UNKNOWN';\n};\n\nconst player_version: string = getEnvPlayerVersion();\n\nexport const getPlayerVersion = () => player_version;\n", "/**\n * Custom Audio Element\n * The goal is to create an element that works just like the audio element\n * but can be extended/sub-classed, because native elements cannot be\n * extended today across browsers.\n */\n\nexport const AudioEvents = [\n 'abort',\n 'canplay',\n 'canplaythrough',\n 'durationchange',\n 'emptied',\n 'ended',\n 'error',\n 'loadeddata',\n 'loadedmetadata',\n 'loadstart',\n 'pause',\n 'play',\n 'playing',\n 'progress',\n 'ratechange',\n 'seeked',\n 'seeking',\n 'stalled',\n 'suspend',\n 'timeupdate',\n 'volumechange',\n 'waiting',\n];\n\nconst template = document.createElement('template');\n// Could you get styles to apply by passing a global button from global to shadow?\n\ntemplate.innerHTML = `\n<style>\n :host {\n /* display:inline (like the native el) makes it so you can't fill\n the container with the native el */\n display: inline-block;\n box-sizing: border-box;\n\n width: auto;\n height: auto;\n }\n\n audio {\n max-width: 100%;\n max-height: 100%;\n min-width: 100%;\n min-height: 100%;\n }\n\n</style>\n\n<audio part=\"audio\" crossorigin></audio>\n<slot></slot>\n`;\n\nclass CustomAudioElement extends HTMLElement {\n constructor() {\n super();\n\n this.attachShadow({ mode: 'open' });\n this.shadowRoot.appendChild(template.content.cloneNode(true));\n const nativeEl = (this.nativeEl = this.shadowRoot.querySelector('audio'));\n\n // Initialize all the attribute properties\n // This is required before attributeChangedCallback is called after construction\n // so the initial state of all the attributes are forwarded to the native element.\n Array.from(this.attributes).forEach((attrNode) => {\n this.forwardAttribute(attrNode.name, null, attrNode.value);\n });\n\n // Neither Chrome or Firefox support setting the muted attribute\n // after using document.createElement.\n // One way to get around this would be to build the native tag as a string.\n // But just fixing it manually for now.\n // Apparently this may also be an issue with <input checked> for buttons\n if (nativeEl.defaultMuted) {\n nativeEl.muted = true;\n }\n\n // The audio events are dispatched on the CustomAudioElement instance.\n // This makes it possible to add event listeners before the element is upgraded.\n AudioEvents.forEach((type) => {\n nativeEl.addEventListener(type, (evt) => {\n this.dispatchEvent(new CustomEvent(evt.type, { detail: evt.detail }));\n });\n });\n\n const slotEl = this.shadowRoot.querySelector('slot');\n slotEl.addEventListener('slotchange', () => {\n slotEl.assignedElements().forEach((el) => {\n nativeEl.appendChild(el);\n });\n });\n }\n\n // observedAttributes is required to trigger attributeChangedCallback\n // for any attributes on the custom element.\n // Attributes need to be the lowercase word, e.g. crossorigin, not crossOrigin\n static get observedAttributes() {\n let attrs = [];\n\n // Instead of manually creating a list of all observed attributes,\n // observe any getter/setter prop name (lowercased)\n Object.getOwnPropertyNames(this.prototype).forEach((propName) => {\n let isFunc = false;\n\n // Non-func properties throw errors because it's not an instance\n try {\n if (typeof this.prototype[propName] === 'function') {\n isFunc = true;\n }\n } catch (e) {}\n\n // Exclude functions and constants\n if (!isFunc && propName !== propName.toUpperCase()) {\n attrs.push(propName.toLowerCase());\n }\n });\n\n // Include any attributes from the super class (recursive)\n const supAttrs = Object.getPrototypeOf(this).observedAttributes;\n\n if (supAttrs) {\n attrs = attrs.concat(supAttrs);\n }\n\n return attrs;\n }\n\n // We need to handle sub-class custom attributes differently from\n // attrs meant to be passed to the internal native el.\n attributeChangedCallback(attrName, oldValue, newValue) {\n this.forwardAttribute(attrName, oldValue, newValue);\n }\n\n forwardAttribute(attrName, oldValue, newValue) {\n // Find the matching prop for custom attributes\n const ownProps = Object.getOwnPropertyNames(Object.getPrototypeOf(this));\n const propName = arrayFindAnyCase(ownProps, attrName);\n\n // Check if this is the original custom native elemnt or a subclass\n const isBaseElement = Object.getPrototypeOf(this.constructor).toString().indexOf('function HTMLElement') === 0;\n\n // If this is a subclass custom attribute we want to set the\n // matching property on the subclass\n if (propName && !isBaseElement) {\n // Boolean props should never start as null\n if (typeof this[propName] == 'boolean') {\n // null is returned when attributes are removed i.e. boolean attrs\n if (newValue === null) {\n this[propName] = false;\n } else {\n // The new value might be an empty string, which is still true\n // for boolean attributes\n this[propName] = true;\n }\n } else {\n this[propName] = newValue;\n }\n } else {\n // When this is the original Custom Element, or the subclass doesn't\n // have a matching prop, pass it through.\n if (newValue === null) {\n this.nativeEl.removeAttribute(attrName);\n } else {\n // Ignore a few that don't need to be passed through just in case\n // it creates unexpected behavior.\n if (['id', 'class'].indexOf(attrName) === -1) {\n this.nativeEl.setAttribute(attrName, newValue);\n }\n }\n }\n }\n\n connectedCallback() {}\n}\n\n// Map all native element properties to the custom element\n// so that they're applied to the native element.\n// Skipping HTMLElement because of things like \"attachShadow\"\n// causing issues. Most of those props still need to apply to\n// the custom element.\n// But includign EventTarget props because most events emit from\n// the native element.\nlet nativeElProps = [];\n\n// Can't check typeof directly on element prototypes without\n// throwing Illegal Invocation errors, so creating an element\n// to check on instead.\nconst nativeElTest = document.createElement('audio');\n\n// Deprecated props throw warnings if used, so exclude them\nconst deprecatedProps = ['webkitDisplayingFullscreen', 'webkitSupportsFullscreen'];\n\n// Walk the prototype chain up to HTMLElement.\n// This will grab all super class props in between.\n// i.e. AudioElement and MediaElement\nfor (\n let proto = Object.getPrototypeOf(nativeElTest);\n proto && proto !== HTMLElement.prototype;\n proto = Object.getPrototypeOf(proto)\n) {\n Object.keys(proto).forEach((key) => {\n if (deprecatedProps.indexOf(key) === -1) {\n nativeElProps.push(key);\n }\n });\n}\n\n// Passthrough native el functions from the custom el to the native el\nnativeElProps.forEach((prop) => {\n const type = typeof nativeElTest[prop];\n\n if (type == 'function') {\n // Function\n CustomAudioElement.prototype[prop] = function () {\n return this.nativeEl[prop].apply(this.nativeEl, arguments);\n };\n } else {\n // Getter\n let config = {\n get() {\n return this.nativeEl[prop];\n },\n };\n\n if (prop !== prop.toUpperCase()) {\n // Setter (not a CONSTANT)\n config.set = function (val) {\n this.nativeEl[prop] = val;\n };\n }\n\n Object.defineProperty(CustomAudioElement.prototype, prop, config);\n }\n});\n\nfunction arrayFindAnyCase(arr, word) {\n let found = null;\n\n arr.forEach((item) => {\n if (item.toLowerCase() == word.toLowerCase()) {\n found = item;\n }\n });\n\n return found;\n}\n\nif (!globalThis.customElements.get('custom-audio')) {\n globalThis.customElements.define('custom-audio', CustomAudioElement);\n globalThis.CustomAudioElement = CustomAudioElement;\n}\n\nexport default CustomAudioElement;\n"],
|
|
5
|
-
"mappings": "AAAA,gJCIA,GAAM,GAAsB,IAAM,CAChC,GAAI,CAEF,MAAO,
|
|
5
|
+
"mappings": "AAAA,gJCIA,GAAM,GAAsB,IAAM,CAChC,GAAI,CAEF,MAAO,8BACP,EACF,MAAO,WAGH,EAAyB,IAElB,EAAmB,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B,EAAyB,CA5P/F,MA6PI,OAAQ,OACD,MACH,GAAM,GAAS,CAAC,CAAC,EACX,EAAS,CAAC,CAAC,EACjB,AAAI,CAAC,GAAU,EACb,KAAK,OACA,AAAI,GAAU,CAAC,EACpB,KAAK,SAEI,GAAU,GACnB,MAAK,SACL,KAAK,QAEP,UACG,WACH,QAAK,mBAAL,kBAAwB,GACxB,UACG,GAAW,YAEd,KAAK,IAAM,EAAc,UAAY,QACrC,UACG,GAAW,MACd,GAAM,GAAQ,KAAK,MACnB,AAAM,KAAK,KAET,QAAQ,KACN,iIAGE,KAAK,MACT,MAAK,KAAK,OAAO,MAAQ,GAE3B,UACG,GAAW,aACd,AAAI,GACF,MAAM,GACH,KAAK,AAAC,GAAS,EAAK,QACpB,KAAK,AAAC,GAAU,KAAK,SAAW,GAChC,MAAM,AAAC,GAAS,QAAQ,MAAM,2DAA2D,OAE9F,cAEA,MAGJ,MAAM,yBAAyB,EAAU,EAAU,GAGrD,sBAAuB,CACrB,KAAK,WAST,AAAK,WAAW,eAAe,IAAI,cACjC,YAAW,eAAe,OAAO,YAAa,GAE9C,WAAW,gBAAkB,GAK/B,GAAO,GAAQ",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/mux-audio.js
CHANGED
|
@@ -26,7 +26,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
26
26
|
`,a.parse()),a.state==="INITIAL"||a.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){a.onparsingerror&&a.onparsingerror(e)}return a.onflush&&a.onflush(),this},S}()},"./src/utils/webvtt-parser.ts":function(k,b,d){"use strict";d.r(b),d.d(b,"generateCueId",function(){return D}),d.d(b,"parseWebVTT",function(){return v});var R=d("./src/polyfills/number.ts"),y=d("./src/utils/vttparser.ts"),T=d("./src/demux/id3.ts"),I=d("./src/utils/timescale-conversion.ts"),x=d("./src/remux/mp4-remuxer.ts"),L=/\r\n|\n\r|\n|\r/g,_=function(a,e,i){return i===void 0&&(i=0),a.substr(i,e.length)===e},g=function(a){var e=parseInt(a.substr(-3)),i=parseInt(a.substr(-6,2)),t=parseInt(a.substr(-9,2)),r=a.length>9?parseInt(a.substr(0,a.indexOf(":"))):0;if(!Object(R.isFiniteNumber)(e)||!Object(R.isFiniteNumber)(i)||!Object(R.isFiniteNumber)(t)||!Object(R.isFiniteNumber)(r))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+a);return e+=1e3*i,e+=60*1e3*t,e+=60*60*1e3*r,e},A=function(a){for(var e=5381,i=a.length;i;)e=e*33^a.charCodeAt(--i);return(e>>>0).toString()};function D(p,a,e){return A(p.toString())+A(a.toString())+A(e)}var S=function(a,e,i){var t=a[e],r=a[t.prevCC];if(!r||!r.new&&t.new){a.ccOffset=a.presentationOffset=t.start,t.new=!1;return}for(;(s=r)!==null&&s!==void 0&&s.new;){var s;a.ccOffset+=t.start-r.start,t.new=!1,t=r,r=a[t.prevCC]}a.presentationOffset=i};function v(p,a,e,i,t,r,s,n){var h=new y.VTTParser,c=Object(T.utf8ArrayToStr)(new Uint8Array(p)).trim().replace(L,`
|
|
27
27
|
`).split(`
|
|
28
28
|
`),u=[],f=Object(I.toMpegTsClockFromTimescale)(a,e),l="00:00.000",o=0,E=0,m,O=!0,P=!1;h.oncue=function(M){var F=i[t],B=i.ccOffset,C=(o-f)/9e4;if(F!=null&&F.new&&(E!==void 0?B=i.ccOffset=F.start:S(i,t,C)),C&&(B=C-i.presentationOffset),P){var w=M.endTime-M.startTime,U=Object(x.normalizePts)((M.startTime+B-E)*9e4,r*9e4)/9e4;M.startTime=U,M.endTime=U+w}var N=M.text.trim();M.text=decodeURIComponent(encodeURIComponent(N)),M.id||(M.id=D(M.startTime,M.endTime,N)),M.endTime>0&&u.push(M)},h.onparsingerror=function(M){m=M},h.onflush=function(){if(m){n(m);return}s(u)},c.forEach(function(M){if(O)if(_(M,"X-TIMESTAMP-MAP=")){O=!1,P=!0,M.substr(16).split(",").forEach(function(F){_(F,"LOCAL:")?l=F.substr(6):_(F,"MPEGTS:")&&(o=parseInt(F.substr(7)))});try{E=g(l)/1e3}catch(F){P=!1,m=F}return}else M===""&&(O=!1);h.parse(M+`
|
|
29
|
-
`)}),h.flush()}},"./src/utils/xhr-loader.ts":function(k,b,d){"use strict";d.r(b);var R=d("./src/utils/logger.ts"),y=d("./src/loader/load-stats.ts"),T=/^age:\s*[\d.]+\s*$/m,I=function(){function x(_){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=_?_.xhrSetup:null,this.stats=new y.LoadStats,this.retryDelay=0}var L=x.prototype;return L.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},L.abortInternal=function(){var g=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),g&&(g.onreadystatechange=null,g.onprogress=null,g.readyState!==4&&(this.stats.aborted=!0,g.abort()))},L.abort=function(){var g;this.abortInternal(),(g=this.callbacks)!==null&&g!==void 0&&g.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},L.load=function(g,A,D){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=g,this.config=A,this.callbacks=D,this.retryDelay=A.retryDelay,this.loadInternal()},L.loadInternal=function(){var g=this.config,A=this.context;if(!!g){var D=this.loader=new self.XMLHttpRequest,S=this.stats;S.loading.first=0,S.loaded=0;var v=this.xhrSetup;try{if(v)try{v(D,A.url)}catch{D.open("GET",A.url,!0),v(D,A.url)}D.readyState||D.open("GET",A.url,!0);var p=this.context.headers;if(p)for(var a in p)D.setRequestHeader(a,p[a])}catch(e){this.callbacks.onError({code:D.status,text:e.message},A,D);return}A.rangeEnd&&D.setRequestHeader("Range","bytes="+A.rangeStart+"-"+(A.rangeEnd-1)),D.onreadystatechange=this.readystatechange.bind(this),D.onprogress=this.loadprogress.bind(this),D.responseType=A.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),g.timeout),D.send()}},L.readystatechange=function(){var g=this.context,A=this.loader,D=this.stats;if(!(!g||!A)){var S=A.readyState,v=this.config;if(!D.aborted&&S>=2)if(self.clearTimeout(this.requestTimeout),D.loading.first===0&&(D.loading.first=Math.max(self.performance.now(),D.loading.start)),S===4){A.onreadystatechange=null,A.onprogress=null;var p=A.status;if(p>=200&&p<300){D.loading.end=Math.max(self.performance.now(),D.loading.first);var a,e;if(g.responseType==="arraybuffer"?(a=A.response,e=a.byteLength):(a=A.responseText,e=a.length),D.loaded=D.total=e,!this.callbacks)return;var i=this.callbacks.onProgress;if(i&&i(D,g,a,A),!this.callbacks)return;var t={url:A.responseURL,data:a};this.callbacks.onSuccess(t,D,g,A)}else D.retry>=v.maxRetry||p>=400&&p<499?(R.logger.error(p+" while loading "+g.url),this.callbacks.onError({code:p,text:A.statusText},g,A)):(R.logger.warn(p+" while loading "+g.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,v.maxRetryDelay),D.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),v.timeout)}},L.loadtimeout=function(){R.logger.warn("timeout while loading "+this.context.url);var g=this.callbacks;g&&(this.abortInternal(),g.onTimeout(this.stats,this.context,this.loader))},L.loadprogress=function(g){var A=this.stats;A.loaded=g.loaded,g.lengthComputable&&(A.total=g.total)},L.getCacheAge=function(){var g=null;if(this.loader&&T.test(this.loader.getAllResponseHeaders())){var A=this.loader.getResponseHeader("age");g=A?parseFloat(A):null}return g},x}();b.default=I}}).default})});var ot=ze(St()),Ie=ze(Je()),lt=ze(Je()),Be=ze(Je()),_t=(k,b,d)=>{if(!b.has(k))throw TypeError("Cannot "+d)},Qt=(k,b,d)=>(_t(k,b,"read from private field"),d?d.call(k):b.get(k)),Jt=(k,b,d)=>{if(b.has(k))throw TypeError("Cannot add the same private member more than once");b instanceof WeakSet?b.add(k):b.set(k,d)},$t=(k,b,d,R)=>(_t(k,b,"write to private field"),R?R.call(k,d):b.set(k,d),d);if(typeof DocumentFragment=="undefined"){class k{}globalThis.DocumentFragment=k}globalThis.customElements||(globalThis.customElements={get(k){},define(k,b,d){},upgrade(k){},whenDefined(k){return Promise.resolve(globalThis.HTMLElement)}});var $e;if(!globalThis.CustomEvent){class k{constructor(d,R={}){Jt(this,$e,void 0),$t(this,$e,R==null?void 0:R.detail)}get detail(){Qt(this,$e)}initCustomEvent(d,R,y,T){}}$e=new WeakMap,globalThis.CustomEvent=k}if(!globalThis.EventTarget){class k{addEventListener(){}removeEventListener(){}dispatchEvent(d){return!0}}globalThis.EventTarget=k}if(!globalThis.HTMLElement){class k extends EventTarget{}globalThis.HTMLElement=k}if(!globalThis.HTMLVideoElement){class k extends EventTarget{}globalThis.HTMLVideoElement=k}var At,Dt;if(!((At=globalThis.document)==null?void 0:At.createElement)){let k=(Dt=globalThis.document)!=null?Dt:{};k.createElement=function(b,d){return new HTMLElement},globalThis.document=k}var ut={ANY:"any",MUTED:"muted"},Zt=Object.values(ut),Lt=k=>typeof k=="boolean"||typeof k=="string"&&Zt.includes(k),Ot=(k,b,d)=>{let R=!1,y=!1,T=Lt(b)?b:!!b,I=()=>{k.addEventListener("playing",()=>{R=!0},{once:!0})};if(I(),k.addEventListener("loadstart",()=>{R=!1,I(),ft(k,T)},{once:!0}),k.addEventListener("loadedmetadata",()=>{d||(y=!Number.isFinite(k.duration)),ft(k,T)},{once:!0}),d&&d.once(lt.default.Events.LEVEL_LOADED,(x,L)=>{var _;y=(_=L.details.live)!=null?_:!1}),!T){let x=()=>{!y||((d==null?void 0:d.liveSyncPosition)?k.currentTime=d.liveSyncPosition:Number.isFinite(k.seekable.end(0))&&(k.currentTime=k.seekable.end(0)))};k.addEventListener("play",()=>{d&&k.preload==="metadata"?d.once(lt.default.Events.LEVEL_UPDATED,x):d&&x()},{once:!0})}return x=>{R||(T=Lt(x)?x:!!x,ft(k,T))}},ft=(k,b)=>{if(!b)return;let d=k.muted,R=()=>k.muted=d;switch(b){case ut.ANY:k.play().catch(y=>{k.muted=!0,k.play().catch(R)});break;case ut.MUTED:k.muted=!0,k.play().catch(R);break;default:k.play().catch(()=>{});break}},We=class extends Error{constructor(k,b=We.MEDIA_ERR_CUSTOM,d){super(k);var R;this.name="MediaError",this.code=b,this.fatal=d!=null?d:b>=We.MEDIA_ERR_NETWORK&&b<=We.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(R=We.defaultMessages[this.code])!=null?R:"")}},Ae=We;Ae.MEDIA_ERR_ABORTED=1,Ae.MEDIA_ERR_NETWORK=2,Ae.MEDIA_ERR_DECODE=3,Ae.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Ae.MEDIA_ERR_ENCRYPTED=5,Ae.MEDIA_ERR_CUSTOM=100,Ae.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};function qt(k,b){b.on(Be.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(y,{tracks:T})=>{T.forEach(I=>{var x;let L=(x=I.subtitleTrack)!=null?x:I.closedCaptions,_=b.subtitleTracks.findIndex(({lang:g,name:A,type:D})=>g==(L==null?void 0:L.lang)&&A===I.label&&D.toLowerCase()===I.kind);er(k,I.kind,I.label,L==null?void 0:L.lang,`${I.kind}${_}`)})});let d=()=>{var y;if(!b.subtitleTracks.length)return;let T=Array.from(k.textTracks).find(x=>x.id&&x.mode==="showing"&&["subtitles","captions"].includes(x.kind)),I=`${(y=b.subtitleTracks[b.subtitleTrack])==null?void 0:y.type.toLowerCase()}${b.subtitleTrack}`;if(T&&(b.subtitleTrack<0||(T==null?void 0:T.id)!==I)){let x=b.subtitleTracks.findIndex(({lang:L,name:_,type:g})=>L==T.language&&_===T.label&&g.toLowerCase()===T.kind);b.subtitleTrack=x}T&&(T==null?void 0:T.id)===I&&T.cues&&Array.from(T.cues).forEach(x=>{T.addCue(x)})};k.textTracks.addEventListener("change",d),b.on(Be.default.Events.CUES_PARSED,(y,{track:T,type:I,cues:x})=>{let L=k.textTracks.getTrackById(T);if(!L)return;let _=L.mode==="disabled";_&&(L.mode="hidden"),x.forEach(g=>{var A;((A=L.cues)==null?void 0:A.getCueById(g.id))||L.addCue(g)}),_&&(L.mode="disabled")}),b.on(Be.default.Events.DESTROYING,()=>{k.textTracks.removeEventListener("change",d),k.querySelectorAll("track[data-removeondestroy]").forEach(y=>{y.remove()})});let R=()=>{Array.from(k.textTracks).forEach(y=>{var T,I;if(!["subtitles","caption"].includes(y.kind)&&y.label==="thumbnails"){if(!((T=y.cues)==null?void 0:T.length)){let x=k.querySelector('track[label="thumbnails"]'),L=(I=x==null?void 0:x.getAttribute("src"))!=null?I:"";x==null||x.removeAttribute("src"),setTimeout(()=>{x==null||x.setAttribute("src",L)},0)}y.mode!=="hidden"&&(y.mode="hidden")}})};b.once(Be.default.Events.MANIFEST_LOADED,R),b.once(Be.default.Events.MEDIA_ATTACHED,R)}function er(k,b,d,R,y){let T=document.createElement("track");return T.kind=b,T.label=d,R&&(T.srclang=R),y&&(T.id=y),T.track.mode="disabled",T.setAttribute("data-removeondestroy",""),k.append(T),T.track}var Rt=(k,b)=>k in b,bt="mux.com",Pt=()=>ot.default.utils.now(),Ge={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},we={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},dt={HLS:we.M3U8},mr=Object.keys(dt),pr=[...Object.values(we),"hls","HLS"],tr=k=>{let b=k.indexOf("?");if(b<0)return[k];let d=k.slice(0,b),R=k.slice(b);return[d,R]},It=(k,{domain:b=bt}={})=>{if(!k)return;let[d,R=""]=tr(k);return`https://stream.${b}/${d}.m3u8${R}`},rr=k=>{let b="";try{b=new URL(k).pathname}catch{console.error("invalid url")}let d=b.lastIndexOf(".");if(d<0)return"";let R=b.slice(d+1).toUpperCase();return Rt(R,we)?we[R]:""},Mt=k=>{let b=k.type;if(b){let R=b.toUpperCase();return Rt(R,dt)?dt[R]:b}let{src:d}=k;return d?rr(d):""},ir=k=>{if([Ge.LIVE,Ge.LL_LIVE].includes(k)){let b={backBufferLength:12};return k===Ge.LL_LIVE?{...b,maxFragLookUpTolerance:.001}:b}return{}},ct=new WeakMap;var ht=(k,b)=>{b&&(b.detachMedia(),b.destroy()),(k==null?void 0:k.mux)&&!k.mux.deleted&&(k.mux.destroy(),k.mux),k&&(k.removeEventListener("error",Ct),k.removeEventListener("error",vt),ct.delete(k))},nr=(k,b)=>{var d,R,y;let{debug:T,preferMse:I,streamType:x,startTime:L=-1}=k,_=Mt(k),g=_===we.M3U8,A=!_||((d=b==null?void 0:b.canPlayType(_))!=null?d:!0),D=Ie.default.isSupported(),S=((y=(R=window==null?void 0:window.navigator)==null?void 0:R.userAgent)!=null?y:"").toLowerCase().indexOf("android")!==-1&&x===Ge.LL_LIVE;if(g&&!(!g||A&&!((I||S)&&D))&&D){let v={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},p=ir(x);return new Ie.default({debug:T,startPosition:L,...v,...p})}},ar=({playbackId:k,src:b,customDomain:d})=>{if(k)return!0;if(typeof b!="string")return!1;let R=new URL(b).hostname.toLocaleLowerCase();return R.includes(bt)||!!d&&R.includes(d.toLocaleLowerCase())},sr=(k,b,d)=>{let{envKey:R}=k,y=ar(k);if((R||y)&&b){let{playerInitTime:T,playerSoftwareName:I,playerSoftwareVersion:x,beaconCollectionDomain:L,metadata:_,debug:g}=k,A=D=>typeof D.player_error_code=="string"?!1:typeof k.errorTranslator=="function"?k.errorTranslator(D):D;ot.default.monitor(b,{debug:g,beaconCollectionDomain:L,hlsjs:d,Hls:d?Ie.default:void 0,automaticErrorTracking:!1,errorTranslator:A,data:{...R?{env_key:R}:{},player_software_name:I,player_software_version:x,player_init_time:T,..._}})}},or=(k,b,d)=>{var R,y,T;if(!b){console.warn("attempting to load media before mediaEl exists");return}let{preferMse:I,streamType:x}=k,L=Mt(k),_=L===we.M3U8,g=!L||((R=b==null?void 0:b.canPlayType(L))!=null?R:!0),A=Ie.default.isSupported(),D=((T=(y=window==null?void 0:window.navigator)==null?void 0:y.userAgent)!=null?T:"").toLowerCase().indexOf("android")!==-1&&x===Ge.LL_LIVE,S=!_||g&&!((I||D)&&A),{src:v}=k;if(b&&g&&S){if(typeof v=="string"){let{startTime:p}=k;if(b.setAttribute("src",v),p){let a=({target:e})=>{e.currentTime=p,e.removeEventListener("loadedmetadata",a)};b.addEventListener("loadedmetadata",a)}}else b.removeAttribute("src");b.addEventListener("error",Ct),b.addEventListener("error",vt)}else if(d&&v){switch(d.on(Ie.default.Events.ERROR,(p,a)=>{let e={[Ie.default.ErrorTypes.NETWORK_ERROR]:Ae.MEDIA_ERR_NETWORK,[Ie.default.ErrorTypes.MEDIA_ERROR]:Ae.MEDIA_ERR_DECODE},i=new Ae("",e[a.type]);i.fatal=a.fatal,i.data=a,b.dispatchEvent(new CustomEvent("error",{detail:i}))}),b.addEventListener("error",vt),qt(b,d),b.preload){case"none":b.addEventListener("play",()=>d.loadSource(v),{once:!0});break;case"metadata":let p=d.config.maxBufferLength,a=d.config.maxBufferSize;d.config.maxBufferLength=1,d.config.maxBufferSize=1,b.addEventListener("play",()=>{d.config.maxBufferLength=p,d.config.maxBufferSize=a},{once:!0}),d.loadSource(v);break;default:d.loadSource(v)}d.attachMedia(b)}else console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};async function Ct(k){if(!k.isTrusted)return;k.stopImmediatePropagation();let b=k.target;if(!(b==null?void 0:b.error))return;let{message:d,code:R}=b.error,y=new Ae(d,R);if(b.src&&(R!==Ae.MEDIA_ERR_DECODE||R!==void 0)){let{status:T}=await fetch(b.src);y.data={response:{code:T}}}b.dispatchEvent(new CustomEvent("error",{detail:y}))}function vt(k){var b;if(!(k instanceof CustomEvent)||!(k.detail instanceof Ae))return;let d=k.target,R=k.detail;if(!R||!R.fatal)return;let y=ct.get(d);y&&(y.error=R),(b=d.mux)==null||b.emit("error",{player_error_code:R.code,player_error_message:R.message})}var Ft=(k,b,d)=>{ht(b,d),ct.set(b,{});let R=nr(k,b);return sr(k,b,R),or(k,b,R),R};var lr=()=>{try{return"0.6.1"}catch{}return"UNKNOWN"},ur=lr(),Bt=()=>ur;var wt=["abort","canplay","canplaythrough","durationchange","emptied","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"],Ut=document.createElement("template");Ut.innerHTML=`
|
|
29
|
+
`)}),h.flush()}},"./src/utils/xhr-loader.ts":function(k,b,d){"use strict";d.r(b);var R=d("./src/utils/logger.ts"),y=d("./src/loader/load-stats.ts"),T=/^age:\s*[\d.]+\s*$/m,I=function(){function x(_){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=_?_.xhrSetup:null,this.stats=new y.LoadStats,this.retryDelay=0}var L=x.prototype;return L.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},L.abortInternal=function(){var g=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),g&&(g.onreadystatechange=null,g.onprogress=null,g.readyState!==4&&(this.stats.aborted=!0,g.abort()))},L.abort=function(){var g;this.abortInternal(),(g=this.callbacks)!==null&&g!==void 0&&g.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},L.load=function(g,A,D){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=g,this.config=A,this.callbacks=D,this.retryDelay=A.retryDelay,this.loadInternal()},L.loadInternal=function(){var g=this.config,A=this.context;if(!!g){var D=this.loader=new self.XMLHttpRequest,S=this.stats;S.loading.first=0,S.loaded=0;var v=this.xhrSetup;try{if(v)try{v(D,A.url)}catch{D.open("GET",A.url,!0),v(D,A.url)}D.readyState||D.open("GET",A.url,!0);var p=this.context.headers;if(p)for(var a in p)D.setRequestHeader(a,p[a])}catch(e){this.callbacks.onError({code:D.status,text:e.message},A,D);return}A.rangeEnd&&D.setRequestHeader("Range","bytes="+A.rangeStart+"-"+(A.rangeEnd-1)),D.onreadystatechange=this.readystatechange.bind(this),D.onprogress=this.loadprogress.bind(this),D.responseType=A.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),g.timeout),D.send()}},L.readystatechange=function(){var g=this.context,A=this.loader,D=this.stats;if(!(!g||!A)){var S=A.readyState,v=this.config;if(!D.aborted&&S>=2)if(self.clearTimeout(this.requestTimeout),D.loading.first===0&&(D.loading.first=Math.max(self.performance.now(),D.loading.start)),S===4){A.onreadystatechange=null,A.onprogress=null;var p=A.status;if(p>=200&&p<300){D.loading.end=Math.max(self.performance.now(),D.loading.first);var a,e;if(g.responseType==="arraybuffer"?(a=A.response,e=a.byteLength):(a=A.responseText,e=a.length),D.loaded=D.total=e,!this.callbacks)return;var i=this.callbacks.onProgress;if(i&&i(D,g,a,A),!this.callbacks)return;var t={url:A.responseURL,data:a};this.callbacks.onSuccess(t,D,g,A)}else D.retry>=v.maxRetry||p>=400&&p<499?(R.logger.error(p+" while loading "+g.url),this.callbacks.onError({code:p,text:A.statusText},g,A)):(R.logger.warn(p+" while loading "+g.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,v.maxRetryDelay),D.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),v.timeout)}},L.loadtimeout=function(){R.logger.warn("timeout while loading "+this.context.url);var g=this.callbacks;g&&(this.abortInternal(),g.onTimeout(this.stats,this.context,this.loader))},L.loadprogress=function(g){var A=this.stats;A.loaded=g.loaded,g.lengthComputable&&(A.total=g.total)},L.getCacheAge=function(){var g=null;if(this.loader&&T.test(this.loader.getAllResponseHeaders())){var A=this.loader.getResponseHeader("age");g=A?parseFloat(A):null}return g},x}();b.default=I}}).default})});var ot=ze(St()),Ie=ze(Je()),lt=ze(Je()),Be=ze(Je()),_t=(k,b,d)=>{if(!b.has(k))throw TypeError("Cannot "+d)},Qt=(k,b,d)=>(_t(k,b,"read from private field"),d?d.call(k):b.get(k)),Jt=(k,b,d)=>{if(b.has(k))throw TypeError("Cannot add the same private member more than once");b instanceof WeakSet?b.add(k):b.set(k,d)},$t=(k,b,d,R)=>(_t(k,b,"write to private field"),R?R.call(k,d):b.set(k,d),d);if(typeof DocumentFragment=="undefined"){class k{}globalThis.DocumentFragment=k}globalThis.customElements||(globalThis.customElements={get(k){},define(k,b,d){},upgrade(k){},whenDefined(k){return Promise.resolve(globalThis.HTMLElement)}});var $e;if(!globalThis.CustomEvent){class k{constructor(d,R={}){Jt(this,$e,void 0),$t(this,$e,R==null?void 0:R.detail)}get detail(){Qt(this,$e)}initCustomEvent(d,R,y,T){}}$e=new WeakMap,globalThis.CustomEvent=k}if(!globalThis.EventTarget){class k{addEventListener(){}removeEventListener(){}dispatchEvent(d){return!0}}globalThis.EventTarget=k}if(!globalThis.HTMLElement){class k extends EventTarget{}globalThis.HTMLElement=k}if(!globalThis.HTMLVideoElement){class k extends EventTarget{}globalThis.HTMLVideoElement=k}var At,Dt;if(!((At=globalThis.document)==null?void 0:At.createElement)){let k=(Dt=globalThis.document)!=null?Dt:{};k.createElement=function(b,d){return new HTMLElement},globalThis.document=k}var ut={ANY:"any",MUTED:"muted"},Zt=Object.values(ut),Lt=k=>typeof k=="boolean"||typeof k=="string"&&Zt.includes(k),Ot=(k,b,d)=>{let R=!1,y=!1,T=Lt(b)?b:!!b,I=()=>{k.addEventListener("playing",()=>{R=!0},{once:!0})};if(I(),k.addEventListener("loadstart",()=>{R=!1,I(),ft(k,T)},{once:!0}),k.addEventListener("loadedmetadata",()=>{d||(y=!Number.isFinite(k.duration)),ft(k,T)},{once:!0}),d&&d.once(lt.default.Events.LEVEL_LOADED,(x,L)=>{var _;y=(_=L.details.live)!=null?_:!1}),!T){let x=()=>{!y||((d==null?void 0:d.liveSyncPosition)?k.currentTime=d.liveSyncPosition:Number.isFinite(k.seekable.end(0))&&(k.currentTime=k.seekable.end(0)))};k.addEventListener("play",()=>{d&&k.preload==="metadata"?d.once(lt.default.Events.LEVEL_UPDATED,x):d&&x()},{once:!0})}return x=>{R||(T=Lt(x)?x:!!x,ft(k,T))}},ft=(k,b)=>{if(!b)return;let d=k.muted,R=()=>k.muted=d;switch(b){case ut.ANY:k.play().catch(y=>{k.muted=!0,k.play().catch(R)});break;case ut.MUTED:k.muted=!0,k.play().catch(R);break;default:k.play().catch(()=>{});break}},We=class extends Error{constructor(k,b=We.MEDIA_ERR_CUSTOM,d){super(k);var R;this.name="MediaError",this.code=b,this.fatal=d!=null?d:b>=We.MEDIA_ERR_NETWORK&&b<=We.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(R=We.defaultMessages[this.code])!=null?R:"")}},Ae=We;Ae.MEDIA_ERR_ABORTED=1,Ae.MEDIA_ERR_NETWORK=2,Ae.MEDIA_ERR_DECODE=3,Ae.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Ae.MEDIA_ERR_ENCRYPTED=5,Ae.MEDIA_ERR_CUSTOM=100,Ae.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};function qt(k,b){b.on(Be.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(y,{tracks:T})=>{T.forEach(I=>{var x;let L=(x=I.subtitleTrack)!=null?x:I.closedCaptions,_=b.subtitleTracks.findIndex(({lang:g,name:A,type:D})=>g==(L==null?void 0:L.lang)&&A===I.label&&D.toLowerCase()===I.kind);er(k,I.kind,I.label,L==null?void 0:L.lang,`${I.kind}${_}`)})});let d=()=>{var y;if(!b.subtitleTracks.length)return;let T=Array.from(k.textTracks).find(x=>x.id&&x.mode==="showing"&&["subtitles","captions"].includes(x.kind)),I=`${(y=b.subtitleTracks[b.subtitleTrack])==null?void 0:y.type.toLowerCase()}${b.subtitleTrack}`;if(T&&(b.subtitleTrack<0||(T==null?void 0:T.id)!==I)){let x=b.subtitleTracks.findIndex(({lang:L,name:_,type:g})=>L==T.language&&_===T.label&&g.toLowerCase()===T.kind);b.subtitleTrack=x}T&&(T==null?void 0:T.id)===I&&T.cues&&Array.from(T.cues).forEach(x=>{T.addCue(x)})};k.textTracks.addEventListener("change",d),b.on(Be.default.Events.CUES_PARSED,(y,{track:T,type:I,cues:x})=>{let L=k.textTracks.getTrackById(T);if(!L)return;let _=L.mode==="disabled";_&&(L.mode="hidden"),x.forEach(g=>{var A;((A=L.cues)==null?void 0:A.getCueById(g.id))||L.addCue(g)}),_&&(L.mode="disabled")}),b.on(Be.default.Events.DESTROYING,()=>{k.textTracks.removeEventListener("change",d),k.querySelectorAll("track[data-removeondestroy]").forEach(y=>{y.remove()})});let R=()=>{Array.from(k.textTracks).forEach(y=>{var T,I;if(!["subtitles","caption"].includes(y.kind)&&y.label==="thumbnails"){if(!((T=y.cues)==null?void 0:T.length)){let x=k.querySelector('track[label="thumbnails"]'),L=(I=x==null?void 0:x.getAttribute("src"))!=null?I:"";x==null||x.removeAttribute("src"),setTimeout(()=>{x==null||x.setAttribute("src",L)},0)}y.mode!=="hidden"&&(y.mode="hidden")}})};b.once(Be.default.Events.MANIFEST_LOADED,R),b.once(Be.default.Events.MEDIA_ATTACHED,R)}function er(k,b,d,R,y){let T=document.createElement("track");return T.kind=b,T.label=d,R&&(T.srclang=R),y&&(T.id=y),T.track.mode="disabled",T.setAttribute("data-removeondestroy",""),k.append(T),T.track}var Rt=(k,b)=>k in b,bt="mux.com",Pt=()=>ot.default.utils.now(),Ge={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},we={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},dt={HLS:we.M3U8},mr=Object.keys(dt),pr=[...Object.values(we),"hls","HLS"],tr=k=>{let b=k.indexOf("?");if(b<0)return[k];let d=k.slice(0,b),R=k.slice(b);return[d,R]},It=(k,{domain:b=bt}={})=>{if(!k)return;let[d,R=""]=tr(k);return`https://stream.${b}/${d}.m3u8${R}`},rr=k=>{let b="";try{b=new URL(k).pathname}catch{console.error("invalid url")}let d=b.lastIndexOf(".");if(d<0)return"";let R=b.slice(d+1).toUpperCase();return Rt(R,we)?we[R]:""},Mt=k=>{let b=k.type;if(b){let R=b.toUpperCase();return Rt(R,dt)?dt[R]:b}let{src:d}=k;return d?rr(d):""},ir=k=>{if([Ge.LIVE,Ge.LL_LIVE].includes(k)){let b={backBufferLength:12};return k===Ge.LL_LIVE?{...b,maxFragLookUpTolerance:.001}:b}return{}},ct=new WeakMap;var ht=(k,b)=>{b&&(b.detachMedia(),b.destroy()),(k==null?void 0:k.mux)&&!k.mux.deleted&&(k.mux.destroy(),k.mux),k&&(k.removeEventListener("error",Ct),k.removeEventListener("error",vt),ct.delete(k))},nr=(k,b)=>{var d,R,y;let{debug:T,preferMse:I,streamType:x,startTime:L=-1}=k,_=Mt(k),g=_===we.M3U8,A=!_||((d=b==null?void 0:b.canPlayType(_))!=null?d:!0),D=Ie.default.isSupported(),S=((y=(R=window==null?void 0:window.navigator)==null?void 0:R.userAgent)!=null?y:"").toLowerCase().indexOf("android")!==-1&&x===Ge.LL_LIVE;if(g&&!(!g||A&&!((I||S)&&D))&&D){let v={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},p=ir(x);return new Ie.default({debug:T,startPosition:L,...v,...p})}},ar=({playbackId:k,src:b,customDomain:d})=>{if(k)return!0;if(typeof b!="string")return!1;let R=new URL(b).hostname.toLocaleLowerCase();return R.includes(bt)||!!d&&R.includes(d.toLocaleLowerCase())},sr=(k,b,d)=>{let{envKey:R}=k,y=ar(k);if((R||y)&&b){let{playerInitTime:T,playerSoftwareName:I,playerSoftwareVersion:x,beaconCollectionDomain:L,metadata:_,debug:g}=k,A=D=>typeof D.player_error_code=="string"?!1:typeof k.errorTranslator=="function"?k.errorTranslator(D):D;ot.default.monitor(b,{debug:g,beaconCollectionDomain:L,hlsjs:d,Hls:d?Ie.default:void 0,automaticErrorTracking:!1,errorTranslator:A,data:{...R?{env_key:R}:{},player_software_name:I,player_software_version:x,player_init_time:T,..._}})}},or=(k,b,d)=>{var R,y,T;if(!b){console.warn("attempting to load media before mediaEl exists");return}let{preferMse:I,streamType:x}=k,L=Mt(k),_=L===we.M3U8,g=!L||((R=b==null?void 0:b.canPlayType(L))!=null?R:!0),A=Ie.default.isSupported(),D=((T=(y=window==null?void 0:window.navigator)==null?void 0:y.userAgent)!=null?T:"").toLowerCase().indexOf("android")!==-1&&x===Ge.LL_LIVE,S=!_||g&&!((I||D)&&A),{src:v}=k;if(b&&g&&S){if(typeof v=="string"){let{startTime:p}=k;if(b.setAttribute("src",v),p){let a=({target:e})=>{e.currentTime=p,e.removeEventListener("loadedmetadata",a)};b.addEventListener("loadedmetadata",a)}}else b.removeAttribute("src");b.addEventListener("error",Ct),b.addEventListener("error",vt)}else if(d&&v){switch(d.on(Ie.default.Events.ERROR,(p,a)=>{let e={[Ie.default.ErrorTypes.NETWORK_ERROR]:Ae.MEDIA_ERR_NETWORK,[Ie.default.ErrorTypes.MEDIA_ERROR]:Ae.MEDIA_ERR_DECODE},i=new Ae("",e[a.type]);i.fatal=a.fatal,i.data=a,b.dispatchEvent(new CustomEvent("error",{detail:i}))}),b.addEventListener("error",vt),qt(b,d),b.preload){case"none":b.addEventListener("play",()=>d.loadSource(v),{once:!0});break;case"metadata":let p=d.config.maxBufferLength,a=d.config.maxBufferSize;d.config.maxBufferLength=1,d.config.maxBufferSize=1,b.addEventListener("play",()=>{d.config.maxBufferLength=p,d.config.maxBufferSize=a},{once:!0}),d.loadSource(v);break;default:d.loadSource(v)}d.attachMedia(b)}else console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};async function Ct(k){if(!k.isTrusted)return;k.stopImmediatePropagation();let b=k.target;if(!(b==null?void 0:b.error))return;let{message:d,code:R}=b.error,y=new Ae(d,R);if(b.src&&(R!==Ae.MEDIA_ERR_DECODE||R!==void 0)){let{status:T}=await fetch(b.src);y.data={response:{code:T}}}b.dispatchEvent(new CustomEvent("error",{detail:y}))}function vt(k){var b;if(!(k instanceof CustomEvent)||!(k.detail instanceof Ae))return;let d=k.target,R=k.detail;if(!R||!R.fatal)return;let y=ct.get(d);y&&(y.error=R),(b=d.mux)==null||b.emit("error",{player_error_code:R.code,player_error_message:R.message})}var Ft=(k,b,d)=>{ht(b,d),ct.set(b,{});let R=nr(k,b);return sr(k,b,R),or(k,b,R),R};var lr=()=>{try{return"0.6.2-canary.2-830286f"}catch{}return"UNKNOWN"},ur=lr(),Bt=()=>ur;var wt=["abort","canplay","canplaythrough","durationchange","emptied","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"],Ut=document.createElement("template");Ut.innerHTML=`
|
|
30
30
|
<style>
|
|
31
31
|
:host {
|
|
32
32
|
/* display:inline (like the native el) makes it so you can't fill
|