@mux/playback-core 0.35.0 → 0.35.1-canary.1

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.
@@ -0,0 +1,1020 @@
1
+ declare module 'mux-embed' {
2
+ type OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R ? (...args: P) => R : never;
3
+ type GenericObject = {
4
+ [k: string | number | symbol]: any;
5
+ };
6
+ type Hls = GenericObject;
7
+ type hlsjs = GenericObject;
8
+ type dashjs = GenericObject;
9
+ export type Metadata = {
10
+ /**
11
+ * Your environment key from the Mux dashboard.
12
+ */
13
+ env_key?: string;
14
+ /**
15
+ * @deprecated in favor of env_key
16
+ */
17
+ property_key?: string;
18
+ /**
19
+ * The URL for the ad asset
20
+ */
21
+ ad_asset_url?: string;
22
+ /**
23
+ * The Ad ID assigned by the customer
24
+ */
25
+ ad_creative_id?: string;
26
+ /**
27
+ * ID of the ad in the Ad Provider’s system
28
+ */
29
+ ad_id?: string;
30
+ /**
31
+ * The cumulative playing time of the ad in milliseconds. This includes all wall-clock time where ads are playing. It does not include time when ads are loading, when ads are paused, or any time between ads in a pod
32
+ */
33
+ ad_playing_time_ms_cumulative?: number;
34
+ /**
35
+ * The URL for the Ad tag
36
+ */
37
+ ad_tag_url?: string;
38
+ /**
39
+ * The Universal ID for the ad
40
+ */
41
+ ad_universal_id?: string;
42
+ /**
43
+ * The type of ad
44
+ */
45
+ ad_type?: AdType;
46
+ /**
47
+ * Browser used for the video view (Safari, Chrome, etc.) NB: `(viewer_application_name)`
48
+ */
49
+ browser?: string;
50
+ /**
51
+ * Browser version (e.g. Chrome 66.0.3359.158) NB: `(viewer_application_version)`
52
+ */
53
+ browser_version?: string;
54
+ /**
55
+ * Custom metadata field 1
56
+ */
57
+ custom_1?: string;
58
+ /**
59
+ * Custom metadata field 2
60
+ */
61
+ custom_2?: string;
62
+ /**
63
+ * Custom metadata field 3
64
+ */
65
+ custom_3?: string;
66
+ /**
67
+ * Custom metadata field 4
68
+ */
69
+ custom_4?: string;
70
+ /**
71
+ * Custom metadata field 5
72
+ */
73
+ custom_5?: string;
74
+ /**
75
+ * Custom metadata field 6
76
+ */
77
+ custom_6?: string;
78
+ /**
79
+ * Custom metadata field 7
80
+ */
81
+ custom_7?: string;
82
+ /**
83
+ * Custom metadata field 8
84
+ */
85
+ custom_8?: string;
86
+ /**
87
+ * Custom metadata field 9
88
+ */
89
+ custom_9?: string;
90
+ /**
91
+ * Custom metadata field 10
92
+ */
93
+ custom_10?: string;
94
+ /**
95
+ * Custom metadata field 11
96
+ */
97
+ custom_11?: string;
98
+ /**
99
+ * Custom metadata field 12
100
+ */
101
+ custom_12?: string;
102
+ /**
103
+ * Custom metadata field 13
104
+ */
105
+ custom_13?: string;
106
+ /**
107
+ * Custom metadata field 14
108
+ */
109
+ custom_14?: string;
110
+ /**
111
+ * Custom metadata field 15
112
+ */
113
+ custom_15?: string;
114
+ /**
115
+ * Custom metadata field 16
116
+ */
117
+ custom_16?: string;
118
+ /**
119
+ * Custom metadata field 17
120
+ */
121
+ custom_17?: string;
122
+ /**
123
+ * Custom metadata field 18
124
+ */
125
+ custom_18?: string;
126
+ /**
127
+ * Custom metadata field 19
128
+ */
129
+ custom_19?: string;
130
+ /**
131
+ * Custom metadata field 20
132
+ */
133
+ custom_20?: string;
134
+ /**
135
+ * CDN delivering the video view (either determined by Mux (network metrics), or provided as video_cdn (Custom Metadata))
136
+ */
137
+ cdn?: string;
138
+ /**
139
+ * You can use this field to separate views into different experiments, if you would like to filter by this dimension later. This should be a string value, but your account is limited to a total of 10 unique experiment names, so be sure that this value is not generated dynamically or randomly.
140
+ */
141
+ experiment_name?: string;
142
+ /**
143
+ * Operating System (iOS, Windows, etc) NB: `(viewer_os_family)`
144
+ */
145
+ operating_system?: string;
146
+ /**
147
+ * Operating System version (e.g. OS X 10.6) NB: `(viewer_os_version)`
148
+ */
149
+ operating_system_version?: string;
150
+ /**
151
+ * Provide the context of the page for more specific analysis. Values include watchpage, iframe, or leave empty. watchpage — A web page that is dedicated to playing a specific video (for example youtube.com/watch/ID or hulu.com/watch/ID) iframe — An iframe specifically used to embed a player on different sites/pages
152
+ */
153
+ page_type?: string;
154
+ /**
155
+ * Page URL
156
+ */
157
+ page_url?: string;
158
+ /**
159
+ * A sub property is an optional way to group data within a property. For example, sub properties may be used by a video platform to group data by its own customers, or a media company might use them to distinguish between its many websites.
160
+ */
161
+ sub_property_id?: string;
162
+ /**
163
+ * If you are explicitly loading your page, (perhaps in a Single Page App), include the timestamp (milliseconds since Jan 1 1970) of when the page load started when you initialize the player (or for HTML5 video, when right before you add the element to the DOM) in order to accurately track page load time.
164
+ */
165
+ page_load_init_time?: number;
166
+ /**
167
+ * If you are explicitly loading your page, (perhaps in a Single Page App), include the timestamp (milliseconds since Jan 1 1970) of when the page load competed when you initialize the player (or for HTML5 video, when right before you add the element to the DOM) in order to accurately track page load time.
168
+ */
169
+ page_load_end_time?: number;
170
+ /**
171
+ * Indicates whether the player was set to autoplay the video or not. This tracks whether the video has `autoplay=true` set; it is not always able to tell if the browser disregarded the setting, otherwise prevented the video from playing, or if the video play was triggered via a script.
172
+ */
173
+ player_autoplay_on?: boolean;
174
+ /**
175
+ * Indicates whether the player is using captions.
176
+ */
177
+ player_captions_enabled?: boolean;
178
+ /**
179
+ * Height of the player as displayed in page, in pixels
180
+ */
181
+ player_height?: number;
182
+ /**
183
+ * Identifies the instance of the Player class that is created when a video is initialized
184
+ */
185
+ player_instance_id?: string;
186
+ /**
187
+ * If you are explicitly loading your player in page (perhaps as a response to a user interaction), include the timestamp (milliseconds since Jan 1 1970) when you initialize the player (or for HTML5 video, when right before you add the element to the DOM) in order to accurately track page load time and player startup time.
188
+ */
189
+ player_init_time?: number;
190
+ /**
191
+ * Indicates whether the player is paused. Corresponds with `paused=true` for the video.
192
+ */
193
+ player_is_paused?: boolean;
194
+ /**
195
+ * Indicates whether the player is fullscreen.
196
+ */
197
+ player_is_fullscreen?: boolean;
198
+ /**
199
+ * Player's text language
200
+ */
201
+ player_language_code?: string;
202
+ /**
203
+ * You can provide a name for the player if you want to compare different configurations or types of players around your site or application. This is different from the player software (e.g. Video.js), which is tracked automatically by the SDK.
204
+ */
205
+ player_name?: string;
206
+ /**
207
+ * Indicates whether the player is using picture-in-picture mode.
208
+ */
209
+ player_pip_enabled?: boolean;
210
+ /**
211
+ * The current playback mode of the player (e.g., 'standard', 'picture-in-picture', 'fullscreen', etc.)
212
+ */
213
+ player_playback_mode?: string;
214
+ /**
215
+ * Additional metadata associated with the playback mode as a JSON-stringified object
216
+ */
217
+ player_playback_mode_data?: string;
218
+ /**
219
+ * Specifies the playhead position in milliseconds
220
+ */
221
+ player_playhead_time?: number;
222
+ /**
223
+ * Specifies if the player was configured to load the video when the page loads.
224
+ */
225
+ player_preload_on?: boolean;
226
+ /**
227
+ * If the video is remote played to AirPlay as specified by the SDK.
228
+ */
229
+ player_remote_played?: boolean;
230
+ /**
231
+ * Player Software being used to play the Video (e.g. Video.js, JW Player, etc.)
232
+ */
233
+ player_software?: string;
234
+ /**
235
+ * Player Software being used to play the Video (e.g. Video.js, JW Player, etc.) (currently potentially redundant with player_software, above)
236
+ */
237
+ player_software_name?: string;
238
+ /**
239
+ * Player Software Version (e.g. 2.45.5)
240
+ */
241
+ player_software_version?: string;
242
+ /**
243
+ * As you make changes to your player you can compare how new versions of your player perform. This is not the player software version (e.g. Video.js 5.0.0), which is tracked automatically by the SDK.
244
+ */
245
+ player_version?: string;
246
+ /**
247
+ * Width of the player as displayed in page, in pixels
248
+ */
249
+ player_width?: number;
250
+ /**
251
+ * Format of the source, as determined by the player. E.g. 'dash', 'x-application/mpegUrl', 'mp4', etc.
252
+ */
253
+ video_source_mime_type?: string;
254
+ /**
255
+ * Your internal ID for the video
256
+ */
257
+ video_id?: string;
258
+ /**
259
+ * Affiliate that the viewer is watching or referred the viewer
260
+ */
261
+ video_affiliate?: string;
262
+ /**
263
+ * Codec of the audio that played.
264
+ */
265
+ video_audio_codec?: string;
266
+ /**
267
+ * The brand associated with the video or the brand of the streaming platform the viewer is using to watch the video.
268
+ */
269
+ video_brand?: string;
270
+ /**
271
+ * Codec of the video that played.
272
+ */
273
+ video_codec?: string;
274
+ /**
275
+ * The Content Delivery Network used to deliver the video. If using an SDK that supports CDN header extraction, this value will be auto-populated.
276
+ */
277
+ video_cdn?: string;
278
+ /**
279
+ * The type of content: 'short', 'movie', 'episode', 'clip', 'trailer', or 'event'
280
+ */
281
+ video_content_type?: string;
282
+ /**
283
+ * The length of the video in milliseconds
284
+ */
285
+ video_duration?: number;
286
+ /**
287
+ * The format or type of dynamic range available on the video that played
288
+ */
289
+ video_dynamic_range_type?: string;
290
+ /**
291
+ * Allows you to compare different encoders or encoding settings. This could designate the encoder used (e.g. `x264`, `hevc`, or `av1`), the preset used (e.g. 'av1-0', 'av1-4', or 'av1-8'), or other properties of the encoding you want to track.
292
+ */
293
+ video_encoding_variant?: string;
294
+ video_is_live?: boolean;
295
+ /**
296
+ * The audio language of the video, assuming it's unchangeable after playing.
297
+ */
298
+ video_language_code?: string;
299
+ /**
300
+ * The playback ranges of the video as a stringified array of start and end times when playback occurred
301
+ */
302
+ video_playback_range?: string;
303
+ /**
304
+ * The image shown as the pre-visualisation before play
305
+ */
306
+ video_poster_url?: string;
307
+ /**
308
+ * The producer of the video title
309
+ */
310
+ video_producer?: string;
311
+ /**
312
+ * The series of the video (e.g.: 'Season 1')
313
+ */
314
+ video_series?: string;
315
+ /**
316
+ * The type of video stream (e.g: 'live' or 'on-demand')
317
+ */
318
+ video_stream_type?: string;
319
+ video_source_bitrate?: number;
320
+ video_source_codec?: string;
321
+ video_source_rendition_name?: string;
322
+ video_source_duration?: number;
323
+ video_source_format?: string;
324
+ video_source_fps?: number;
325
+ /**
326
+ * Height of the source video being sent to the player, in pixels
327
+ */
328
+ video_source_height?: number;
329
+ video_source_is_live?: boolean;
330
+ video_source_url?: string;
331
+ /**
332
+ * Width of the source video being as seen by the player
333
+ */
334
+ video_source_width?: number;
335
+ /**
336
+ * Title of the video player (e.g.: 'Awesome Show: Pilot')
337
+ */
338
+ video_title?: string;
339
+ /**
340
+ * Allows you to monitor issues with the files of specific versions of the content, for example different audio translations or versions with hard-coded/burned-in subtitles.
341
+ */
342
+ video_variant_name?: string;
343
+ /**
344
+ * Your internal ID for a video variant
345
+ */
346
+ video_variant_id?: string;
347
+ /**
348
+ * View ID
349
+ */
350
+ view_id?: string;
351
+ /**
352
+ * CDN PoP/Edge Server information
353
+ */
354
+ view_cdn_edge_pop?: string;
355
+ /**
356
+ * CDN origin region
357
+ */
358
+ view_cdn_origin?: string;
359
+ /**
360
+ * Name of the customer's application that the viewer is using to watch the content
361
+ */
362
+ view_client_application_name?: string;
363
+ /**
364
+ * Version of the customer's application that the viewer is using to watch the content
365
+ */
366
+ view_client_application_version?: string;
367
+ /**
368
+ * Security level of the specific DRM type. Some DRM types do not have levels.
369
+ */
370
+ view_drm_level?: string;
371
+ /**
372
+ * Digital Rights Management type
373
+ */
374
+ view_drm_type?: string;
375
+ /**
376
+ * Frames dropped for the video
377
+ */
378
+ view_dropped_frame_count?: number;
379
+ /**
380
+ * An ID that can be used to correlate the view with platform services upstream such as CDN or origin logs.
381
+ */
382
+ view_session_id?: string;
383
+ /**
384
+ * Boolean value of whether a view contains advertisements
385
+ */
386
+ view_has_ad?: boolean;
387
+ /**
388
+ * Boolean indicating if this view had time_shift enabled
389
+ */
390
+ view_time_shift_enabled?: boolean;
391
+ /**
392
+ * The type of connection used by the player, as reported by the client when available: `cellular`, `other`, `wifi`, `wired`
393
+ */
394
+ viewer_connection_type?: string;
395
+ /**
396
+ * The form factor of the device: `tv`, `phone`, `tablet`, etc.
397
+ */
398
+ mux_viewer_device_category?: string;
399
+ /**
400
+ * Device Manufacturer (e.g. Apple, Microsoft)
401
+ */
402
+ mux_viewer_device_manufacturer?: string;
403
+ /**
404
+ * Device Name (e.g. iPhone)
405
+ */
406
+ mux_viewer_device_name?: string;
407
+ /**
408
+ * Device model (e.g. iPhone 16,2)
409
+ */
410
+ mux_viewer_device_model?: string;
411
+ /**
412
+ * Name of the viewer's customer-specific subscription plan
413
+ */
414
+ viewer_plan?: string;
415
+ /**
416
+ * Category of the viewer's customer-specific subscription plan
417
+ */
418
+ viewer_plan_category?: string;
419
+ /**
420
+ * Tier of the viewer's customer-specific subscription plan
421
+ */
422
+ viewer_plan_status?: string;
423
+ /**
424
+ * The cumulative playing time of the video in milliseconds. This metric includes all wall-clock time where the player is playing. It does not include paused, rebuffering, seeking, or startup time. It does include time when ads are playing, and excludes time the ads are paused.
425
+ */
426
+ view_playing_time_ms_cumulative?: number;
427
+ /**
428
+ * An ID representing the viewer who is watching the stream. Use this to look up video views for an individual viewer. If no value is specified, a unique ID will be generated by the SDK. Note: You should not use any value that is personally identifiable on its own (such as email address, username, etc). Instead, you should supply an anonymized viewer ID which you have stored within your own system.
429
+ */
430
+ viewer_user_id?: string;
431
+ /**
432
+ * @deprecated - Use viewer_user_id
433
+ */
434
+ user_id?: string;
435
+ mux_sample_number?: number;
436
+ event?: string;
437
+ };
438
+ export type MuxEvents = {
439
+ DESTROY: 'destroy';
440
+ /**
441
+ * Internal event that is used to provide periodic updates on the playback state, while the player is not paused. Each core library emits heartbeat events (hb) automatically, and custom integrations should not need to emit this.
442
+ */
443
+ HEARTBEAT: 'hb';
444
+ /**
445
+ * Fired when the player is ready to be used.
446
+ */
447
+ PLAYER_READY: 'playerready';
448
+ /**
449
+ * Signals that the video being played in the player has changed. This must be called if a new video is loaded within the same player. The event should be fired immediately after the new video has been given to the player.
450
+ */
451
+ VIDEO_CHANGE: 'videochange';
452
+ /**
453
+ * For e.g. live linear channels, signals changes between content. Similar to `"videochange"`.
454
+ */
455
+ PROGRAM_CHANGE: 'programchange';
456
+ /**
457
+ * Signals that the player is beginning its attempt to play back the video. The video is not yet showing on the screen (or moving forward in the case of a resume). The buffer may be empty or full depending on the pre-loading strategy.
458
+ *
459
+ * For the HTML5 video element, this correlates to the play event on the video element.
460
+ *
461
+ * For ad playback, once resuming from the ad break, the `play` event should be fired immediately after the {@link MuxEvents.AD_BREAK_END `adbreakend`} event, assuming the player will continue playing content after the ad break without interaction from the viewer.
462
+ */
463
+ PLAY: 'play';
464
+ /**
465
+ * Signals that playback has been intentionally delayed, either by the viewer or by the player (e.g. starting an ad).
466
+ *
467
+ * For the HTML5 video element, this correlates to the pause event on the video element.
468
+ *
469
+ * In the case of playback breaking to play an ad, the `pause` event should be fired just before the {@link MuxEvents.AD_BREAK_START `adbreakstart`} event is fired.
470
+ */
471
+ PAUSE: 'pause';
472
+ /**
473
+ * Signals that the video is now actually playing. The buffer is full enough that the player has decided it can start showing frames. In other words, this is when the first moving frame is displayed to the end user.
474
+ *
475
+ * For the HTML5 video element, this correlates to the playing event on the video element.
476
+ */
477
+ PLAYING: 'playing';
478
+ /**
479
+ * Signals that the playback has advanced some non-zero amount forward. This event should be emitted at least every 250 milliseconds, but can be sent more often than this.
480
+ */
481
+ TIME_UPDATE: 'timeupdate';
482
+ /**
483
+ * Signals that the user has attempted to seek forward or backward within the timeline of the video.
484
+ */
485
+ SEEKING: 'seeking';
486
+ /**
487
+ * Signals that the player has the video data for the new playback position, and is ready to immediately start playing at this new position.
488
+ */
489
+ SEEKED: 'seeked';
490
+ /**
491
+ * Signals that the player has stopped playing back content when it is expected that playback should be progressing.
492
+ */
493
+ REBUFFER_START: 'rebufferstart';
494
+ /**
495
+ * Signals that the player has resumed playing back content after playback previous stalled while attempting to play back.
496
+ */
497
+ REBUFFER_END: 'rebufferend';
498
+ /**
499
+ * Signals that the player has encountered a fatal playback error. It is important that this is emitted only for errors that are fatal (i.e. not recoverable), as this will mark the view as a playback failure within Mux.
500
+ */
501
+ ERROR: 'error';
502
+ /**
503
+ * Signals that the current video has played to completion.
504
+ */
505
+ ENDED: 'ended';
506
+ /**
507
+ * Signals that the current rendition that is actively being played has changed. Note that this event should be triggered when the playing rendition changes, not necessarily when the player logic has started requesting a different rendition.
508
+ */
509
+ RENDITION_CHANGE: 'renditionchange';
510
+ /**
511
+ * Signals that a device orientation has been changed during the view. On most platforms this information is not available directly to the player SDK so the customer implementation will notify the Mux SDK when the orientation is changed and Mux will fire an event based on the notification.
512
+ */
513
+ ORIENTATION_CHANGE: 'orientationchange';
514
+ /**
515
+ * Signals that the playback mode has changed.
516
+ */
517
+ PLAYBACK_MODE_CHANGE: 'playbackmodechange';
518
+ /**
519
+ * Signals that an ad request is about to be made, or was just made but the response has not been received.
520
+ *
521
+ * In the process of the player retrieving an ad payload,
522
+ * multiple {@link MuxEvents.AD_REQUEST `adrequest`} and {@link MuxEvents.AD_RESPONSE `adresponse`} events may be fired (either due to waterfall,
523
+ * or for an ad break that has multiple ads). In the case that these requests are made in parallel,
524
+ * the player integration must send an `ad_request_id` in the data along with each {@link MuxEvents.AD_REQUEST `adrequest`} and {@link MuxEvents.AD_RESPONSE `adresponse`} event,
525
+ * so that Mux can match them up correctly.
526
+ */
527
+ AD_REQUEST: 'adrequest';
528
+ /**
529
+ * Signals that a response was received from the ad server.
530
+ *
531
+ * In the process of the player retrieving an ad payload,
532
+ * multiple {@link MuxEvents.AD_REQUEST `adrequest`} and {@link MuxEvents.AD_RESPONSE `adresponse`} events may be fired (either due to waterfall,
533
+ * or for an ad break that has multiple ads). In the case that these requests are made in parallel,
534
+ * the player integration must send an `ad_request_id` in the data along with each {@link MuxEvents.AD_REQUEST `adrequest`} and {@link MuxEvents.AD_RESPONSE `adresponse`} event,
535
+ * so that Mux can match them up correctly.
536
+ *
537
+ * The adresponse event can only be fired by the player integration if the adrequest events are fired as well.
538
+ */
539
+ AD_RESPONSE: 'adresponse';
540
+ /**
541
+ * Signals that an ad break has begun. This coincides with the playback of the video being paused in order to display the ads at the current position. This event should come immediately after the pause event is fired due to attempting to play back an ad break, and before any adplay, adplaying, adpause, or adended.
542
+ *
543
+ * The `adbreakstart` event may come before, during, or after the adrequest/adresponse events, depending on the player’s configuration for making ad requests.
544
+ */
545
+ AD_BREAK_START: 'adbreakstart';
546
+ /**
547
+ * Signals that the player is beginning its attempt to play back an individual advertisement video. The ad is not yet showing on the screen (or moving forward in the case of a resume). The buffer may be empty or full depending on the pre-loading strategy.
548
+ *
549
+ * This event is the ad-specific equivalent of play.
550
+ */
551
+ AD_PLAY: 'adplay';
552
+ /**
553
+ * Signals that an advertisement is now actually playing. The buffer is full enough that the player has decided it can start showing frames for the ad.
554
+ *
555
+ * This event is the ad-specific equivalent of playing.
556
+ */
557
+ AD_PLAYING: 'adplaying';
558
+ /**
559
+ * Signals that playback of an advertisement has been intentionally delayed, either by the viewer or by the player (e.g. user pressing pause on the ad player controls).
560
+ *
561
+ * This event is the ad-specific equivalent of pause.
562
+ */
563
+ AD_PAUSE: 'adpause';
564
+ /**
565
+ * Signals that the current advertisement has progressed past the first quartile in playback. This event should coincide with the point in time that the ad integration would fire the firstQuartile ad tracking beacon (in VAST terminology).
566
+ */
567
+ AD_FIRST_QUARTILE: 'adfirstquartile';
568
+ /**
569
+ * Signals that the current advertisement has progressed past the midpoint in playback. This event should coincide with the point in time that the ad integration would fire the midpoint ad tracking beacon (in VAST terminology).
570
+ */
571
+ AD_MID_POINT: 'admidpoint';
572
+ /**
573
+ * Signals that the current advertisement has progressed past the third quartile in playback. This event should coincide with the point in time that the ad integration would fire the thirdQuartile ad tracking beacon (in VAST terminology).
574
+ */
575
+ AD_THIRD_QUARTILE: 'adthirdquartile';
576
+ /**
577
+ * Signals that the advertisement has played to completion.
578
+ *
579
+ * This event is the ad-specific equivalent of ended.
580
+ */
581
+ AD_ENDED: 'adended';
582
+ /**
583
+ * Signals that all ads in the ad break have completed, and playback is about to resume on the main content. This event should be come immediately after the last adended event in the ad break, and before the resuming play event signifying that playback of the main content is resuming.
584
+ *
585
+ * There may be multiple adplay/adended combinations within a single ad break.
586
+ */
587
+ AD_BREAK_END: 'adbreakend';
588
+ /**
589
+ * Signals that an error has occurred that relates to the ad break currently in play or the ad request/response.
590
+ */
591
+ AD_ERROR: 'aderror';
592
+ /**
593
+ * Signals that a network request for a piece of content returned successfully.
594
+ */
595
+ REQUEST_COMPLETED: 'requestcompleted';
596
+ /**
597
+ * Signals that a network request for a piece of content returned unsuccessfully.
598
+ */
599
+ REQUEST_FAILED: 'requestfailed';
600
+ /**
601
+ * Signals that a network request for a piece of content was aborted before it could return (either successfully or unsuccessfully).
602
+ */
603
+ REQUEST_CANCELLED: 'requestcanceled';
604
+ FRAGMENT_CHANGE: 'fragmentchange';
605
+ LOADSTART: 'loadstart';
606
+ RATECHANGE: 'ratechange';
607
+ STALLED: 'stalled';
608
+ WAITING: 'waiting';
609
+ };
610
+ export type MuxEventsInternal = MuxEvents & {
611
+ VIEWEND: 'viewend';
612
+ VIEWSTART: 'viewstart';
613
+ /**
614
+ * Signals that a new view is beginning and should be recorded. This must be called first before any additional playback events. Note that this should only be emitted for the first view within a player; for a change of videos within the same player, {@link MuxEvents.VIDEO_CHANGE `videochange`} should be used.
615
+ */
616
+ VIEW_INIT: 'viewinit';
617
+ };
618
+ export type MuxEvent = MuxEvents[keyof MuxEvents];
619
+ export type MuxEventInternal = MuxEventsInternal[keyof MuxEventsInternal];
620
+ export type HlsOptions = {
621
+ hlsjs: hlsjs;
622
+ Hls?: Hls;
623
+ };
624
+ export type DashOptions = {
625
+ dashjs: dashjs;
626
+ };
627
+ export type Options = Partial<HlsOptions & DashOptions> & {
628
+ /**
629
+ * Controls whether debug log statements are logged to the console
630
+ */
631
+ debug?: boolean;
632
+ data?: Metadata;
633
+ disableCookies?: boolean;
634
+ /**
635
+ * Respect 'Do Not Track' when set within browsers.
636
+ */
637
+ respectDoNotTrack?: boolean;
638
+ /**
639
+ * In the case that you want full control over what errors are counted as fatal or not, you may want to consider turning off Mux's automatic error tracking completely. This can be done by passing `automaticErrorTracking: false` in the configuration object.
640
+ */
641
+ automaticErrorTracking?: boolean;
642
+ /**
643
+ * If your player emits error events that are not fatal to playback or the errors are unclear and/or do not have helpful information in the default error message and codes you might find it helpful to use an error translator or disable automatic error tracking all together.
644
+ */
645
+ errorTranslator?: (error: ErrorEvent) => ErrorEvent | boolean;
646
+ /**
647
+ * @private *For internal use only.*
648
+ * If the events emitted by the the default monitors needs filtering (by yielding an empty array or a nullish value) or transformation (by yielding a different event type or data) you might find it helpful to use an emit translator.
649
+ */
650
+ emitTranslator?: (...args: any[]) => [
651
+ any
652
+ ] | [
653
+ any,
654
+ any
655
+ ] | null | undefined;
656
+ /**
657
+ * @private *For internal use only.*
658
+ * Callback for playhead position
659
+ */
660
+ getPlayheadTime?: () => number | undefined;
661
+ /**
662
+ * @private *For internal use only.*
663
+ * Callback for player state
664
+ */
665
+ getStateData?: () => Partial<Metadata> | undefined;
666
+ /**
667
+ * @private *For internal use only.*
668
+ * Callback to optionally augment/modify state data returned from getStateData()
669
+ */
670
+ stateDataTranslator?: (stateData: ReturnType<NonNullable<Options['getStateData']>>) => ReturnType<NonNullable<Options['getStateData']>>;
671
+ /**
672
+ *
673
+ */
674
+ getAdData?: any;
675
+ /**
676
+ *
677
+ */
678
+ minimumRebufferDuration?: number;
679
+ /**
680
+ *
681
+ */
682
+ sustainedRebufferThreshold?: number;
683
+ /**
684
+ *
685
+ */
686
+ playbackHeartbeatTime?: number;
687
+ /**
688
+ *
689
+ */
690
+ disableRebufferTracking?: boolean;
691
+ /**
692
+ *
693
+ */
694
+ disablePlayheadRebufferTracking?: boolean;
695
+ /**
696
+ * Disables filtering of backward playhead jumps during ad breaks. By default, the SDK
697
+ * ignores backward playhead jumps during ads to handle CSAI scenarios where the ad
698
+ * playhead loops (e.g., 0→5s, 0→5s for each ad). Set this to true to disable that
699
+ * filtering and track all playhead changes during ads.
700
+ */
701
+ disableAdPlaybackRangeFiltering?: boolean;
702
+ /**
703
+ *
704
+ */
705
+ sampleRate?: number;
706
+ /**
707
+ *
708
+ */
709
+ beaconCollectionDomain?: string;
710
+ /**
711
+ * If you are explicitly loading your page, (perhaps in a Single Page App), include the timestamp (milliseconds since Jan 1 1970) of when the page load started when you initialize the player (or for HTML5 video, when right before you add the element to the DOM) in order to accurately track page load time.
712
+ */
713
+ pageLoadInitTime?: number;
714
+ /**
715
+ * If you are explicitly loading your page, (perhaps in a Single Page App), include the timestamp (milliseconds since Jan 1 1970) of when the page load competed when you initialize the player (or for HTML5 video, when right before you add the element to the DOM) in order to accurately track page load time.
716
+ */
717
+ pageLoadEndTime?: number;
718
+ /**
719
+ * @deprecated Use `beaconCollectionDomain`
720
+ */
721
+ beaconDomain?: string;
722
+ platform?: {
723
+ name?: string;
724
+ version?: string;
725
+ layout?: string;
726
+ product?: string;
727
+ manufacturer?: string;
728
+ os?: {
729
+ family?: string;
730
+ architecture?: string;
731
+ version?: string;
732
+ };
733
+ };
734
+ };
735
+ export type AdType = 'preroll' | 'midroll' | 'postroll';
736
+ export type AdEvent = {
737
+ ad_request_id?: string;
738
+ ad_tag_url?: string;
739
+ ad_asset_url?: string;
740
+ ad_creative_id?: string;
741
+ ad_id?: string;
742
+ ad_universal_id?: string;
743
+ ad_type?: AdType;
744
+ };
745
+ export type ErrorSeverity = {
746
+ fatal: 'fatal';
747
+ warning: 'warning';
748
+ };
749
+ export type ErrorEvent = {
750
+ player_error_code?: number;
751
+ player_error_message?: string;
752
+ player_error_context?: string;
753
+ player_error_severity?: keyof ErrorSeverity;
754
+ player_error_business_exception?: boolean;
755
+ };
756
+ export type TimeUpdateEvent = Partial<Pick<Metadata, 'player_playhead_time'>>;
757
+ export type FragmentChangeEvent = {
758
+ currentFragmentPDT: number;
759
+ currentFragmentStart: number;
760
+ };
761
+ export type RenditionChangeEvent = Partial<Pick<Metadata, 'video_source_width' | 'video_source_height' | 'video_source_bitrate' | 'video_source_fps' | 'video_source_codec' | 'video_source_rendition_name'>>;
762
+ export type OrientationChangeEvent = {
763
+ viewer_device_orientation: [
764
+ number,
765
+ number,
766
+ number
767
+ ];
768
+ };
769
+ export type RequestCompletedEvent = {
770
+ request_event_type?: string;
771
+ request_bytes_loaded?: number;
772
+ request_current_level?: string;
773
+ request_hostname?: string;
774
+ request_id?: string;
775
+ request_labeled_bitrate?: number;
776
+ request_media_duration?: number;
777
+ request_rendition_lists?: any;
778
+ request_response_end?: number;
779
+ request_response_headers?: Headers;
780
+ request_response_start?: number;
781
+ request_start?: number;
782
+ request_type?: string;
783
+ request_video_width?: number;
784
+ request_video_height?: number;
785
+ player_manifest_newest_program_time?: number;
786
+ video_holdback?: number;
787
+ video_part_holdback?: number;
788
+ video_part_target_duration?: number;
789
+ video_target_duration?: number;
790
+ video_source_is_live?: boolean;
791
+ };
792
+ export type RequestFailedEvent = {
793
+ request_error: string;
794
+ request_error_code: number;
795
+ request_error_text: string;
796
+ request_id?: string;
797
+ };
798
+ export type NetworkEvent = {
799
+ request_type?: 'manifest' | 'video' | 'audio' | 'video_init' | 'audio_init' | 'media' | 'subtitle' | 'encryption';
800
+ request_start?: number;
801
+ request_hostname?: string;
802
+ request_event_type?: string;
803
+ request_url?: string;
804
+ request_id?: string;
805
+ };
806
+ export type PlaybackModeChangeEvent = {
807
+ player_playback_mode: string;
808
+ player_playback_mode_data: string;
809
+ };
810
+ export type EventParamsMap = {
811
+ /** @TODO As a followup, implement a metadatachange event for this use case and make this payload `void` (CJP) */
812
+ [events.HEARTBEAT]: Partial<Metadata>;
813
+ [events.VIDEO_CHANGE]: Partial<Metadata>;
814
+ [events.PROGRAM_CHANGE]: Partial<Metadata>;
815
+ [events.PLAY]: void;
816
+ [events.PAUSE]: void;
817
+ [events.PLAYING]: void;
818
+ [events.SEEKING]: void;
819
+ [events.SEEKED]: void;
820
+ [events.REBUFFER_START]: void;
821
+ [events.REBUFFER_END]: void;
822
+ [events.ERROR]: ErrorEvent;
823
+ [events.ENDED]: void;
824
+ [events.RENDITION_CHANGE]: RenditionChangeEvent;
825
+ [events.ORIENTATION_CHANGE]: OrientationChangeEvent;
826
+ [events.PLAYBACK_MODE_CHANGE]: PlaybackModeChangeEvent;
827
+ [events.AD_REQUEST]: AdEvent;
828
+ [events.AD_RESPONSE]: AdEvent;
829
+ [events.AD_BREAK_START]: AdEvent;
830
+ [events.AD_PLAY]: AdEvent;
831
+ [events.AD_PLAYING]: AdEvent;
832
+ [events.AD_PAUSE]: AdEvent;
833
+ [events.AD_FIRST_QUARTILE]: AdEvent;
834
+ [events.AD_MID_POINT]: AdEvent;
835
+ [events.AD_THIRD_QUARTILE]: AdEvent;
836
+ [events.AD_ENDED]: AdEvent;
837
+ [events.AD_BREAK_END]: AdEvent;
838
+ [events.AD_ERROR]: AdEvent;
839
+ [events.REQUEST_COMPLETED]: RequestCompletedEvent & NetworkEvent;
840
+ [events.REQUEST_FAILED]: RequestFailedEvent & NetworkEvent;
841
+ [events.REQUEST_CANCELLED]: NetworkEvent;
842
+ [events.TIME_UPDATE]: TimeUpdateEvent;
843
+ [events.DESTROY]: void;
844
+ [events.PLAYER_READY]: void;
845
+ [events.FRAGMENT_CHANGE]: FragmentChangeEvent;
846
+ [events.LOADSTART]: void;
847
+ [events.RATECHANGE]: void;
848
+ [events.STALLED]: void;
849
+ [events.WAITING]: void;
850
+ };
851
+ export type EventParamsMapInternal = EventParamsMap & {
852
+ [eventsInternal.VIEWEND]: Partial<Metadata>;
853
+ [eventsInternal.VIEWSTART]: Partial<Metadata>;
854
+ [eventsInternal.VIEW_INIT]: Partial<Metadata>;
855
+ };
856
+ export type PlayerId = string | HTMLMediaElement;
857
+ /**
858
+ * Monitor a video element
859
+ */
860
+ function monitor(id: PlayerId, options?: Options): void;
861
+ /**
862
+ * Create a new generic player monitor
863
+ */
864
+ function init(id: PlayerId, options?: Options): void;
865
+ /**
866
+ * Stop monitoring a normal video element
867
+ */
868
+ function destroyMonitor(playerId: PlayerId): void;
869
+ function addHLSJS(playerId: PlayerId, options: HlsOptions): void;
870
+ function addDashJS(playerId: PlayerId, options: DashOptions): void;
871
+ function removeHLSJS(playerId: PlayerId): void;
872
+ function removeDashJS(playerId: PlayerId): void;
873
+ function checkDoNotTrack(): boolean;
874
+ function updateData(playerId: PlayerId, data: Partial<Metadata>): void;
875
+ /**
876
+ * Emit an event to update the state of a player monitor.
877
+ */
878
+ function emit<K extends MuxEventsInternal[keyof MuxEventsInternal]>(playerId: PlayerId, type: K, payload?: EventParamsMapInternal[K]): void;
879
+ export type Headers = {
880
+ 'x-cdn'?: string;
881
+ 'content-type'?: string;
882
+ 'x-request-id'?: string;
883
+ 'cf-ray'?: string;
884
+ 'x-amz-cf-id'?: string;
885
+ 'x-akamai-request-id'?: string;
886
+ };
887
+ type HostnameDomain = [
888
+ string,
889
+ string?
890
+ ] | undefined;
891
+ type publicUtils = {
892
+ safeCall<Type, Key extends keyof Type>(object: Type, method: Key, arguments?: any[]): any;
893
+ safeIncrement<Type, Key extends keyof Type>(object: Type, prop: Key, num?: number): void;
894
+ getComputedStyle<Key extends keyof CSSStyleDeclaration>(el: HTMLElement | null | undefined, prop: Key): ReturnType<CSSStyleDeclaration['getPropertyValue']>;
895
+ secondsToMs(seconds: number): number;
896
+ headersStringToObject(headers: string): Headers;
897
+ cdnHeadersToRequestId(headers: Headers): string | undefined;
898
+ extractHostnameAndDomain(url: string): HostnameDomain;
899
+ extractHostname(url: string): HostnameDomain;
900
+ generateShortID: () => string;
901
+ generateUUID: () => string;
902
+ now: () => number;
903
+ assign: typeof Object.assign;
904
+ /** @TODO This is a class. Make sure to update appropriately in final type defs (CJP) */
905
+ manifestParser: any;
906
+ /**
907
+ * @TODO improve return type:
908
+ * [
909
+ * HTMLElement, // Typically HTMLMediaElement/HTMLVideoElement, but not necessarily
910
+ * string,
911
+ * string // Typically nodeName of HTMLElement, or '' if not an HTMLElement
912
+ * ]
913
+ * (CJP)
914
+ */
915
+ findMediaElement: (id: PlayerId) => [
916
+ any,
917
+ any,
918
+ any
919
+ ];
920
+ };
921
+ const utils: publicUtils;
922
+ const events: MuxEvents;
923
+ const eventsInternal: MuxEventsInternal;
924
+ export interface MuxOnVideoElement {
925
+ deleted: false;
926
+ destroy: () => void;
927
+ swapElement: (playerId: PlayerId) => void;
928
+ emit: OmitFirstArg<typeof emit>;
929
+ addHLSJS: OmitFirstArg<typeof addHLSJS>;
930
+ addDashJS: OmitFirstArg<typeof addDashJS>;
931
+ removeHLSJS: OmitFirstArg<typeof removeHLSJS>;
932
+ removeDashJS: OmitFirstArg<typeof removeDashJS>;
933
+ updateData: OmitFirstArg<typeof updateData>;
934
+ /**
935
+ * @private *For internal use only.*
936
+ * @param emitTranslator
937
+ * @returns
938
+ */
939
+ setEmitTranslator: (emitTranslator: Options['emitTranslator']) => void;
940
+ /**
941
+ * @private *For internal use only.*
942
+ * @param setStateDataTranslator
943
+ * @returns
944
+ */
945
+ setStateDataTranslator: (stateDataTranslator: Options['stateDataTranslator']) => void;
946
+ /**
947
+ * @private *For internal use only.*
948
+ * @param setGetPlayheadTime
949
+ * @returns
950
+ */
951
+ setGetPlayheadTime: (getPlayheadTime: Options['getPlayheadTime']) => void;
952
+ /** @TODO Hopefully we can move this out of the core interface def and instead keep it explicit in the ima-specific code (CJP) */
953
+ triggerAdRequest?: () => void;
954
+ }
955
+ export interface DeletedMuxOnVideoElement {
956
+ deleted: true;
957
+ destroy: () => void;
958
+ swapElement: () => void;
959
+ emit: () => void;
960
+ addHLSJS: () => void;
961
+ addDashJS: () => void;
962
+ removeHLSJS: () => void;
963
+ removeDashJS: () => void;
964
+ updateData: () => void;
965
+ /**
966
+ * @private *For internal use only.*
967
+ * @param emitTranslator
968
+ * @returns
969
+ */
970
+ setEmitTranslator: () => void;
971
+ /**
972
+ * @private *For internal use only.*
973
+ * @param setStateDataTranslator
974
+ * @returns
975
+ */
976
+ setStateDataTranslator: () => void;
977
+ /**
978
+ * @private *For internal use only.*
979
+ * @param setGetPlayheadTime
980
+ * @returns
981
+ */
982
+ setGetPlayheadTime: () => void;
983
+ /** @TODO Hopefully we can move this out of the core interface def and instead keep it explicit in the ima-specific code (CJP) */
984
+ triggerAdRequest?: () => void;
985
+ }
986
+ export interface Mux {
987
+ (task: any, ...args: any[]): void;
988
+ loaded: number;
989
+ NAME: string;
990
+ VERSION: string;
991
+ API_VERSION: string;
992
+ PLAYER_TRACKED: boolean;
993
+ monitor: typeof monitor;
994
+ destroyMonitor: typeof destroyMonitor;
995
+ addHLSJS: typeof addHLSJS;
996
+ addDashJS: typeof addDashJS;
997
+ removeHLSJS: typeof removeHLSJS;
998
+ removeDashJS: typeof removeDashJS;
999
+ init: typeof init;
1000
+ emit: typeof emit;
1001
+ checkDoNotTrack: typeof checkDoNotTrack;
1002
+ updateData: typeof updateData;
1003
+ /** @TODO Revisit type def (CJP) */
1004
+ log: any;
1005
+ utils: typeof utils;
1006
+ events: MuxEvents;
1007
+ WINDOW_HIDDEN: boolean;
1008
+ WINDOW_UNLOADING: boolean;
1009
+ }
1010
+ const mux: Mux;
1011
+ export default mux;
1012
+ global {
1013
+ interface HTMLMediaElement {
1014
+ mux?: MuxOnVideoElement | DeletedMuxOnVideoElement;
1015
+ getVideoPlaybackQuality?: () => {
1016
+ droppedVideoFrames?: number;
1017
+ };
1018
+ }
1019
+ }
1020
+ }