@mux/mux-video 0.7.1-canary.0-556dabf

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/CHANGELOG.md ADDED
@@ -0,0 +1,96 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ # [0.7.0](https://github.com/muxinc/elements/compare/@mux-elements/mux-video@0.6.1...@mux-elements/mux-video@0.7.0) (2022-06-23)
7
+
8
+ ### Features
9
+
10
+ - **mux-video:** Add basic support for custom video domains. ([82cfb15](https://github.com/muxinc/elements/commit/82cfb15ecb9729329018c1fe999a1585bcae55c7))
11
+
12
+ ## [0.6.1](https://github.com/muxinc/elements/compare/@mux-elements/mux-video@0.6.0...@mux-elements/mux-video@0.6.1) (2022-06-07)
13
+
14
+ ### Bug Fixes
15
+
16
+ - importing castable-video ([44cbb2f](https://github.com/muxinc/elements/commit/44cbb2f26290952ac8d3fe51a1d933352b0b9134))
17
+
18
+ # [0.6.0](https://github.com/muxinc/elements/compare/@mux-elements/mux-video@0.5.4...@mux-elements/mux-video@0.6.0) (2022-06-06)
19
+
20
+ ### Features
21
+
22
+ - add casting logic without cast-button ([#237](https://github.com/muxinc/elements/issues/237)) ([f7f1fe9](https://github.com/muxinc/elements/commit/f7f1fe9713f8c2dcedb2840f463b5478d6fffca0))
23
+
24
+ ## [0.5.4](https://github.com/muxinc/elements/compare/@mux-elements/mux-video@0.5.3...@mux-elements/mux-video@0.5.4) (2022-05-26)
25
+
26
+ **Note:** Version bump only for package @mux-elements/mux-video
27
+
28
+ ## [0.5.3](https://github.com/muxinc/elements/compare/@mux-elements/mux-video@0.5.2...@mux-elements/mux-video@0.5.3) (2022-05-23)
29
+
30
+ **Note:** Version bump only for package @mux-elements/mux-video
31
+
32
+ ## [0.5.2](https://github.com/muxinc/elements/compare/@mux-elements/mux-video@0.5.1...@mux-elements/mux-video@0.5.2) (2022-05-20)
33
+
34
+ ### Bug Fixes
35
+
36
+ - switch cjs extension to .cjs.js ([30e83c3](https://github.com/muxinc/elements/commit/30e83c3ce0bd9bfda4817c30ffe0921e425619e4))
37
+
38
+ ## [0.5.1](https://github.com/muxinc/elements/compare/@mux-elements/mux-video@0.5.0...@mux-elements/mux-video@0.5.1) (2022-05-10)
39
+
40
+ ### Bug Fixes
41
+
42
+ - error message was not passed back to player ([ade8143](https://github.com/muxinc/elements/commit/ade81438834610a7bddfa158ff20ec671ccd508f))
43
+ - fix 3x init of playback-core if `src` used ([#213](https://github.com/muxinc/elements/issues/213)) ([1d3e465](https://github.com/muxinc/elements/commit/1d3e465f8cc40544f0fb2c17ff4fb435c9e9a807))
44
+
45
+ # [0.5.0](https://github.com/muxinc/elements/compare/@mux-elements/mux-video@0.4.5...@mux-elements/mux-video@0.5.0) (2022-05-03)
46
+
47
+ ### Bug Fixes
48
+
49
+ - custom video events handling ([#203](https://github.com/muxinc/elements/issues/203)) ([a909f89](https://github.com/muxinc/elements/commit/a909f89a69ee0d4b67e9d9371ac0f80984016181))
50
+ - keep .hls but have it log a warning saying to use .\_hls ([11e6c10](https://github.com/muxinc/elements/commit/11e6c102a7e238bc8104c52ae9b94e7e3c2c7e19))
51
+
52
+ ### Features
53
+
54
+ - add errorTranslator prop & muxVideo.error property ([#195](https://github.com/muxinc/elements/issues/195)) ([3afc2f0](https://github.com/muxinc/elements/commit/3afc2f0af75a5ad8ef00257a4ebc34882ff8c9ab))
55
+ - add part=video/audio for mux-video/audio ([49e5b6f](https://github.com/muxinc/elements/commit/49e5b6f14fde14d429afae5c5a46d7595c4e027e)), closes [#125](https://github.com/muxinc/elements/issues/125)
56
+ - rename hls to \_hls ([2d53bc2](https://github.com/muxinc/elements/commit/2d53bc2517840d65a8fd5e2bb2d979ce8b491116))
57
+
58
+ ## [0.4.5](https://github.com/muxinc/elements/compare/@mux-elements/mux-video@0.4.4...@mux-elements/mux-video@0.4.5) (2022-04-22)
59
+
60
+ ### Bug Fixes
61
+
62
+ - point pkgjson#browser at mjs build for webpack 4 ([#191](https://github.com/muxinc/elements/issues/191)) ([a73a495](https://github.com/muxinc/elements/commit/a73a4951052bfc77cc24667b9bc0a05efbcbb355))
63
+
64
+ ## [0.4.4](https://github.com/muxinc/elements/compare/@mux-elements/mux-video@0.4.3...@mux-elements/mux-video@0.4.4) (2022-04-18)
65
+
66
+ ### Bug Fixes
67
+
68
+ - make mux-player size based on video element ([#185](https://github.com/muxinc/elements/issues/185)) ([e4af9a8](https://github.com/muxinc/elements/commit/e4af9a885720f172837eb20ea49dc96bf66a77be))
69
+
70
+ ## [0.4.3](https://github.com/muxinc/elements/compare/@mux-elements/mux-video@0.4.2...@mux-elements/mux-video@0.4.3) (2022-04-12)
71
+
72
+ ### Bug Fixes
73
+
74
+ - clear some state on playbackId change ([#174](https://github.com/muxinc/elements/issues/174)) ([af0738e](https://github.com/muxinc/elements/commit/af0738ea5ae5a75861f75fc2ae3809ada735f3e2))
75
+
76
+ ## [0.4.2](https://github.com/muxinc/elements/compare/@mux-elements/mux-video@0.4.1...@mux-elements/mux-video@0.4.2) (2022-04-08)
77
+
78
+ ### Bug Fixes
79
+
80
+ - **mux-video:** prevent forward custom attrs ([#172](https://github.com/muxinc/elements/issues/172)) ([91a7812](https://github.com/muxinc/elements/commit/91a7812dff7163396440d8d1af26f94d04d3fea3))
81
+
82
+ ## [0.4.1](https://github.com/muxinc/elements/compare/@mux-elements/mux-video@0.4.0...@mux-elements/mux-video@0.4.1) (2022-04-01)
83
+
84
+ **Note:** Version bump only for package @mux-elements/mux-video
85
+
86
+ # [0.4.0](https://github.com/muxinc/elements/compare/@mux-elements/mux-video@0.3.0...@mux-elements/mux-video@0.4.0) (2022-03-28)
87
+
88
+ ### Bug Fixes
89
+
90
+ - **mux-video:** initial muted autoplay attribute should autoplay muted ([#148](https://github.com/muxinc/elements/issues/148)) ([0757127](https://github.com/muxinc/elements/commit/0757127bc3095b43d3b265e46b5eb8123a7e1bb5))
91
+ - **mux-video:** use generateInitTime() instead of Date.now. ([3ac1722](https://github.com/muxinc/elements/commit/3ac1722dc2140b1970323d96fa908e384682f93e))
92
+ - prettier format all elements files ([741d607](https://github.com/muxinc/elements/commit/741d607521ca9578cfad9f0a9216a6565b4c56a1))
93
+
94
+ ### Features
95
+
96
+ - add beaconCollectionDomain option to replace beaconDomain ([a44b699](https://github.com/muxinc/elements/commit/a44b699ae3138590b9d953f693f95971694658df))
package/README.md ADDED
@@ -0,0 +1,246 @@
1
+ <p align="center">
2
+ <h1 align="center">&lt;mux-video/&gt;</h1>
3
+ <a href="https://npmcharts.com/compare/@mux/mux-video?interval=30"><img src="https://img.shields.io/npm/dm/@mux/mux-video.svg?sanitize=true" alt="Downloads"></a>
4
+ <a href="https://www.npmjs.com/package/@mux/mux-video"><img src="https://img.shields.io/npm/v/@mux/mux-video.svg?sanitize=true" alt="Version"></a>
5
+ <a href="https://www.npmjs.com/package/@mux/mux-video"><img src="https://img.shields.io/npm/l/@mux/mux-video.svg?sanitize=true" alt="License"></a>
6
+ </p>
7
+
8
+ # Introduction
9
+
10
+ `<mux-video></mux-video>` is a Mux-flavored HTML5 video element.
11
+
12
+ If you are familiar with using `<video />` + [Hls.js](https://github.com/video-dev/hls.js) in your application, then you'll feel right at home with this web component.
13
+
14
+ # Installation
15
+
16
+ If you're using `npm` or `yarn`, install that way:
17
+
18
+ ## Package manager
19
+
20
+ ```
21
+ yarn add @mux/mux-video
22
+ ```
23
+
24
+ or
25
+
26
+ ```
27
+ npm i @mux/mux-video
28
+ ```
29
+
30
+ Then, import the library into your application with either `import` or `require`:
31
+
32
+ ```js
33
+ import '@mux/mux-video';
34
+ ```
35
+
36
+ or
37
+
38
+ ```js
39
+ require('@mux/mux-video');
40
+ ```
41
+
42
+ ## CDN option
43
+
44
+ Alternatively, use the CDN hosted version of this package:
45
+
46
+ ```html
47
+ <script src="https://unpkg.com/@mux/mux-video@0.4"></script>
48
+ ```
49
+
50
+ If you are using ECMAScript modules, you can also load the `mux-video.mjs` file with `type=module`:
51
+
52
+ ```html
53
+ <script type="module" src="https://unpkg.com/@mux/mux-video@0.4/dist/mux-video.mjs"></script>
54
+ ```
55
+
56
+ ## Features and benefits
57
+
58
+ Without `<mux-video>` if you want to use the browser built-in HTML5 video element for playback you would have to wire up [Hls.js](https://github.com/video-dev/hls.js) and [Mux Data](https://docs.mux.com/guides/data/monitor-hls-js) yourself.
59
+
60
+ `<mux-video>` will automatically handle recoverable errors that happen during video playback. This is particularly handy for live streams that may experience disconnects.
61
+
62
+ `<mux-video>` will use the optimial Hls.js settings for Mux Video so you don't have to worry about that. `<mux-video>` will also periodically test new versions of Hls.js and upgrade to known stable versions so you don't have to worry about upgrading to a new version of Hls.js yourself.
63
+
64
+ ## Usage
65
+
66
+ Loading this library in the browser will register a [custom web component](https://developer.mozilla.org/en-US/docs/Web/Web_Components) for `<mux-video>`.
67
+
68
+ Now you are free to use this web component in your HTML, just as you would with the HTML5 `<video>` element.
69
+
70
+ ```html
71
+ <body>
72
+ <mux-video
73
+ playback-id="DS00Spx1CV902MCtPj5WknGlR102V5HFkDe"
74
+ metadata-video-title="Big Buck Bunny"
75
+ metadata-viewer-user-id="user-id-1234"
76
+ stream-type="on-demand"
77
+ controls
78
+ ></mux-video>
79
+ </body>
80
+ ```
81
+
82
+ Attributes:
83
+
84
+ - `playback-id`: This is the playback ID for your Mux Asset or Mux Live Stream. The playback-id is the variable you may have used before to construct a `.m3u8` hls url like this:`https://stream.mux.com/{PLAYBACK_ID}.m3u8`. [Mux Docs](https://docs.mux.com/guides/video/play-your-videos#1-get-your-playback-id)
85
+ - `env-key`: This is the environment key for Mux Data. Note that this is different than your API Key. Get your env key from the "Mux Data" part of the Mux Dashboard. If undefined and you are playing a Mux Video asset, the environment will be inferred.
86
+
87
+ <img src="../../images/env-key.png" alt="Mux Data dashboard env key"></img>
88
+
89
+ - `metadata-video-title`: This is an arbitrary title for your video that will be passed in as metadata into Mux Data. Adding a title will give you useful context in your Mux Data dashboard. (optional, but encouraged)
90
+ - `metadata-viewer-user-id`: If you have a logged-in user this should be an anonymized ID value that maps back to the user in your database. Take care to not expose personal identifiable information like names, usernames or email addresses. (optional, but encouraged)
91
+ - `metadata-video-id`: This is an arbitrary ID that should map back to a record of this video in your database.
92
+ - `stream-type`: Enum value: one of `"on-demand"`, `"live"` (HLS live stream), `"ll-live"` (low latency live). Not strictly required, but preffered so that `<mux-video />` can make optimizations based on the type of stream.
93
+ - `start-time: number (seconds)`: Set this to start playback of your media at some time other than 0.
94
+
95
+ This is the bare bones of metadata that you should provide to the `<mux-video>` element.
96
+
97
+ All the other attributes that you would use on a `<video>` element like `poster`, `controls`, `muted` and `autoplay` are available and will work the same as they do with the HTML5 video element. One sidenote about `autoplay` though -- [read this to understand why that might not always work as expected](https://docs.mux.com/guides/video/web-autoplay-your-videos).
98
+
99
+ ### Advanced: more metadata
100
+
101
+ To go above and beyond `metadata-*` attributes
102
+
103
+ To set other available metadata fields use the `metadata` property on the `<mux-video>` element like so:
104
+
105
+ ```html
106
+ <mux-video
107
+ playback-id="DS00Spx1CV902MCtPj5WknGlR102V5HFkDe"
108
+ metadata-video-title="Big Buck Bunny"
109
+ metadata-viewer-user-id="user-id-1234"
110
+ controls
111
+ >
112
+ </mux-video>
113
+
114
+ <script>
115
+ const muxVideo = document.querySelector('mux-video');
116
+ muxVideo.metadata = {
117
+ experiment_name: 'landing_page_v3',
118
+ video_content_type: 'clip',
119
+ video_series: 'season 1',
120
+ };
121
+ </script>
122
+ ```
123
+
124
+ Instead of using the `metadata` property, you also have the option to specify a remote URL for fetching metadata asynchronously. In the example below you would have an API server running at `https://api.myapp.com/` and the specified endpoint should respond with JSON in the form of something like this:
125
+
126
+ ```json
127
+ {
128
+ "experiment_name": "landing_page_v3",
129
+ "video_content_type": "clip",
130
+ "video_series": "season 1"
131
+ }
132
+ ```
133
+
134
+ When `metadata-url` is specified then `<mux-video>` will asychronously fetch the extra metadata without blocking the initial startup time.
135
+
136
+ ```html
137
+ <mux-video
138
+ playback-id="DS00Spx1CV902MCtPj5WknGlR102V5HFkDe"
139
+ metadata-video-title="Big Buck Bunny"
140
+ metadata-viewer-user-id="user-id-1234"
141
+ metadata-url="https://api.myapp.com/v1/metadata-endpoint.json"
142
+ controls
143
+ >
144
+ </mux-video>
145
+ ```
146
+
147
+ Take a look at the [metadata guide](https://docs.mux.com/guides/data/make-your-data-actionable-with-metadata) to view an exhaustive list of available values.
148
+
149
+ ### Advanced: prefer-mse
150
+
151
+ By default `<mux-video>` will try to use native playback via the underlying `<video/>` tag whenever possible. However, it can also instead use an in-code player when the browser browser supports [Media Source Extension](https://developer.mozilla.org/en-US/docs/Web/API/Media_Source_Extensions_API). This includes MSE in Mac OS Safari.
152
+
153
+ If you prefer to use the in-code MSE-based engine (currently hls.js) whenever possible, then pass in the `prefer-mse` attribute.
154
+
155
+ ```html
156
+ <mux-video
157
+ playback-id="DS00Spx1CV902MCtPj5WknGlR102V5HFkDe"
158
+ metadata-video-title="Big Buck Bunny"
159
+ metadata-viewer-user-id="user-id-1234"
160
+ prefer-mse
161
+ controls
162
+ >
163
+ </mux-video>
164
+ ```
165
+
166
+ ### Advanced: type
167
+
168
+ By default `<mux-video>` will try to figure out the type of media you're trying to play (for example, an HLS/m3u8 media source, an mp4, etc.) based the extension of the file from the `src` attribute's url. This allows `<mux-video>` to determine whether it can/should use an in-code player or native playback. By way of example, the code below has an identifiable "mp4" extension, so `<mux-video>` will rely on native plyaback via the underlying `<video/>` tag.
169
+
170
+ ```html
171
+ <mux-video
172
+ src="https://stream.mux.com/DS00Spx1CV902MCtPj5WknGlR102V5HFkDe/high.mp4"
173
+ metadata-video-title="Big Buck Bunny"
174
+ metadata-viewer-user-id="user-id-1234"
175
+ prefer-mse
176
+ controls
177
+ >
178
+ </mux-video>
179
+ ```
180
+
181
+ Sometimes, however, your `src` URL may not have an identifiable extension. In these cases, we recommend relying on the `type` attribute, similar to the `<source/>` tag's [type attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/source#attr-type). Below is an example of explicitly declaring the MIME type for an HLS/m3u8 media source:
182
+
183
+ ```html
184
+ <mux-video
185
+ src="https://stream.notmux.com/path/to/an/hls/source/playlist"
186
+ type="application/vnd.apple.mpegurl"
187
+ metadata-video-title="Big Buck Bunny"
188
+ metadata-viewer-user-id="user-id-1234"
189
+ prefer-mse
190
+ controls
191
+ >
192
+ </mux-video>
193
+ ```
194
+
195
+ Or, for convenience, we also support the shorthand `type="hls`:
196
+
197
+ ```html
198
+ <mux-video
199
+ src="https://stream.notmux.com/path/to/an/hls/source/playlist"
200
+ type="hls"
201
+ metadata-video-title="Big Buck Bunny"
202
+ metadata-viewer-user-id="user-id-1234"
203
+ prefer-mse
204
+ controls
205
+ >
206
+ </mux-video>
207
+ ```
208
+
209
+ ### Advanced: Signed URLs and other playback query params
210
+
211
+ Mux supports a number of query parameters on HLS playback URLs. Most commonly is the `token=` param [used for signed URLs](https://docs.mux.com/guides/video/secure-video-playback).
212
+
213
+ In order to use `token=` -- or any other query params, pass them through with the `playback-id` attribute:
214
+
215
+ ```
216
+ playback-id="DS00Spx1CV902MCtPj5WknGlR102V5HFkDe?token=jwt-signed-token"
217
+ ```
218
+
219
+ ### Advanced: Use with React+TypeScript
220
+
221
+ Even though we don't (yet!) have our own `React` version of `<mux-video>`, you can still use it in your `React` app. However, if you're also using TypeScript, make sure you add the following TypeScript definitions, since custom elements (like as `<mux-video>`) will not be recognized as [Intrinsic Elements](https://www.typescriptlang.org/docs/handbook/jsx.html#intrinsic-elements):
222
+
223
+ ```typescript
224
+ interface MuxVideoHTMLAttributes<T> extends React.VideoHTMLAttributes<T> {
225
+ debug?: boolean;
226
+ autoplay?: boolean;
227
+ }
228
+
229
+ declare global {
230
+ namespace JSX {
231
+ interface IntrinsicElements {
232
+ 'mux-video': React.DetailedHTMLProps<MuxVideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>;
233
+ }
234
+ }
235
+ }
236
+ ```
237
+
238
+ # FAQ
239
+
240
+ ### If I'm using Mux, do I have to use this library?
241
+
242
+ No, you do not. The way Mux delivers HLS video is compliant with the HLS spec. Any video player that supports HLS will work with Mux Video.
243
+
244
+ ### If I'm not using Mux Video, can I still use this library?
245
+
246
+ You sure can! Instead of passing in `playback-id=""` attribute, pass in `src=""` with an HLS url. You can still use `env-key=""` to get all the features of Mux Data with your non-Mux video.
@@ -0,0 +1,20 @@
1
+ var Dt=Object.create;var G=Object.defineProperty;var Rt=Object.getOwnPropertyDescriptor;var kt=Object.getOwnPropertyNames;var wt=Object.getPrototypeOf,Lt=Object.prototype.hasOwnProperty;var Nt=(r,t,s)=>t in r?G(r,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[t]=s;var At=r=>G(r,"__esModule",{value:!0});var xt=(r,t)=>{At(r);for(var s in t)G(r,s,{get:t[s],enumerable:!0})},Ut=(r,t,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of kt(t))!Lt.call(r,n)&&n!=="default"&&G(r,n,{get:()=>t[n],enumerable:!(s=Rt(t,n))||s.enumerable});return r},Yt=r=>Ut(At(G(r!=null?Dt(wt(r)):{},"default",r&&r.__esModule&&"default"in r?{get:()=>r.default,enumerable:!0}:{value:r,enumerable:!0})),r);var B=(r,t,s)=>(Nt(r,typeof t!="symbol"?t+"":t,s),s),rt=(r,t,s)=>{if(!t.has(r))throw TypeError("Cannot "+s)};var a=(r,t,s)=>(rt(r,t,"read from private field"),s?s.call(r):t.get(r)),c=(r,t,s)=>{if(t.has(r))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(r):t.set(r,s)},E=(r,t,s,n)=>(rt(r,t,"write to private field"),n?n.call(r,s):t.set(r,s),s);var h=(r,t,s)=>(rt(r,t,"access private method"),s);xt(exports,{MediaError:()=>y.MediaError,VideoEvents:()=>ct,default:()=>Qt});var y=Yt(require("@mux/playback-core"));var Vt=()=>{try{return"0.7.1-canary.0-556dabf"}catch{}return"UNKNOWN"},Ft=Vt(),gt=()=>Ft;var Gt=r=>{var t,s,n,d,m,Bt,P,at,g,_,L,it,N,nt,$,Ht,z,jt,x,bt,U,T,S,C,M,I,O,tt,J,Kt,Y,vt,X,qt,V,St,Z,Wt,F,_t;return t=class extends r{constructor(){super();c(this,O);c(this,J);c(this,Y);c(this,X);c(this,V);c(this,Z);c(this,F);B(this,"castEnabled",!1);c(this,U,{paused:!1});c(this,T,void 0);c(this,S,{});c(this,C,void 0);c(this,M,void 0);c(this,I,void 0);t.instances.add(this),h(this,V,St).call(this)}static get castElement(){return a(t,s)}static get castEnabled(){return a(t,n)}static get castState(){var e;return(e=a(t,g,_))==null?void 0:e.getCastState()}static async exitCast(){let e=!0;try{await a(t,g,_).endCurrentSession(e)}catch(i){console.error(i);return}}get castPlayer(){if(t.castElement===this)return a(this,T)}attributeChangedCallback(e){if(!!this.castPlayer)switch(e){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(e={}){var i;h(i=t,x,bt).call(i,e),E(t,s,this),Object.entries(a(this,S)).forEach(([u,p])=>{a(this,T).controller.addEventListener(u,p)});try{await a(t,g,_).requestSession()}catch{E(t,s,void 0);return}a(this,U).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(u){console.error(u)}}async load(){var v,D;if(!this.castPlayer)return super.load();let e=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),i=[...this.querySelectorAll("track")].filter(({kind:b,src:A})=>A&&(b==="subtitles"||b==="captions")),u=[],p=0;i.length&&(e.tracks=i.map(b=>{let A=++p;u.length===0&&b.track.mode==="showing"&&u.push(A);let R=new chrome.cast.media.Track(A,chrome.cast.media.TrackType.TEXT);return R.trackContentId=b.src,R.trackContentType="text/vtt",R.subtype=b.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,R.name=b.label,R.language=b.srclang,R})),this.castStreamType==="live"?e.streamType=chrome.cast.media.StreamType.LIVE:e.streamType=chrome.cast.media.StreamType.BUFFERED,e.metadata=new chrome.cast.media.GenericMediaMetadata,e.metadata.title=this.title,e.metadata.images=[{url:this.poster}];let f=new chrome.cast.media.LoadRequest(e);f.currentTime=(v=super.currentTime)!=null?v:0,f.autoplay=!a(this,U).paused,f.activeTrackIds=u,await((D=a(t,L,it))==null?void 0:D.loadMedia(f)),this.dispatchEvent(new Event("volumechange"))}play(){var e;if(this.castPlayer){this.castPlayer.isPaused&&((e=this.castPlayer.controller)==null||e.playOrPause());return}return super.play()}pause(){var e;if(this.castPlayer){this.castPlayer.isPaused||(e=this.castPlayer.controller)==null||e.playOrPause();return}super.pause()}get castSrc(){var e,i,u;return(u=(i=this.getAttribute("cast-src"))!=null?i:(e=this.querySelector("source"))==null?void 0:e.src)!=null?u:this.currentSrc}set castSrc(e){this.castSrc!=e&&this.setAttribute("cast-src",`${e}`)}get castContentType(){var e;return(e=this.getAttribute("cast-content-type"))!=null?e:void 0}set castContentType(e){this.setAttribute("cast-content-type",`${e}`)}get castStreamType(){var e;return(e=this.getAttribute("cast-stream-type"))!=null?e:void 0}set castStreamType(e){this.setAttribute("cast-stream-type",`${e}`)}get readyState(){if(this.castPlayer)switch(this.castPlayer.playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return this.castPlayer?this.castPlayer.isPaused:super.paused}get muted(){var e;return this.castPlayer?(e=this.castPlayer)==null?void 0:e.isMuted:super.muted}set muted(e){var i;if(this.castPlayer){(e&&!this.castPlayer.isMuted||!e&&this.castPlayer.isMuted)&&((i=this.castPlayer.controller)==null||i.muteOrUnmute());return}super.muted=e}get volume(){var e,i;return this.castPlayer?(i=(e=this.castPlayer)==null?void 0:e.volumeLevel)!=null?i:1:super.volume}set volume(e){var i;if(this.castPlayer){this.castPlayer.volumeLevel=e,(i=this.castPlayer.controller)==null||i.setVolumeLevel();return}super.volume=e}get duration(){var e,i;return this.castPlayer&&a(this,O,tt)?(i=(e=this.castPlayer)==null?void 0:e.duration)!=null?i:NaN:super.duration}get currentTime(){var e,i;return this.castPlayer&&a(this,O,tt)?(i=(e=this.castPlayer)==null?void 0:e.currentTime)!=null?i:0:super.currentTime}set currentTime(e){var i;if(this.castPlayer){this.castPlayer.currentTime=e,(i=this.castPlayer.controller)==null||i.seek();return}super.currentTime=e}get onentercast(){return a(this,C)}set onentercast(e){a(this,C)&&(this.removeEventListener("entercast",a(this,C)),E(this,C,null)),typeof e=="function"&&(E(this,C,e),this.addEventListener("entercast",e))}get onleavecast(){return a(this,M)}set onleavecast(e){a(this,M)&&(this.removeEventListener("leavecast",a(this,M)),E(this,M,null)),typeof e=="function"&&(E(this,M,e),this.addEventListener("leavecast",e))}get oncastchange(){return a(this,I)}set oncastchange(e){a(this,I)&&(this.removeEventListener("castchange",a(this,I)),E(this,I,null)),typeof e=="function"&&(E(this,I,e),this.addEventListener("castchange",e))}},s=new WeakMap,n=new WeakMap,d=new WeakMap,m=new WeakSet,Bt=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},P=new WeakSet,at=function(){return typeof cast!="undefined"&&cast.framework},g=new WeakSet,_=function(){if(a(t,P,at))return cast.framework.CastContext.getInstance()},L=new WeakSet,it=function(){var e;return(e=a(t,g,_))==null?void 0:e.getCurrentSession()},N=new WeakSet,nt=function(){var e;return(e=a(t,L,it))==null?void 0:e.getSessionObj().media[0]},$=new WeakSet,Ht=function(e){return new Promise((i,u)=>{a(t,N,nt).editTracksInfo(e,i,u)})},z=new WeakSet,jt=function(e){return new Promise((i,u)=>{a(t,N,nt).getStatus(e,i,u)})},x=new WeakSet,bt=function(e){return a(t,g,_).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...e})},U=new WeakMap,T=new WeakMap,S=new WeakMap,C=new WeakMap,M=new WeakMap,I=new WeakMap,O=new WeakSet,tt=function(){var e;return(e=this.castPlayer)==null?void 0:e.isMediaLoaded},J=new WeakSet,Kt=function(){a(t,s)===this&&(Object.entries(a(this,S)).forEach(([e,i])=>{a(this,T).controller.removeEventListener(e,i)}),E(t,s,void 0),this.muted=a(this,T).isMuted,this.currentTime=a(this,T).savedPlayerState.currentTime,a(this,T).savedPlayerState.isPaused===!1&&this.play())},Y=new WeakSet,vt=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:a(t,g,_).getCastState()}))},X=new WeakSet,qt=async function(){var i,u;let{SESSION_RESUMED:e}=cast.framework.SessionState;if(a(t,g,_).getSessionState()===e&&this.castSrc===((i=a(t,N,nt))==null?void 0:i.media.contentId)){E(t,s,this),Object.entries(a(this,S)).forEach(([p,f])=>{a(this,T).controller.addEventListener(p,f)});try{await h(u=t,z,jt).call(u,new chrome.cast.media.GetStatusRequest)}catch(p){console.error(p)}a(this,S)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),a(this,S)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},V=new WeakSet,St=function(){var e;!a(t,P,at)||this.castEnabled||(this.castEnabled=!0,h(e=t,x,bt).call(e),this.textTracks.addEventListener("change",h(this,F,_t).bind(this)),h(this,Y,vt).call(this),E(this,T,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(a(this,T)),E(this,S,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:i})=>{i===!1&&h(this,J,Kt).call(this),this.dispatchEvent(new Event(i?"entercast":"leavecast"))},[cast.framework.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.dispatchEvent(new Event("durationchange"))},[cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{!a(this,O,tt)||this.dispatchEvent(new Event("timeupdate"))},[cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.dispatchEvent(new Event("resize"))},[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.dispatchEvent(new Event(this.paused?"pause":"play"))},[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var i,u;((i=this.castPlayer)==null?void 0:i.playerState)!==chrome.cast.media.PlayerState.PAUSED&&this.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(u=this.castPlayer)==null?void 0:u.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!a(this,O,tt)||(await Promise.resolve(),h(this,Z,Wt).call(this))}}))},Z=new WeakSet,Wt=function(){h(this,F,_t).call(this)},F=new WeakSet,_t=async function(){var lt,dt,ht,mt,Et,pt;if(!this.castPlayer)return;let i=((dt=(lt=a(this,T).mediaInfo)==null?void 0:lt.tracks)!=null?dt:[]).filter(({type:l})=>l===chrome.cast.media.TrackType.TEXT),u=[...this.textTracks].filter(({kind:l})=>l==="subtitles"||l==="captions"),p=i.map(({language:l,name:Q,trackId:st})=>{var yt;let{mode:ft}=(yt=u.find(Tt=>Tt.language===l&&Tt.label===Q))!=null?yt:{};return ft?{mode:ft,trackId:st}:!1}).filter(Boolean),v=p.filter(({mode:l})=>l!=="showing").map(({trackId:l})=>l),D=p.find(({mode:l})=>l==="showing"),b=(Et=(mt=(ht=a(t,L,it))==null?void 0:ht.getSessionObj().media[0])==null?void 0:mt.activeTrackIds)!=null?Et:[],A=b;if(b.length&&(A=A.filter(l=>!v.includes(l))),(D==null?void 0:D.trackId)&&(A=[...A,D.trackId]),A=[...new Set(A)],!((l,Q)=>l.length===Q.length&&l.every(st=>Q.includes(st)))(b,A))try{let l=new chrome.cast.media.EditTracksInfoRequest(A);await h(pt=t,$,Ht).call(pt,l)}catch(l){console.error(l)}},c(t,m),c(t,P),c(t,g),c(t,L),c(t,N),c(t,$),c(t,z),c(t,x),B(t,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),B(t,"instances",new Set),c(t,s,void 0),c(t,n,!1),B(t,"initCast",()=>{var e;a(t,m,Bt)?a(t,P,at)?a(e=t,d).call(e,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var i;return a(i=t,d).call(i,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var i;return a(i=t,d).call(i,chrome.cast.isAvailable)})}}),c(t,d,e=>{if(e){E(t,n,!0);let{CAST_STATE_CHANGED:i}=cast.framework.CastContextEventType;a(t,g,_).addEventListener(i,p=>{t.instances.forEach(f=>{var v;return h(v=f,Y,vt).call(v,p)})});let{SESSION_STATE_CHANGED:u}=cast.framework.CastContextEventType;a(t,g,_).addEventListener(u,p=>{t.instances.forEach(f=>{var v;return h(v=f,X,qt).call(v,p)})}),t.instances.forEach(p=>{var f;return h(f=p,V,St).call(f)})}}),t},ot=Gt(HTMLVideoElement);customElements.get("castable-video")||(customElements.define("castable-video",ot,{extends:"video"}),globalThis.CastableVideoElement=ot);ot.initCast();var ct=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","castchange","entercast","leavecast"],Pt=document.createElement("template");Pt.innerHTML=`
2
+ <style>
3
+ :host {
4
+ display: inline-block;
5
+ line-height: 0;
6
+ width: auto;
7
+ height: auto;
8
+ }
9
+
10
+ video {
11
+ max-width: 100%;
12
+ max-height: 100%;
13
+ min-width: 100%;
14
+ min-height: 100%;
15
+ }
16
+ </style>
17
+ <video is="castable-video" part="video" crossorigin></video>
18
+ <slot></slot>
19
+ `;var H,j,K,Ct,q,Mt,k=class extends HTMLElement{constructor(){super();c(this,K);c(this,q);c(this,H,void 0);c(this,j,void 0);this.attachShadow({mode:"open"}),this.isConnected&&h(this,K,Ct).call(this)}static get observedAttributes(){let t=[],s=d=>d.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();Object.getOwnPropertyNames(this.prototype).forEach(d=>{let m=!1;try{typeof this.prototype[d]=="function"&&(m=!0)}catch{}!m&&d!==d.toUpperCase()&&t.push(d.toLowerCase(),s(d))});let n=Object.getPrototypeOf(this).observedAttributes;return n&&(t=t.concat(n)),t}attributeChangedCallback(t,s,n){!a(this,H)&&!this.isConnected&&(E(this,H,!0),h(this,K,Ct).call(this)),h(this,q,Mt).call(this,t,s,n)}connectedCallback(){}};H=new WeakMap,j=new WeakMap,K=new WeakSet,Ct=function(){if(a(this,j))return;E(this,j,!0),this.shadowRoot.append(Pt.content.cloneNode(!0)),this.nativeEl=this.shadowRoot.querySelector("video"),ct.forEach(s=>{this.nativeEl.addEventListener(s,n=>{this.dispatchEvent(new CustomEvent(n.type,{detail:n.detail}))})});let t=this.shadowRoot.querySelector("slot");t.addEventListener("slotchange",()=>{t.assignedElements().forEach(s=>{!["track","source"].includes(s.localName)||this.nativeEl.append(s)})}),Array.prototype.forEach.call(this.attributes,s=>{h(this,q,Mt).call(this,s.name,null,s.value)}),this.nativeEl.defaultMuted&&(this.nativeEl.muted=!0)},q=new WeakSet,Mt=function(t,s,n){let d=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),m=zt(d,t),w=Object.getPrototypeOf(this.constructor).toString().indexOf("function HTMLElement")===0;m&&!w?typeof this[m]=="boolean"?n===null?this[m]=!1:this[m]=!0:this[m]=n:n===null?this.nativeEl.removeAttribute(t):["id","class"].indexOf(t)===-1&&this.nativeEl.setAttribute(t,n)};var It=[],Ot=document.createElement("video",{is:"castable-video"}),$t=["webkitDisplayingFullscreen","webkitSupportsFullscreen"];for(let r=Object.getPrototypeOf(Ot);r&&r!==HTMLElement.prototype;r=Object.getPrototypeOf(r))Object.getOwnPropertyNames(r).forEach(t=>{$t.indexOf(t)===-1&&It.push(t)});It.forEach(r=>{if(r in k.prototype)return;if(typeof Ot[r]=="function")k.prototype[r]=function(){return this.nativeEl[r].apply(this.nativeEl,arguments)};else{let s={get(){return this.nativeEl[r]}};r!==r.toUpperCase()&&(s.set=function(n){this.nativeEl[r]=n}),Object.defineProperty(k.prototype,r,s)}});function zt(r,t){let s=null;return r.forEach(n=>{n.toLowerCase()==t.toLowerCase()&&(s=n)}),s}globalThis.customElements.get("custom-video")||(globalThis.customElements.define("custom-video",k),globalThis.CustomVideoElement=k);var ut=k;var o={ENV_KEY:"env-key",DEBUG:"debug",PLAYBACK_ID:"playback-id",METADATA_URL:"metadata-url",PREFER_MSE:"prefer-mse",PLAYER_SOFTWARE_VERSION:"player-software-version",PLAYER_SOFTWARE_NAME:"player-software-name",METADATA_VIDEO_ID:"metadata-video-id",METADATA_VIDEO_TITLE:"metadata-video-title",METADATA_VIEWER_USER_ID:"metadata-viewer-user-id",BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",TYPE:"type",STREAM_TYPE:"stream-type",START_TIME:"start-time"},Jt=Object.values(o),Xt=gt(),Zt="mux-video",et=class extends ut{constructor(){super();this.__metadata={};this.__playerInitTime=(0,y.generatePlayerInitTime)()}static get observedAttributes(){var t;return[...Jt,...(t=ut.observedAttributes)!=null?t:[]]}get playerInitTime(){return this.__playerInitTime}get playerSoftwareName(){var t;return(t=this.__playerSoftwareName)!=null?t:Zt}set playerSoftwareName(t){this.__playerSoftwareName=t}get playerSoftwareVersion(){var t;return(t=this.__playerSoftwareVersion)!=null?t:Xt}set playerSoftwareVersion(t){this.__playerSoftwareVersion=t}get hls(){return console.warn("<mux-video>.hls is deprecated, please use ._hls instead"),this._hls}get _hls(){return this.__hls}get mux(){return this.nativeEl.mux}get error(){var t;return(t=(0,y.getError)(this.nativeEl))!=null?t:null}get errorTranslator(){return this.__errorTranslator}set errorTranslator(t){this.__errorTranslator=t}get src(){return this.getAttribute("src")}set src(t){t!==this.src&&(t==null?this.removeAttribute("src"):this.setAttribute("src",t))}get type(){var t;return(t=this.getAttribute(o.TYPE))!=null?t:void 0}set type(t){t!==this.type&&(t?this.setAttribute(o.TYPE,t):this.removeAttribute(o.TYPE))}get autoplay(){let t=this.getAttribute("autoplay");return t===null?!1:t===""?!0:t}set autoplay(t){let s=this.autoplay;t!==s&&(t?this.setAttribute("autoplay",typeof t=="string"?t:""):this.removeAttribute("autoplay"))}get debug(){return this.getAttribute(o.DEBUG)!=null}set debug(t){t!==this.debug&&(t?this.setAttribute(o.DEBUG,""):this.removeAttribute(o.DEBUG))}get startTime(){let t=this.getAttribute(o.START_TIME);if(t==null)return;let s=+t;return Number.isNaN(s)?void 0:s}set startTime(t){t!==this.startTime&&(t==null?this.removeAttribute(o.START_TIME):this.setAttribute(o.START_TIME,`${t}`))}get playbackId(){var t;return(t=this.getAttribute(o.PLAYBACK_ID))!=null?t:void 0}set playbackId(t){t!==this.playbackId&&(t?this.setAttribute(o.PLAYBACK_ID,t):this.removeAttribute(o.PLAYBACK_ID))}get customDomain(){var t;return(t=this.getAttribute(o.CUSTOM_DOMAIN))!=null?t:void 0}set customDomain(t){t!==this.customDomain&&(t?this.setAttribute(o.CUSTOM_DOMAIN,t):this.removeAttribute(o.CUSTOM_DOMAIN))}get envKey(){var t;return(t=this.getAttribute(o.ENV_KEY))!=null?t:void 0}set envKey(t){t!==this.envKey&&(t?this.setAttribute(o.ENV_KEY,t):this.removeAttribute(o.ENV_KEY))}get beaconCollectionDomain(){var t;return(t=this.getAttribute(o.BEACON_COLLECTION_DOMAIN))!=null?t:void 0}set beaconCollectionDomain(t){t!==this.beaconCollectionDomain&&(t?this.setAttribute(o.BEACON_COLLECTION_DOMAIN,t):this.removeAttribute(o.BEACON_COLLECTION_DOMAIN))}get streamType(){var t;return(t=this.getAttribute(o.STREAM_TYPE))!=null?t:void 0}set streamType(t){t!==this.streamType&&(t?this.setAttribute(o.STREAM_TYPE,t):this.removeAttribute(o.STREAM_TYPE))}get preferMse(){return this.getAttribute(o.PREFER_MSE)!=null}set preferMse(t){t?this.setAttribute(o.PREFER_MSE,""):this.removeAttribute(o.PREFER_MSE)}get metadata(){let t=this.getAttribute(o.METADATA_VIDEO_ID),s=this.getAttribute(o.METADATA_VIDEO_TITLE),n=this.getAttribute(o.METADATA_VIEWER_USER_ID);return{...this.__metadata,...t!=null?{video_id:t}:{},...s!=null?{video_title:s}:{},...n!=null?{viewer_user_id:n}:{}}}set metadata(t){this.__metadata=t!=null?t:{},this.mux&&this.mux.emit("hb",this.__metadata)}load(){let t=(0,y.initialize)(this,this.nativeEl,this.__hls);this.__hls=t;let s=(0,y.setupAutoplay)(this.nativeEl,this.autoplay,t);this.__updateAutoplay=s}unload(){(0,y.teardown)(this.nativeEl,this.__hls),this.__hls=void 0}attributeChangedCallback(t,s,n){var d;switch(t){case o.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=n!=null?n:void 0;break;case o.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=n!=null?n:void 0;break;case"src":let m=!!s,w=!!n;!m&&w?this.load():m&&!w?this.unload():m&&w&&(this.unload(),this.load());break;case"autoplay":if(n===s)break;(d=this.__updateAutoplay)==null||d.call(this,this.autoplay);break;case o.PLAYBACK_ID:this.src=(0,y.toMuxVideoURL)(n!=null?n:void 0,{domain:this.customDomain});break;case o.DEBUG:let P=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=P);break;case o.METADATA_URL:n&&fetch(n).then(W=>W.json()).then(W=>this.metadata=W).catch(W=>console.error(`Unable to load or parse metadata JSON from metadata-url ${n}!`));break;default:break}super.attributeChangedCallback(t,s,n)}disconnectedCallback(){this.unload()}};globalThis.customElements.get("mux-video")||(globalThis.customElements.define("mux-video",et),globalThis.MuxVideoElement=et);var Qt=et;
20
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts", "../src/env.ts", "../../../shared/castable-video/castable-video.js", "../src/CustomVideoElement.js"],
4
+ "sourcesContent": ["import {\n initialize,\n setupAutoplay,\n generatePlayerInitTime,\n MuxMediaProps,\n StreamTypes,\n ValueOf,\n toMuxVideoURL,\n teardown,\n Metadata,\n mux,\n MediaError,\n getError,\n} from '@mux/playback-core';\nimport type { PlaybackEngine, Autoplay, 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 CustomVideoElement, { VideoEvents } from './CustomVideoElement';\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 PLAYER_SOFTWARE_VERSION: 'player-software-version';\n PLAYER_SOFTWARE_NAME: 'player-software-name';\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 CUSTOM_DOMAIN: 'custom-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 PLAYER_SOFTWARE_VERSION: 'player-software-version',\n PLAYER_SOFTWARE_NAME: 'player-software-name',\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 CUSTOM_DOMAIN: 'custom-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-video';\n\nclass MuxVideoElement extends CustomVideoElement<HTMLVideoElement> implements Partial<MuxMediaProps> {\n static get observedAttributes() {\n return [...AttributeNameValues, ...(CustomVideoElement.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 __playerSoftwareVersion?: string;\n protected __playerSoftwareName?: string;\n protected __updateAutoplay?: UpdateAutoplay;\n protected __errorTranslator?: Function;\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 this.__playerSoftwareName ?? playerSoftwareName;\n }\n\n set playerSoftwareName(value: string | undefined) {\n this.__playerSoftwareName = value;\n }\n\n get playerSoftwareVersion() {\n return this.__playerSoftwareVersion ?? playerSoftwareVersion;\n }\n\n set playerSoftwareVersion(value: string | undefined) {\n this.__playerSoftwareVersion = value;\n }\n\n /**\n * @deprecated please use ._hls instead\n */\n get hls() {\n console.warn('<mux-video>.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<HTMLVideoElement['mux']> | undefined {\n return this.nativeEl.mux;\n }\n\n // @ts-ignore\n get error(): MediaError | null {\n return getError(this.nativeEl) ?? null;\n }\n\n get errorTranslator() {\n return this.__errorTranslator;\n }\n\n set errorTranslator(value: Function | undefined) {\n this.__errorTranslator = value;\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 get type(): ValueOf<ExtensionMimeTypeMap> | undefined {\n return (this.getAttribute(Attributes.TYPE) as ValueOf<ExtensionMimeTypeMap>) ?? undefined;\n }\n\n set type(val: ValueOf<ExtensionMimeTypeMap> | undefined) {\n // dont' cause an infinite loop\n if (val === this.type) return;\n\n if (val) {\n this.setAttribute(Attributes.TYPE, val);\n } else {\n this.removeAttribute(Attributes.TYPE);\n }\n }\n\n get autoplay(): Autoplay {\n const attr = this.getAttribute('autoplay');\n\n if (attr === null) {\n return false;\n } else if (attr === '') {\n return true;\n } else {\n return attr as Autoplay;\n }\n }\n\n set autoplay(val: Autoplay) {\n const currentVal = this.autoplay;\n if (val === currentVal) {\n return;\n }\n\n if (val) {\n this.setAttribute('autoplay', typeof val === 'string' ? val : '');\n } else {\n this.removeAttribute('autoplay');\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 customDomain() {\n return this.getAttribute(Attributes.CUSTOM_DOMAIN) ?? undefined;\n }\n\n set customDomain(val: string | undefined) {\n // dont' cause an infinite loop\n if (val === this.customDomain) return;\n\n if (val) {\n this.setAttribute(Attributes.CUSTOM_DOMAIN, val);\n } else {\n this.removeAttribute(Attributes.CUSTOM_DOMAIN);\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 // don't 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 const video_id = this.getAttribute(Attributes.METADATA_VIDEO_ID);\n const video_title = this.getAttribute(Attributes.METADATA_VIDEO_TITLE);\n const viewer_user_id = this.getAttribute(Attributes.METADATA_VIEWER_USER_ID);\n return {\n ...this.__metadata,\n ...(video_id != null ? { video_id } : {}),\n ...(video_title != null ? { video_title } : {}),\n ...(viewer_user_id != null ? { viewer_user_id } : {}),\n };\n }\n\n set metadata(val: Readonly<Metadata> | undefined) {\n this.__metadata = val ?? {};\n if (!!this.mux) {\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 // NOTE: This was carried over from hls-video-element. Is it needed for an edge case?\n // play() {\n // if (this.readyState === 0 && this.networkState < 2) {\n // this.load();\n // this._hls.on(Hls.Events.MANIFEST_PARSED,function() {\n // video.play();\n //\n // return this.nativeEl.play();\n // }\n // }\n\n attributeChangedCallback(attrName: string, oldValue: string | null, newValue: string | null) {\n switch (attrName) {\n case Attributes.PLAYER_SOFTWARE_NAME:\n this.playerSoftwareName = newValue ?? undefined;\n break;\n case Attributes.PLAYER_SOFTWARE_VERSION:\n this.playerSoftwareVersion = newValue ?? undefined;\n break;\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 if (newValue === oldValue) {\n break;\n }\n /** In case newValue is an empty string or null, use this.autoplay which translates to booleans (WL) */\n this.__updateAutoplay?.(this.autoplay);\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, { domain: this.customDomain }) 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 MuxVideoElementType = typeof MuxVideoElement;\ndeclare global {\n var MuxVideoElement: MuxVideoElementType;\n}\n\n/** @TODO Refactor once using `globalThis` polyfills */\nif (!globalThis.customElements.get('mux-video')) {\n globalThis.customElements.define('mux-video', MuxVideoElement);\n /** @TODO consider externalizing this (breaks standard modularity) */\n globalThis.MuxVideoElement = MuxVideoElement;\n}\n\nexport { PlaybackEngine, PlaybackEngine as Hls, ExtensionMimeTypeMap as MimeTypes, MediaError, VideoEvents };\n\nexport default MuxVideoElement;\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", "/* global globalThis, chrome, cast */\n\n/**\n * CastableVideoMixin\n *\n * Because there can only be one custom built-in (is=\"my-video\") this mixin function\n * provides a way to compose multiple classes to create one custom built-in class.\n * @see https://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/\n *\n * @param {HTMLVideoElement} superclass - HTMLVideoElement or an extended class of it.\n * @return {CastableVideo}\n */\nconst CastableVideoMixin = (superclass) =>\n class CastableVideo extends superclass {\n static observedAttributes = ['cast-src', 'cast-content-type', 'cast-stream-type'];\n static instances = new Set();\n\n static #castElement;\n static get castElement() {\n return CastableVideo.#castElement;\n }\n\n static #castEnabled = false;\n static get castEnabled() {\n return CastableVideo.#castEnabled;\n }\n\n static get castState() {\n return CastableVideo.#castContext?.getCastState();\n }\n\n static async exitCast() {\n // Should the receiver application be stopped or just disconnected.\n const stopCasting = true;\n try {\n await CastableVideo.#castContext.endCurrentSession(stopCasting);\n } catch (err) {\n console.error(err);\n return;\n }\n }\n\n static initCast = () => {\n if (!this.#isChromeCastAvailable) {\n globalThis.__onGCastApiAvailable = () => {\n // The globalThis.__onGCastApiAvailable callback alone is not reliable for\n // the added cast.framework. It's loaded in a separate JS file.\n // http://www.gstatic.com/eureka/clank/101/cast_sender.js\n // http://www.gstatic.com/cast/sdk/libs/sender/1.0/cast_framework.js\n customElements.whenDefined('google-cast-button').then(() => this.#onSdkLoaded(chrome.cast.isAvailable));\n };\n } else if (!this.#isCastFrameworkAvailable) {\n customElements.whenDefined('google-cast-button').then(() => this.#onSdkLoaded(chrome.cast.isAvailable));\n } else {\n this.#onSdkLoaded(chrome.cast.isAvailable);\n }\n };\n\n static #onSdkLoaded = (isAvailable) => {\n if (isAvailable) {\n this.#castEnabled = true;\n\n const { CAST_STATE_CHANGED } = cast.framework.CastContextEventType;\n CastableVideo.#castContext.addEventListener(CAST_STATE_CHANGED, (e) => {\n this.instances.forEach((video) => video.#onCastStateChanged(e));\n });\n\n const { SESSION_STATE_CHANGED } = cast.framework.CastContextEventType;\n CastableVideo.#castContext.addEventListener(SESSION_STATE_CHANGED, (e) => {\n this.instances.forEach((video) => video.#onSessionStateChanged(e));\n });\n\n this.instances.forEach((video) => video.#init());\n }\n };\n\n static get #isChromeCastAvailable() {\n return typeof chrome !== 'undefined' && chrome.cast && chrome.cast.isAvailable;\n }\n\n static get #isCastFrameworkAvailable() {\n return typeof cast !== 'undefined' && cast.framework;\n }\n\n static get #castContext() {\n if (CastableVideo.#isCastFrameworkAvailable) {\n return cast.framework.CastContext.getInstance();\n }\n return undefined;\n }\n\n static get #currentSession() {\n return CastableVideo.#castContext?.getCurrentSession();\n }\n\n static get #currentMedia() {\n return CastableVideo.#currentSession?.getSessionObj().media[0];\n }\n\n static #editTracksInfo(request) {\n return new Promise((resolve, reject) => {\n CastableVideo.#currentMedia.editTracksInfo(request, resolve, reject);\n });\n }\n\n static #getMediaStatus(request) {\n return new Promise((resolve, reject) => {\n CastableVideo.#currentMedia.getStatus(request, resolve, reject);\n });\n }\n\n static #setOptions(options) {\n return CastableVideo.#castContext.setOptions({\n // Set the receiver application ID to your own (created in the\n // Google Cast Developer Console), or optionally\n // use the chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID\n receiverApplicationId: chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,\n\n // Auto join policy can be one of the following three:\n // ORIGIN_SCOPED - Auto connect from same appId and page origin\n // TAB_AND_ORIGIN_SCOPED - Auto connect from same appId, page origin, and tab\n // PAGE_SCOPED - No auto connect\n autoJoinPolicy: chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,\n\n // The following flag enables Cast Connect(requires Chrome 87 or higher)\n // https://developers.googleblog.com/2020/08/introducing-cast-connect-android-tv.html\n androidReceiverCompatible: false,\n\n language: 'en-US',\n resumeSavedSession: true,\n\n ...options,\n });\n }\n\n castEnabled = false;\n #localState = { paused: false };\n #remotePlayer;\n #remoteListeners = {};\n #enterCastCallback;\n #leaveCastCallback;\n #castChangeCallback;\n\n constructor() {\n super();\n\n CastableVideo.instances.add(this);\n this.#init();\n }\n\n get castPlayer() {\n if (CastableVideo.castElement === this) return this.#remotePlayer;\n return undefined;\n }\n\n get #isMediaLoaded() {\n return this.castPlayer?.isMediaLoaded;\n }\n\n attributeChangedCallback(attrName) {\n if (!this.castPlayer) return;\n\n switch (attrName) {\n case 'cast-stream-type':\n case 'cast-src':\n this.load();\n break;\n }\n }\n\n #disconnect() {\n if (CastableVideo.#castElement !== this) return;\n\n Object.entries(this.#remoteListeners).forEach(([event, listener]) => {\n this.#remotePlayer.controller.removeEventListener(event, listener);\n });\n\n CastableVideo.#castElement = undefined;\n\n // isMuted is not in savedPlayerState. should we sync this back to local?\n this.muted = this.#remotePlayer.isMuted;\n this.currentTime = this.#remotePlayer.savedPlayerState.currentTime;\n if (this.#remotePlayer.savedPlayerState.isPaused === false) {\n this.play();\n }\n }\n\n #onCastStateChanged() {\n // Cast state: NO_DEVICES_AVAILABLE, NOT_CONNECTED, CONNECTING, CONNECTED\n // https://developers.google.com/cast/docs/reference/web_sender/cast.framework#.CastState\n this.dispatchEvent(\n new CustomEvent('castchange', {\n detail: CastableVideo.#castContext.getCastState(),\n })\n );\n }\n\n async #onSessionStateChanged() {\n // Session states: NO_SESSION, SESSION_STARTING, SESSION_STARTED, SESSION_START_FAILED,\n // SESSION_ENDING, SESSION_ENDED, SESSION_RESUMED\n // https://developers.google.com/cast/docs/reference/web_sender/cast.framework#.SessionState\n\n const { SESSION_RESUMED } = cast.framework.SessionState;\n if (CastableVideo.#castContext.getSessionState() === SESSION_RESUMED) {\n /**\n * Figure out if this was the video that started the resumed session.\n * @TODO make this more specific than just checking against the video src!! (WL)\n *\n * If this video element can get the same unique id on each browser refresh\n * it would be possible to pass this unique id w/ `LoadRequest.customData`\n * and verify against CastableVideo.#currentMedia.customData below.\n */\n if (this.castSrc === CastableVideo.#currentMedia?.media.contentId) {\n CastableVideo.#castElement = this;\n\n Object.entries(this.#remoteListeners).forEach(([event, listener]) => {\n this.#remotePlayer.controller.addEventListener(event, listener);\n });\n\n /**\n * There is cast framework resume session bug when you refresh the page a few\n * times the this.#remotePlayer.currentTime will not be in sync with the receiver :(\n * The below status request syncs it back up.\n */\n try {\n await CastableVideo.#getMediaStatus(new chrome.cast.media.GetStatusRequest());\n } catch (error) {\n console.error(error);\n }\n\n // Dispatch the play, playing events manually to sync remote playing state.\n this.#remoteListeners[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]();\n this.#remoteListeners[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]();\n }\n }\n }\n\n #init() {\n if (!CastableVideo.#isCastFrameworkAvailable || this.castEnabled) return;\n this.castEnabled = true;\n CastableVideo.#setOptions();\n\n /**\n * @TODO add listeners for addtrack, removetrack (WL)\n * This only has an impact on <track> with a `src` because these have to be\n * loaded manually in the load() method. This will require a new load() call\n * for each added/removed track w/ src.\n */\n this.textTracks.addEventListener('change', this.#updateRemoteTextTrack.bind(this));\n\n this.#onCastStateChanged();\n\n this.#remotePlayer = new cast.framework.RemotePlayer();\n new cast.framework.RemotePlayerController(this.#remotePlayer);\n\n this.#remoteListeners = {\n [cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]: ({ value }) => {\n if (value === false) {\n this.#disconnect();\n }\n this.dispatchEvent(new Event(value ? 'entercast' : 'leavecast'));\n },\n [cast.framework.RemotePlayerEventType.DURATION_CHANGED]: () => {\n this.dispatchEvent(new Event('durationchange'));\n },\n [cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]: () => {\n this.dispatchEvent(new Event('volumechange'));\n },\n [cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]: () => {\n this.dispatchEvent(new Event('volumechange'));\n },\n [cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]: () => {\n if (!this.#isMediaLoaded) return;\n this.dispatchEvent(new Event('timeupdate'));\n },\n [cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]: () => {\n this.dispatchEvent(new Event('resize'));\n },\n [cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]: () => {\n this.dispatchEvent(new Event(this.paused ? 'pause' : 'play'));\n },\n [cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]: () => {\n // Player states: IDLE, PLAYING, PAUSED, BUFFERING\n // https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.media#.PlayerState\n\n // pause event is handled above.\n if (this.castPlayer?.playerState === chrome.cast.media.PlayerState.PAUSED) {\n return;\n }\n this.dispatchEvent(\n new Event(\n {\n [chrome.cast.media.PlayerState.PLAYING]: 'playing',\n [chrome.cast.media.PlayerState.BUFFERING]: 'waiting',\n [chrome.cast.media.PlayerState.IDLE]: 'emptied',\n }[this.castPlayer?.playerState]\n )\n );\n },\n [cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]: async () => {\n if (!this.#isMediaLoaded) return;\n\n // mediaInfo is not immediately available due to a bug? wait one tick\n await Promise.resolve();\n this.#onRemoteMediaLoaded();\n },\n };\n }\n\n async requestCast(options = {}) {\n CastableVideo.#setOptions(options);\n CastableVideo.#castElement = this;\n\n Object.entries(this.#remoteListeners).forEach(([event, listener]) => {\n this.#remotePlayer.controller.addEventListener(event, listener);\n });\n\n try {\n // Open browser cast menu.\n await CastableVideo.#castContext.requestSession();\n } catch (err) {\n CastableVideo.#castElement = undefined;\n // console.error(err); // Don't show an error if dismissing the menu.\n return;\n }\n\n // Pause locally when the session is created.\n this.#localState.paused = super.paused;\n super.pause();\n\n // Sync over the muted state but not volume, 100% is different on TV's :P\n this.muted = super.muted;\n\n try {\n await this.load();\n } catch (err) {\n console.error(err);\n }\n }\n\n async load() {\n if (!this.castPlayer) return super.load();\n\n const mediaInfo = new chrome.cast.media.MediaInfo(this.castSrc, this.castContentType);\n\n // Manually add text tracks with a `src` attribute.\n // M3U8's load text tracks in the receiver, handle these in the media loaded event.\n const subtitles = [...this.querySelectorAll('track')].filter(({ kind, src }) => {\n return src && (kind === 'subtitles' || kind === 'captions');\n });\n\n const activeTrackIds = [];\n let textTrackIdCount = 0;\n\n if (subtitles.length) {\n mediaInfo.tracks = subtitles.map((trackEl) => {\n const trackId = ++textTrackIdCount;\n // only activate 1 subtitle text track.\n if (activeTrackIds.length === 0 && trackEl.track.mode === 'showing') {\n activeTrackIds.push(trackId);\n }\n\n const track = new chrome.cast.media.Track(trackId, chrome.cast.media.TrackType.TEXT);\n track.trackContentId = trackEl.src;\n track.trackContentType = 'text/vtt';\n track.subtype =\n trackEl.kind === 'captions'\n ? chrome.cast.media.TextTrackType.CAPTIONS\n : chrome.cast.media.TextTrackType.SUBTITLES;\n track.name = trackEl.label;\n track.language = trackEl.srclang;\n return track;\n });\n }\n\n if (this.castStreamType === 'live') {\n mediaInfo.streamType = chrome.cast.media.StreamType.LIVE;\n } else {\n mediaInfo.streamType = chrome.cast.media.StreamType.BUFFERED;\n }\n\n mediaInfo.metadata = new chrome.cast.media.GenericMediaMetadata();\n mediaInfo.metadata.title = this.title;\n mediaInfo.metadata.images = [\n {\n url: this.poster,\n },\n ];\n\n const request = new chrome.cast.media.LoadRequest(mediaInfo);\n request.currentTime = super.currentTime ?? 0;\n request.autoplay = !this.#localState.paused;\n request.activeTrackIds = activeTrackIds;\n\n await CastableVideo.#currentSession?.loadMedia(request);\n\n this.dispatchEvent(new Event('volumechange'));\n }\n\n #onRemoteMediaLoaded() {\n this.#updateRemoteTextTrack();\n }\n\n async #updateRemoteTextTrack() {\n if (!this.castPlayer) return;\n\n // Get the tracks w/ trackId's that have been loaded; manually or via a playlist like a M3U8 or MPD.\n const remoteTracks = this.#remotePlayer.mediaInfo?.tracks ?? [];\n const remoteSubtitles = remoteTracks.filter(({ type }) => type === chrome.cast.media.TrackType.TEXT);\n\n const localSubtitles = [...this.textTracks].filter(({ kind }) => kind === 'subtitles' || kind === 'captions');\n\n // Create a new array from the local subs w/ the trackId's from the remote subs.\n const subtitles = remoteSubtitles\n .map(({ language, name, trackId }) => {\n // Find the corresponding local text track and assign the trackId.\n const { mode } = localSubtitles.find((local) => local.language === language && local.label === name) ?? {};\n if (mode) return { mode, trackId };\n return false;\n })\n .filter(Boolean);\n\n const hiddenSubtitles = subtitles.filter(({ mode }) => mode !== 'showing');\n const hiddenTrackIds = hiddenSubtitles.map(({ trackId }) => trackId);\n const showingSubtitle = subtitles.find(({ mode }) => mode === 'showing');\n\n // Note this could also include audio or video tracks, diff against local state.\n const activeTrackIds = CastableVideo.#currentSession?.getSessionObj().media[0]?.activeTrackIds ?? [];\n let requestTrackIds = activeTrackIds;\n\n if (activeTrackIds.length) {\n // Filter out all local hidden subtitle trackId's.\n requestTrackIds = requestTrackIds.filter((id) => !hiddenTrackIds.includes(id));\n }\n\n if (showingSubtitle?.trackId) {\n requestTrackIds = [...requestTrackIds, showingSubtitle.trackId];\n }\n\n // Remove duplicate ids.\n requestTrackIds = [...new Set(requestTrackIds)];\n\n const arrayEquals = (a, b) => a.length === b.length && a.every((a) => b.includes(a));\n if (!arrayEquals(activeTrackIds, requestTrackIds)) {\n try {\n const request = new chrome.cast.media.EditTracksInfoRequest(requestTrackIds);\n await CastableVideo.#editTracksInfo(request);\n } catch (error) {\n console.error(error);\n }\n }\n }\n\n play() {\n if (this.castPlayer) {\n if (this.castPlayer.isPaused) {\n this.castPlayer.controller?.playOrPause();\n }\n return;\n }\n return super.play();\n }\n\n pause() {\n if (this.castPlayer) {\n if (!this.castPlayer.isPaused) {\n this.castPlayer.controller?.playOrPause();\n }\n return;\n }\n super.pause();\n }\n\n // Allow the cast source url to be different than <video src>, could be a blob.\n get castSrc() {\n // Try the first <source src> for usage with even more native markup.\n return this.getAttribute('cast-src') ?? this.querySelector('source')?.src ?? this.currentSrc;\n }\n\n set castSrc(val) {\n if (this.castSrc == val) return;\n this.setAttribute('cast-src', `${val}`);\n }\n\n get castContentType() {\n return this.getAttribute('cast-content-type') ?? undefined;\n }\n\n set castContentType(val) {\n this.setAttribute('cast-content-type', `${val}`);\n }\n\n get castStreamType() {\n return this.getAttribute('cast-stream-type') ?? undefined;\n }\n\n set castStreamType(val) {\n this.setAttribute('cast-stream-type', `${val}`);\n }\n\n get readyState() {\n if (this.castPlayer) {\n switch (this.castPlayer.playerState) {\n case chrome.cast.media.PlayerState.IDLE:\n return 0;\n case chrome.cast.media.PlayerState.BUFFERING:\n return 2;\n default:\n return 3;\n }\n }\n return super.readyState;\n }\n\n get paused() {\n if (this.castPlayer) return this.castPlayer.isPaused;\n return super.paused;\n }\n\n get muted() {\n if (this.castPlayer) return this.castPlayer?.isMuted;\n return super.muted;\n }\n\n set muted(val) {\n if (this.castPlayer) {\n if ((val && !this.castPlayer.isMuted) || (!val && this.castPlayer.isMuted)) {\n this.castPlayer.controller?.muteOrUnmute();\n }\n return;\n }\n super.muted = val;\n }\n\n get volume() {\n if (this.castPlayer) return this.castPlayer?.volumeLevel ?? 1;\n return super.volume;\n }\n\n set volume(val) {\n if (this.castPlayer) {\n this.castPlayer.volumeLevel = val;\n this.castPlayer.controller?.setVolumeLevel();\n return;\n }\n super.volume = val;\n }\n\n get duration() {\n // castPlayer duration returns `0` when no media is loaded.\n if (this.castPlayer && this.#isMediaLoaded) {\n return this.castPlayer?.duration ?? NaN;\n }\n return super.duration;\n }\n\n get currentTime() {\n if (this.castPlayer && this.#isMediaLoaded) {\n return this.castPlayer?.currentTime ?? 0;\n }\n return super.currentTime;\n }\n\n set currentTime(val) {\n if (this.castPlayer) {\n this.castPlayer.currentTime = val;\n this.castPlayer.controller?.seek();\n return;\n }\n super.currentTime = val;\n }\n\n get onentercast() {\n return this.#enterCastCallback;\n }\n\n set onentercast(callback) {\n if (this.#enterCastCallback) {\n this.removeEventListener('entercast', this.#enterCastCallback);\n this.#enterCastCallback = null;\n }\n if (typeof callback == 'function') {\n this.#enterCastCallback = callback;\n this.addEventListener('entercast', callback);\n }\n }\n\n get onleavecast() {\n return this.#leaveCastCallback;\n }\n\n set onleavecast(callback) {\n if (this.#leaveCastCallback) {\n this.removeEventListener('leavecast', this.#leaveCastCallback);\n this.#leaveCastCallback = null;\n }\n if (typeof callback == 'function') {\n this.#leaveCastCallback = callback;\n this.addEventListener('leavecast', callback);\n }\n }\n\n get oncastchange() {\n return this.#castChangeCallback;\n }\n\n set oncastchange(callback) {\n if (this.#castChangeCallback) {\n this.removeEventListener('castchange', this.#castChangeCallback);\n this.#castChangeCallback = null;\n }\n if (typeof callback == 'function') {\n this.#castChangeCallback = callback;\n this.addEventListener('castchange', callback);\n }\n }\n };\n\nconst CastableVideoElement = CastableVideoMixin(HTMLVideoElement);\n\nif (!customElements.get('castable-video')) {\n customElements.define('castable-video', CastableVideoElement, {\n extends: 'video',\n });\n globalThis.CastableVideoElement = CastableVideoElement;\n}\n\nCastableVideoElement.initCast();\n", "import 'castable-video';\n\n/**\n * Custom Video Element\n * The goal is to create an element that works just like the video element\n * but can be extended/sub-classed, because native elements cannot be\n * extended today across browsers.\n */\n\n// The onevent like props are weirdly set on the HTMLElement prototype with other\n// generic events making it impossible to pick these specific to HTMLMediaElement.\nexport const VideoEvents = [\n 'abort',\n 'canplay',\n 'canplaythrough',\n 'durationchange',\n 'emptied',\n 'encrypted',\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 'waitingforkey',\n 'resize',\n 'enterpictureinpicture',\n 'leavepictureinpicture',\n 'castchange',\n 'entercast',\n 'leavecast',\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-block;\n line-height: 0;\n width: auto;\n height: auto;\n }\n\n video {\n max-width: 100%;\n max-height: 100%;\n min-width: 100%;\n min-height: 100%;\n }\n</style>\n<video is=\"castable-video\" part=\"video\" crossorigin></video>\n<slot></slot>\n`;\n\nclass CustomVideoElement extends HTMLElement {\n #hasAttrCallback;\n #isInit;\n\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n\n // If the custom element is defined before the <custom-video> HTML is parsed\n // no attributes will be available in the constructor (construction process).\n // Wait until initializing attributes in the attributeChangedCallback.\n // If this element is connected to the DOM, the attributes will be available.\n if (this.isConnected) {\n this.#init();\n }\n }\n\n #init() {\n if (this.#isInit) return;\n this.#isInit = true;\n\n this.shadowRoot.append(template.content.cloneNode(true));\n this.nativeEl = this.shadowRoot.querySelector('video');\n\n // The video events are dispatched on the CustomVideoElement instance.\n // This makes it possible to add event listeners before the element is upgraded.\n VideoEvents.forEach((type) => {\n this.nativeEl.addEventListener(type, (evt) => {\n this.dispatchEvent(new CustomEvent(evt.type, { detail: evt.detail }));\n });\n });\n\n // An unnamed <slot> will be filled with all of the custom element's\n // top-level child nodes that do not have the slot attribute.\n const slotEl = this.shadowRoot.querySelector('slot');\n slotEl.addEventListener('slotchange', () => {\n slotEl.assignedElements().forEach((el) => {\n if (!['track', 'source'].includes(el.localName)) return;\n this.nativeEl.append(el);\n });\n });\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 // Don't call attributeChangedCallback directly here because the extending class\n // could have overridden attributeChangedCallback leading to unexpected results.\n Array.prototype.forEach.call(this.attributes, (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 (this.nativeEl.defaultMuted) {\n this.nativeEl.muted = true;\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 const kebabCase = (name) => {\n return name.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();\n };\n\n // Instead of manually creating a list of all observed attributes, observe\n // any getter/setter prop name (lowercase or kebab-case for custom builtins)\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(), kebabCase(propName));\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 attributeChangedCallback(attrName, oldValue, newValue) {\n // Initialize the attributes right after construction when they become available.\n if (!this.#hasAttrCallback && !this.isConnected) {\n this.#hasAttrCallback = true;\n this.#init();\n }\n\n this.#forwardAttribute(attrName, oldValue, newValue);\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 #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.\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('video', {\n is: 'castable-video',\n});\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. VideoElement and MediaElement\nfor (\n let proto = Object.getPrototypeOf(nativeElTest);\n proto && proto !== HTMLElement.prototype;\n proto = Object.getPrototypeOf(proto)\n) {\n Object.getOwnPropertyNames(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 if (prop in CustomVideoElement.prototype) return;\n\n const type = typeof nativeElTest[prop];\n if (type == 'function') {\n // Function\n CustomVideoElement.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(CustomVideoElement.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-video')) {\n globalThis.customElements.define('custom-video', CustomVideoElement);\n globalThis.CustomVideoElement = CustomVideoElement;\n}\n\nexport default CustomVideoElement;\n"],
5
+ "mappings": "unCAAA,kFAaO,kCCTP,GAAM,IAAsB,IAAM,CAChC,GAAI,CAEF,MAAO,8BACP,EACF,MAAO,WAGH,GAAyB,KAElB,GAAmB,IAAM,GCFtC,GAAM,IAAqB,AAAC,GAAY,CAZxC,kGAaE,sBAA4B,EAAW,CAkIrC,aAAc,CACZ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,KAAK,SAAU,GACnE,KAAK,iBAAmB,EAG1B,QAAS,CACP,eAAS,KAAK,SAAU,KAAK,OAC7B,KAAK,MAAQ,OAcf,yBAAyB,EAAkB,EAAyB,EAAyB,CAjW/F,MAkWI,OAAQ,OACD,GAAW,qBACd,KAAK,mBAAqB,UAAY,OACtC,UACG,GAAW,wBACd,KAAK,sBAAwB,UAAY,OACzC,UACG,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,GAAI,IAAa,EACf,MAGF,QAAK,mBAAL,kBAAwB,KAAK,UAC7B,UACG,GAAW,YAEd,KAAK,IAAM,oBAAc,UAAY,OAAW,CAAE,OAAQ,KAAK,eAC/D,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,WAUT,AAAK,WAAW,eAAe,IAAI,cACjC,YAAW,eAAe,OAAO,YAAa,IAE9C,WAAW,gBAAkB,IAK/B,GAAO,IAAQ",
6
+ "names": []
7
+ }
package/dist/index.mjs ADDED
@@ -0,0 +1,20 @@
1
+ var Mt=Object.defineProperty;var It=(n,t,s)=>t in n?Mt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[t]=s;var F=(n,t,s)=>(It(n,typeof t!="symbol"?t+"":t,s),s),et=(n,t,s)=>{if(!t.has(n))throw TypeError("Cannot "+s)};var r=(n,t,s)=>(et(n,t,"read from private field"),s?s.call(n):t.get(n)),c=(n,t,s)=>{if(t.has(n))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(n):t.set(n,s)},E=(n,t,s,i)=>(et(n,t,"write to private field"),i?i.call(n,s):t.set(n,s),s);var h=(n,t,s)=>(et(n,t,"access private method"),s);import{initialize as Ft,setupAutoplay as Gt,generatePlayerInitTime as Bt,toMuxVideoURL as Ht,teardown as jt,MediaError as ce,getError as Kt}from"@mux/playback-core";var Ot=()=>{try{return"0.7.1-canary.0-556dabf"}catch{}return"UNKNOWN"},Dt=Ot(),ft=()=>Dt;var Rt=n=>{var t,s,i,d,m,kt,_,st,A,S,w,rt,L,at,q,wt,W,Lt,N,yt,x,y,v,P,C,M,I,Z,$,Nt,U,Tt,z,xt,Y,At,J,Ut,V,gt;return t=class extends n{constructor(){super();c(this,I);c(this,$);c(this,U);c(this,z);c(this,Y);c(this,J);c(this,V);F(this,"castEnabled",!1);c(this,x,{paused:!1});c(this,y,void 0);c(this,v,{});c(this,P,void 0);c(this,C,void 0);c(this,M,void 0);t.instances.add(this),h(this,Y,At).call(this)}static get castElement(){return r(t,s)}static get castEnabled(){return r(t,i)}static get castState(){var e;return(e=r(t,A,S))==null?void 0:e.getCastState()}static async exitCast(){let e=!0;try{await r(t,A,S).endCurrentSession(e)}catch(a){console.error(a);return}}get castPlayer(){if(t.castElement===this)return r(this,y)}attributeChangedCallback(e){if(!!this.castPlayer)switch(e){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(e={}){var a;h(a=t,N,yt).call(a,e),E(t,s,this),Object.entries(r(this,v)).forEach(([u,p])=>{r(this,y).controller.addEventListener(u,p)});try{await r(t,A,S).requestSession()}catch{E(t,s,void 0);return}r(this,x).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(u){console.error(u)}}async load(){var b,O;if(!this.castPlayer)return super.load();let e=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),a=[...this.querySelectorAll("track")].filter(({kind:g,src:T})=>T&&(g==="subtitles"||g==="captions")),u=[],p=0;a.length&&(e.tracks=a.map(g=>{let T=++p;u.length===0&&g.track.mode==="showing"&&u.push(T);let D=new chrome.cast.media.Track(T,chrome.cast.media.TrackType.TEXT);return D.trackContentId=g.src,D.trackContentType="text/vtt",D.subtype=g.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,D.name=g.label,D.language=g.srclang,D})),this.castStreamType==="live"?e.streamType=chrome.cast.media.StreamType.LIVE:e.streamType=chrome.cast.media.StreamType.BUFFERED,e.metadata=new chrome.cast.media.GenericMediaMetadata,e.metadata.title=this.title,e.metadata.images=[{url:this.poster}];let f=new chrome.cast.media.LoadRequest(e);f.currentTime=(b=super.currentTime)!=null?b:0,f.autoplay=!r(this,x).paused,f.activeTrackIds=u,await((O=r(t,w,rt))==null?void 0:O.loadMedia(f)),this.dispatchEvent(new Event("volumechange"))}play(){var e;if(this.castPlayer){this.castPlayer.isPaused&&((e=this.castPlayer.controller)==null||e.playOrPause());return}return super.play()}pause(){var e;if(this.castPlayer){this.castPlayer.isPaused||(e=this.castPlayer.controller)==null||e.playOrPause();return}super.pause()}get castSrc(){var e,a,u;return(u=(a=this.getAttribute("cast-src"))!=null?a:(e=this.querySelector("source"))==null?void 0:e.src)!=null?u:this.currentSrc}set castSrc(e){this.castSrc!=e&&this.setAttribute("cast-src",`${e}`)}get castContentType(){var e;return(e=this.getAttribute("cast-content-type"))!=null?e:void 0}set castContentType(e){this.setAttribute("cast-content-type",`${e}`)}get castStreamType(){var e;return(e=this.getAttribute("cast-stream-type"))!=null?e:void 0}set castStreamType(e){this.setAttribute("cast-stream-type",`${e}`)}get readyState(){if(this.castPlayer)switch(this.castPlayer.playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return this.castPlayer?this.castPlayer.isPaused:super.paused}get muted(){var e;return this.castPlayer?(e=this.castPlayer)==null?void 0:e.isMuted:super.muted}set muted(e){var a;if(this.castPlayer){(e&&!this.castPlayer.isMuted||!e&&this.castPlayer.isMuted)&&((a=this.castPlayer.controller)==null||a.muteOrUnmute());return}super.muted=e}get volume(){var e,a;return this.castPlayer?(a=(e=this.castPlayer)==null?void 0:e.volumeLevel)!=null?a:1:super.volume}set volume(e){var a;if(this.castPlayer){this.castPlayer.volumeLevel=e,(a=this.castPlayer.controller)==null||a.setVolumeLevel();return}super.volume=e}get duration(){var e,a;return this.castPlayer&&r(this,I,Z)?(a=(e=this.castPlayer)==null?void 0:e.duration)!=null?a:NaN:super.duration}get currentTime(){var e,a;return this.castPlayer&&r(this,I,Z)?(a=(e=this.castPlayer)==null?void 0:e.currentTime)!=null?a:0:super.currentTime}set currentTime(e){var a;if(this.castPlayer){this.castPlayer.currentTime=e,(a=this.castPlayer.controller)==null||a.seek();return}super.currentTime=e}get onentercast(){return r(this,P)}set onentercast(e){r(this,P)&&(this.removeEventListener("entercast",r(this,P)),E(this,P,null)),typeof e=="function"&&(E(this,P,e),this.addEventListener("entercast",e))}get onleavecast(){return r(this,C)}set onleavecast(e){r(this,C)&&(this.removeEventListener("leavecast",r(this,C)),E(this,C,null)),typeof e=="function"&&(E(this,C,e),this.addEventListener("leavecast",e))}get oncastchange(){return r(this,M)}set oncastchange(e){r(this,M)&&(this.removeEventListener("castchange",r(this,M)),E(this,M,null)),typeof e=="function"&&(E(this,M,e),this.addEventListener("castchange",e))}},s=new WeakMap,i=new WeakMap,d=new WeakMap,m=new WeakSet,kt=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},_=new WeakSet,st=function(){return typeof cast!="undefined"&&cast.framework},A=new WeakSet,S=function(){if(r(t,_,st))return cast.framework.CastContext.getInstance()},w=new WeakSet,rt=function(){var e;return(e=r(t,A,S))==null?void 0:e.getCurrentSession()},L=new WeakSet,at=function(){var e;return(e=r(t,w,rt))==null?void 0:e.getSessionObj().media[0]},q=new WeakSet,wt=function(e){return new Promise((a,u)=>{r(t,L,at).editTracksInfo(e,a,u)})},W=new WeakSet,Lt=function(e){return new Promise((a,u)=>{r(t,L,at).getStatus(e,a,u)})},N=new WeakSet,yt=function(e){return r(t,A,S).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...e})},x=new WeakMap,y=new WeakMap,v=new WeakMap,P=new WeakMap,C=new WeakMap,M=new WeakMap,I=new WeakSet,Z=function(){var e;return(e=this.castPlayer)==null?void 0:e.isMediaLoaded},$=new WeakSet,Nt=function(){r(t,s)===this&&(Object.entries(r(this,v)).forEach(([e,a])=>{r(this,y).controller.removeEventListener(e,a)}),E(t,s,void 0),this.muted=r(this,y).isMuted,this.currentTime=r(this,y).savedPlayerState.currentTime,r(this,y).savedPlayerState.isPaused===!1&&this.play())},U=new WeakSet,Tt=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:r(t,A,S).getCastState()}))},z=new WeakSet,xt=async function(){var a,u;let{SESSION_RESUMED:e}=cast.framework.SessionState;if(r(t,A,S).getSessionState()===e&&this.castSrc===((a=r(t,L,at))==null?void 0:a.media.contentId)){E(t,s,this),Object.entries(r(this,v)).forEach(([p,f])=>{r(this,y).controller.addEventListener(p,f)});try{await h(u=t,W,Lt).call(u,new chrome.cast.media.GetStatusRequest)}catch(p){console.error(p)}r(this,v)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),r(this,v)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},Y=new WeakSet,At=function(){var e;!r(t,_,st)||this.castEnabled||(this.castEnabled=!0,h(e=t,N,yt).call(e),this.textTracks.addEventListener("change",h(this,V,gt).bind(this)),h(this,U,Tt).call(this),E(this,y,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(r(this,y)),E(this,v,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:a})=>{a===!1&&h(this,$,Nt).call(this),this.dispatchEvent(new Event(a?"entercast":"leavecast"))},[cast.framework.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.dispatchEvent(new Event("durationchange"))},[cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{!r(this,I,Z)||this.dispatchEvent(new Event("timeupdate"))},[cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.dispatchEvent(new Event("resize"))},[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.dispatchEvent(new Event(this.paused?"pause":"play"))},[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var a,u;((a=this.castPlayer)==null?void 0:a.playerState)!==chrome.cast.media.PlayerState.PAUSED&&this.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(u=this.castPlayer)==null?void 0:u.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!r(this,I,Z)||(await Promise.resolve(),h(this,J,Ut).call(this))}}))},J=new WeakSet,Ut=function(){h(this,V,gt).call(this)},V=new WeakSet,gt=async function(){var ot,ct,ut,lt,dt,ht;if(!this.castPlayer)return;let a=((ct=(ot=r(this,y).mediaInfo)==null?void 0:ot.tracks)!=null?ct:[]).filter(({type:l})=>l===chrome.cast.media.TrackType.TEXT),u=[...this.textTracks].filter(({kind:l})=>l==="subtitles"||l==="captions"),p=a.map(({language:l,name:X,trackId:tt})=>{var Et;let{mode:mt}=(Et=u.find(pt=>pt.language===l&&pt.label===X))!=null?Et:{};return mt?{mode:mt,trackId:tt}:!1}).filter(Boolean),b=p.filter(({mode:l})=>l!=="showing").map(({trackId:l})=>l),O=p.find(({mode:l})=>l==="showing"),g=(dt=(lt=(ut=r(t,w,rt))==null?void 0:ut.getSessionObj().media[0])==null?void 0:lt.activeTrackIds)!=null?dt:[],T=g;if(g.length&&(T=T.filter(l=>!b.includes(l))),(O==null?void 0:O.trackId)&&(T=[...T,O.trackId]),T=[...new Set(T)],!((l,X)=>l.length===X.length&&l.every(tt=>X.includes(tt)))(g,T))try{let l=new chrome.cast.media.EditTracksInfoRequest(T);await h(ht=t,q,wt).call(ht,l)}catch(l){console.error(l)}},c(t,m),c(t,_),c(t,A),c(t,w),c(t,L),c(t,q),c(t,W),c(t,N),F(t,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),F(t,"instances",new Set),c(t,s,void 0),c(t,i,!1),F(t,"initCast",()=>{var e;r(t,m,kt)?r(t,_,st)?r(e=t,d).call(e,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var a;return r(a=t,d).call(a,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var a;return r(a=t,d).call(a,chrome.cast.isAvailable)})}}),c(t,d,e=>{if(e){E(t,i,!0);let{CAST_STATE_CHANGED:a}=cast.framework.CastContextEventType;r(t,A,S).addEventListener(a,p=>{t.instances.forEach(f=>{var b;return h(b=f,U,Tt).call(b,p)})});let{SESSION_STATE_CHANGED:u}=cast.framework.CastContextEventType;r(t,A,S).addEventListener(u,p=>{t.instances.forEach(f=>{var b;return h(b=f,z,xt).call(b,p)})}),t.instances.forEach(p=>{var f;return h(f=p,Y,At).call(f)})}}),t},it=Rt(HTMLVideoElement);customElements.get("castable-video")||(customElements.define("castable-video",it,{extends:"video"}),globalThis.CastableVideoElement=it);it.initCast();var bt=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","castchange","entercast","leavecast"],vt=document.createElement("template");vt.innerHTML=`
2
+ <style>
3
+ :host {
4
+ display: inline-block;
5
+ line-height: 0;
6
+ width: auto;
7
+ height: auto;
8
+ }
9
+
10
+ video {
11
+ max-width: 100%;
12
+ max-height: 100%;
13
+ min-width: 100%;
14
+ min-height: 100%;
15
+ }
16
+ </style>
17
+ <video is="castable-video" part="video" crossorigin></video>
18
+ <slot></slot>
19
+ `;var G,B,H,St,j,_t,R=class extends HTMLElement{constructor(){super();c(this,H);c(this,j);c(this,G,void 0);c(this,B,void 0);this.attachShadow({mode:"open"}),this.isConnected&&h(this,H,St).call(this)}static get observedAttributes(){let t=[],s=d=>d.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();Object.getOwnPropertyNames(this.prototype).forEach(d=>{let m=!1;try{typeof this.prototype[d]=="function"&&(m=!0)}catch{}!m&&d!==d.toUpperCase()&&t.push(d.toLowerCase(),s(d))});let i=Object.getPrototypeOf(this).observedAttributes;return i&&(t=t.concat(i)),t}attributeChangedCallback(t,s,i){!r(this,G)&&!this.isConnected&&(E(this,G,!0),h(this,H,St).call(this)),h(this,j,_t).call(this,t,s,i)}connectedCallback(){}};G=new WeakMap,B=new WeakMap,H=new WeakSet,St=function(){if(r(this,B))return;E(this,B,!0),this.shadowRoot.append(vt.content.cloneNode(!0)),this.nativeEl=this.shadowRoot.querySelector("video"),bt.forEach(s=>{this.nativeEl.addEventListener(s,i=>{this.dispatchEvent(new CustomEvent(i.type,{detail:i.detail}))})});let t=this.shadowRoot.querySelector("slot");t.addEventListener("slotchange",()=>{t.assignedElements().forEach(s=>{!["track","source"].includes(s.localName)||this.nativeEl.append(s)})}),Array.prototype.forEach.call(this.attributes,s=>{h(this,j,_t).call(this,s.name,null,s.value)}),this.nativeEl.defaultMuted&&(this.nativeEl.muted=!0)},j=new WeakSet,_t=function(t,s,i){let d=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),m=Vt(d,t),k=Object.getPrototypeOf(this.constructor).toString().indexOf("function HTMLElement")===0;m&&!k?typeof this[m]=="boolean"?i===null?this[m]=!1:this[m]=!0:this[m]=i:i===null?this.nativeEl.removeAttribute(t):["id","class"].indexOf(t)===-1&&this.nativeEl.setAttribute(t,i)};var Pt=[],Ct=document.createElement("video",{is:"castable-video"}),Yt=["webkitDisplayingFullscreen","webkitSupportsFullscreen"];for(let n=Object.getPrototypeOf(Ct);n&&n!==HTMLElement.prototype;n=Object.getPrototypeOf(n))Object.getOwnPropertyNames(n).forEach(t=>{Yt.indexOf(t)===-1&&Pt.push(t)});Pt.forEach(n=>{if(n in R.prototype)return;if(typeof Ct[n]=="function")R.prototype[n]=function(){return this.nativeEl[n].apply(this.nativeEl,arguments)};else{let s={get(){return this.nativeEl[n]}};n!==n.toUpperCase()&&(s.set=function(i){this.nativeEl[n]=i}),Object.defineProperty(R.prototype,n,s)}});function Vt(n,t){let s=null;return n.forEach(i=>{i.toLowerCase()==t.toLowerCase()&&(s=i)}),s}globalThis.customElements.get("custom-video")||(globalThis.customElements.define("custom-video",R),globalThis.CustomVideoElement=R);var nt=R;var o={ENV_KEY:"env-key",DEBUG:"debug",PLAYBACK_ID:"playback-id",METADATA_URL:"metadata-url",PREFER_MSE:"prefer-mse",PLAYER_SOFTWARE_VERSION:"player-software-version",PLAYER_SOFTWARE_NAME:"player-software-name",METADATA_VIDEO_ID:"metadata-video-id",METADATA_VIDEO_TITLE:"metadata-video-title",METADATA_VIEWER_USER_ID:"metadata-viewer-user-id",BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",TYPE:"type",STREAM_TYPE:"stream-type",START_TIME:"start-time"},qt=Object.values(o),Wt=ft(),$t="mux-video",Q=class extends nt{constructor(){super();this.__metadata={};this.__playerInitTime=Bt()}static get observedAttributes(){var t;return[...qt,...(t=nt.observedAttributes)!=null?t:[]]}get playerInitTime(){return this.__playerInitTime}get playerSoftwareName(){var t;return(t=this.__playerSoftwareName)!=null?t:$t}set playerSoftwareName(t){this.__playerSoftwareName=t}get playerSoftwareVersion(){var t;return(t=this.__playerSoftwareVersion)!=null?t:Wt}set playerSoftwareVersion(t){this.__playerSoftwareVersion=t}get hls(){return console.warn("<mux-video>.hls is deprecated, please use ._hls instead"),this._hls}get _hls(){return this.__hls}get mux(){return this.nativeEl.mux}get error(){var t;return(t=Kt(this.nativeEl))!=null?t:null}get errorTranslator(){return this.__errorTranslator}set errorTranslator(t){this.__errorTranslator=t}get src(){return this.getAttribute("src")}set src(t){t!==this.src&&(t==null?this.removeAttribute("src"):this.setAttribute("src",t))}get type(){var t;return(t=this.getAttribute(o.TYPE))!=null?t:void 0}set type(t){t!==this.type&&(t?this.setAttribute(o.TYPE,t):this.removeAttribute(o.TYPE))}get autoplay(){let t=this.getAttribute("autoplay");return t===null?!1:t===""?!0:t}set autoplay(t){let s=this.autoplay;t!==s&&(t?this.setAttribute("autoplay",typeof t=="string"?t:""):this.removeAttribute("autoplay"))}get debug(){return this.getAttribute(o.DEBUG)!=null}set debug(t){t!==this.debug&&(t?this.setAttribute(o.DEBUG,""):this.removeAttribute(o.DEBUG))}get startTime(){let t=this.getAttribute(o.START_TIME);if(t==null)return;let s=+t;return Number.isNaN(s)?void 0:s}set startTime(t){t!==this.startTime&&(t==null?this.removeAttribute(o.START_TIME):this.setAttribute(o.START_TIME,`${t}`))}get playbackId(){var t;return(t=this.getAttribute(o.PLAYBACK_ID))!=null?t:void 0}set playbackId(t){t!==this.playbackId&&(t?this.setAttribute(o.PLAYBACK_ID,t):this.removeAttribute(o.PLAYBACK_ID))}get customDomain(){var t;return(t=this.getAttribute(o.CUSTOM_DOMAIN))!=null?t:void 0}set customDomain(t){t!==this.customDomain&&(t?this.setAttribute(o.CUSTOM_DOMAIN,t):this.removeAttribute(o.CUSTOM_DOMAIN))}get envKey(){var t;return(t=this.getAttribute(o.ENV_KEY))!=null?t:void 0}set envKey(t){t!==this.envKey&&(t?this.setAttribute(o.ENV_KEY,t):this.removeAttribute(o.ENV_KEY))}get beaconCollectionDomain(){var t;return(t=this.getAttribute(o.BEACON_COLLECTION_DOMAIN))!=null?t:void 0}set beaconCollectionDomain(t){t!==this.beaconCollectionDomain&&(t?this.setAttribute(o.BEACON_COLLECTION_DOMAIN,t):this.removeAttribute(o.BEACON_COLLECTION_DOMAIN))}get streamType(){var t;return(t=this.getAttribute(o.STREAM_TYPE))!=null?t:void 0}set streamType(t){t!==this.streamType&&(t?this.setAttribute(o.STREAM_TYPE,t):this.removeAttribute(o.STREAM_TYPE))}get preferMse(){return this.getAttribute(o.PREFER_MSE)!=null}set preferMse(t){t?this.setAttribute(o.PREFER_MSE,""):this.removeAttribute(o.PREFER_MSE)}get metadata(){let t=this.getAttribute(o.METADATA_VIDEO_ID),s=this.getAttribute(o.METADATA_VIDEO_TITLE),i=this.getAttribute(o.METADATA_VIEWER_USER_ID);return{...this.__metadata,...t!=null?{video_id:t}:{},...s!=null?{video_title:s}:{},...i!=null?{viewer_user_id:i}:{}}}set metadata(t){this.__metadata=t!=null?t:{},this.mux&&this.mux.emit("hb",this.__metadata)}load(){let t=Ft(this,this.nativeEl,this.__hls);this.__hls=t;let s=Gt(this.nativeEl,this.autoplay,t);this.__updateAutoplay=s}unload(){jt(this.nativeEl,this.__hls),this.__hls=void 0}attributeChangedCallback(t,s,i){var d;switch(t){case o.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=i!=null?i:void 0;break;case o.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=i!=null?i:void 0;break;case"src":let m=!!s,k=!!i;!m&&k?this.load():m&&!k?this.unload():m&&k&&(this.unload(),this.load());break;case"autoplay":if(i===s)break;(d=this.__updateAutoplay)==null||d.call(this,this.autoplay);break;case o.PLAYBACK_ID:this.src=Ht(i!=null?i:void 0,{domain:this.customDomain});break;case o.DEBUG:let _=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=_);break;case o.METADATA_URL:i&&fetch(i).then(K=>K.json()).then(K=>this.metadata=K).catch(K=>console.error(`Unable to load or parse metadata JSON from metadata-url ${i}!`));break;default:break}super.attributeChangedCallback(t,s,i)}disconnectedCallback(){this.unload()}};globalThis.customElements.get("mux-video")||(globalThis.customElements.define("mux-video",Q),globalThis.MuxVideoElement=Q);var de=Q;export{ce as MediaError,bt as VideoEvents,de as default};
20
+ //# sourceMappingURL=index.mjs.map