@mux/playback-core 0.16.2 → 0.17.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.
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +3 -3
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +3 -3
- package/dist/playback-core.js +45 -32
- package/dist/playback-core.js.map +4 -4
- package/dist/playback-core.mjs +45 -32
- package/dist/playback-core.mjs.map +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/errors.d.ts +2 -1
- package/dist/types/index.d.ts +6 -4
- package/dist/types/media-chrome.d.ts +6 -0
- package/dist/types/mux-embed.d.ts +594 -0
- package/dist/types/types.d.ts +11 -6
- package/dist/types-ts3.4/errors.d.ts +2 -1
- package/dist/types-ts3.4/index.d.ts +6 -4
- package/dist/types-ts3.4/media-chrome.d.ts +7 -0
- package/dist/types-ts3.4/mux-embed.d.ts +566 -0
- package/dist/types-ts3.4/types.d.ts +11 -6
- package/package.json +6 -6
|
@@ -0,0 +1,594 @@
|
|
|
1
|
+
declare module 'mux-embed' {
|
|
2
|
+
import Hls from 'hls.js';
|
|
3
|
+
// import dashjs from 'dashjs';
|
|
4
|
+
|
|
5
|
+
export type MetaData = {
|
|
6
|
+
/**
|
|
7
|
+
* Your environment key from the Mux dashboard.
|
|
8
|
+
*/
|
|
9
|
+
env_key?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Your internal ID for the video
|
|
12
|
+
*/
|
|
13
|
+
video_id?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Title of the video player (e.g.: 'Awesome Show: Pilot')
|
|
16
|
+
*/
|
|
17
|
+
video_title?: string;
|
|
18
|
+
/**
|
|
19
|
+
* 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.
|
|
20
|
+
*/
|
|
21
|
+
viewer_user_id?: string;
|
|
22
|
+
/**
|
|
23
|
+
* 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.
|
|
24
|
+
*/
|
|
25
|
+
experiment_name?: string;
|
|
26
|
+
/**
|
|
27
|
+
* 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
|
|
28
|
+
*/
|
|
29
|
+
page_type?: string;
|
|
30
|
+
/**
|
|
31
|
+
* 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.
|
|
32
|
+
*/
|
|
33
|
+
player_init_time?: number;
|
|
34
|
+
/**
|
|
35
|
+
* 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.
|
|
36
|
+
*/
|
|
37
|
+
player_name?: string;
|
|
38
|
+
/**
|
|
39
|
+
* 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.
|
|
40
|
+
*/
|
|
41
|
+
player_version?: string;
|
|
42
|
+
/**
|
|
43
|
+
* 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.
|
|
44
|
+
*/
|
|
45
|
+
sub_property_id?: string;
|
|
46
|
+
/**
|
|
47
|
+
* The Content Delivery Network used to deliver the video. If using an SDK that supports CDN header extraction, this value will be auto-populated.
|
|
48
|
+
*/
|
|
49
|
+
video_cdn?: string;
|
|
50
|
+
/**
|
|
51
|
+
* The type of content: 'short', 'movie', 'episode', 'clip', 'trailer', or 'event'
|
|
52
|
+
*/
|
|
53
|
+
video_content_type?: string;
|
|
54
|
+
/**
|
|
55
|
+
* The length of the video in milliseconds
|
|
56
|
+
*/
|
|
57
|
+
video_duration?: number;
|
|
58
|
+
/**
|
|
59
|
+
* 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.
|
|
60
|
+
*/
|
|
61
|
+
video_encoding_variant?: string;
|
|
62
|
+
/**
|
|
63
|
+
* The audio language of the video, assuming it's unchangeable after playing.
|
|
64
|
+
*/
|
|
65
|
+
video_language_code?: string;
|
|
66
|
+
/**
|
|
67
|
+
* The producer of the video title
|
|
68
|
+
*/
|
|
69
|
+
video_producer?: string;
|
|
70
|
+
/**
|
|
71
|
+
* The series of the video (e.g.: 'Season 1')
|
|
72
|
+
*/
|
|
73
|
+
video_series?: string;
|
|
74
|
+
/**
|
|
75
|
+
* The type of video stream (e.g: 'live' or 'on-demand')
|
|
76
|
+
*/
|
|
77
|
+
video_stream_type?: string;
|
|
78
|
+
/**
|
|
79
|
+
* 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.
|
|
80
|
+
*/
|
|
81
|
+
video_variant_name?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Your internal ID for a video variant
|
|
84
|
+
*/
|
|
85
|
+
video_variant_id?: string;
|
|
86
|
+
/**
|
|
87
|
+
* An ID that can be used to correlate the view with platform services upstream such as CDN or origin logs.
|
|
88
|
+
*/
|
|
89
|
+
view_session_id?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Custom metadata field 1
|
|
92
|
+
*/
|
|
93
|
+
custom_1?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Custom metadata field 2
|
|
96
|
+
*/
|
|
97
|
+
custom_2?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Custom metadata field 3
|
|
100
|
+
*/
|
|
101
|
+
custom_3?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Custom metadata field 4
|
|
104
|
+
*/
|
|
105
|
+
custom_4?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Custom metadata field 5
|
|
108
|
+
*/
|
|
109
|
+
custom_5?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Browser used for the video view (Safari, Chrome, etc.) NB: `(viewer_application_name)`
|
|
112
|
+
*/
|
|
113
|
+
browser?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Browser version (e.g. Chrome 66.0.3359.158) NB: `(viewer_application_version)`
|
|
116
|
+
*/
|
|
117
|
+
browser_version?: string;
|
|
118
|
+
/**
|
|
119
|
+
* CDN delivering the video view (either determined by Mux (network metrics), or provided as video_cdn (Custom Metadata))
|
|
120
|
+
*/
|
|
121
|
+
cdn?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Operating System (iOS, Windows, etc) NB: `(viewer_os_family)`
|
|
124
|
+
*/
|
|
125
|
+
operating_system?: string;
|
|
126
|
+
/**
|
|
127
|
+
* Operating System version (e.g. OS X 10.6) NB: `(viewer_os_version)`
|
|
128
|
+
*/
|
|
129
|
+
operating_system_version?: string;
|
|
130
|
+
/**
|
|
131
|
+
* Page URL
|
|
132
|
+
*/
|
|
133
|
+
page_url?: string;
|
|
134
|
+
/**
|
|
135
|
+
* 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.
|
|
136
|
+
*/
|
|
137
|
+
player_autoplay?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Height of the player as displayed in page, in pixels
|
|
140
|
+
*/
|
|
141
|
+
player_height?: number;
|
|
142
|
+
/**
|
|
143
|
+
* Identifies the instance of the Player class that is created when a video is initialized
|
|
144
|
+
*/
|
|
145
|
+
player_instance_id?: string;
|
|
146
|
+
/**
|
|
147
|
+
* Player's text language
|
|
148
|
+
*/
|
|
149
|
+
player_language?: string;
|
|
150
|
+
/**
|
|
151
|
+
* The image shown as the pre-visualisation before play
|
|
152
|
+
*/
|
|
153
|
+
player_poster?: string;
|
|
154
|
+
/**
|
|
155
|
+
* Specifies if the player was configured to load the video when the page loads.
|
|
156
|
+
*/
|
|
157
|
+
player_preload?: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* If the video is remote played to AirPlay as specified by the SDK.
|
|
160
|
+
*/
|
|
161
|
+
player_remote_played?: boolean;
|
|
162
|
+
/**
|
|
163
|
+
* Player Software being used to play the Video (e.g. Video.js, JW Player, etc.)
|
|
164
|
+
*/
|
|
165
|
+
player_software?: string;
|
|
166
|
+
/**
|
|
167
|
+
* Player Software Version (e.g. 2.45.5)
|
|
168
|
+
*/
|
|
169
|
+
player_software_version?: string;
|
|
170
|
+
/**
|
|
171
|
+
* Player Software Name (e.g. MuxPlayer)
|
|
172
|
+
*/
|
|
173
|
+
player_software_name?: string;
|
|
174
|
+
/**
|
|
175
|
+
* Height of the source video being sent to the player, in pixels
|
|
176
|
+
*/
|
|
177
|
+
player_source_height?: number;
|
|
178
|
+
/**
|
|
179
|
+
* Width of the source video being as seen by the player
|
|
180
|
+
*/
|
|
181
|
+
player_source_width?: number;
|
|
182
|
+
/**
|
|
183
|
+
* Width of the player as displayed in page, in pixels
|
|
184
|
+
*/
|
|
185
|
+
player_width?: number;
|
|
186
|
+
/**
|
|
187
|
+
* Format of the source, as determined by the player. E.g. 'dash', 'x-application/mpegUrl', 'mp4', etc.
|
|
188
|
+
*/
|
|
189
|
+
source_type?: string;
|
|
190
|
+
/**
|
|
191
|
+
* Indicates whether the viewer used full screen to watch the video.
|
|
192
|
+
*/
|
|
193
|
+
used_fullscreen?: boolean;
|
|
194
|
+
/**
|
|
195
|
+
* The type of connection used by the player, as reported by the client when available: `cellular`, `other`, `wifi`, `wired`
|
|
196
|
+
*/
|
|
197
|
+
viewer_connection_type?: string;
|
|
198
|
+
/**
|
|
199
|
+
* The form factor of the device: `tv`, `phone`, `tablet`, etc.
|
|
200
|
+
*/
|
|
201
|
+
viewer_device_category?: string;
|
|
202
|
+
/**
|
|
203
|
+
* Device Manufacturer (e.g. Apple, Microsoft)
|
|
204
|
+
*/
|
|
205
|
+
viewer_device_manufacturer?: string;
|
|
206
|
+
/**
|
|
207
|
+
* Device Name (e.g. iPhone)
|
|
208
|
+
*/
|
|
209
|
+
viewer_device_name?: string;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
type MuxEvents = {
|
|
213
|
+
/**
|
|
214
|
+
* 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.
|
|
215
|
+
*/
|
|
216
|
+
HEARTBEAT: 'hb';
|
|
217
|
+
/**
|
|
218
|
+
* Fired when the player is ready to be used.
|
|
219
|
+
*/
|
|
220
|
+
PLAYER_READY: 'playerready';
|
|
221
|
+
/**
|
|
222
|
+
* 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.
|
|
223
|
+
*/
|
|
224
|
+
VIEW_INIT: 'viewinit';
|
|
225
|
+
/**
|
|
226
|
+
* 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.
|
|
227
|
+
*/
|
|
228
|
+
VIDEO_CHANGE: 'videochange';
|
|
229
|
+
/**
|
|
230
|
+
* 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.
|
|
231
|
+
*
|
|
232
|
+
* For the HTML5 video element, this correlates to the play event on the video element.
|
|
233
|
+
*
|
|
234
|
+
* 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.
|
|
235
|
+
*/
|
|
236
|
+
PLAY: 'play';
|
|
237
|
+
/**
|
|
238
|
+
* Signals that playback has been intentionally delayed, either by the viewer or by the player (e.g. starting an ad).
|
|
239
|
+
*
|
|
240
|
+
* For the HTML5 video element, this correlates to the pause event on the video element.
|
|
241
|
+
*
|
|
242
|
+
* 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.
|
|
243
|
+
*/
|
|
244
|
+
PAUSE: 'pause';
|
|
245
|
+
/**
|
|
246
|
+
* 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.
|
|
247
|
+
*
|
|
248
|
+
* For the HTML5 video element, this correlates to the playing event on the video element.
|
|
249
|
+
*/
|
|
250
|
+
PLAYING: 'playing';
|
|
251
|
+
/**
|
|
252
|
+
* 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.
|
|
253
|
+
*/
|
|
254
|
+
TIME_UPDATE: 'timeupdate';
|
|
255
|
+
/**
|
|
256
|
+
* Signals that the user has attempted to seek forward or backward within the timeline of the video.
|
|
257
|
+
*/
|
|
258
|
+
SEEKING: 'seeking';
|
|
259
|
+
/**
|
|
260
|
+
* Signals that the player has the video data for the new playback position, and is ready to immediately start playing at this new position.
|
|
261
|
+
*/
|
|
262
|
+
SEEKED: 'seeked';
|
|
263
|
+
/**
|
|
264
|
+
* Signals that the player has stopped playing back content when it is expected that playback should be progressing.
|
|
265
|
+
*/
|
|
266
|
+
REBUFFER_START: 'rebufferstart';
|
|
267
|
+
/**
|
|
268
|
+
* Signals that the player has resumed playing back content after playback previous stalled while attempting to play back.
|
|
269
|
+
*/
|
|
270
|
+
REBUFFER_END: 'rebufferend';
|
|
271
|
+
/**
|
|
272
|
+
* 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.
|
|
273
|
+
*/
|
|
274
|
+
ERROR: 'error';
|
|
275
|
+
/**
|
|
276
|
+
* Signals that the current video has played to completion.
|
|
277
|
+
*/
|
|
278
|
+
ENDED: 'ended';
|
|
279
|
+
/**
|
|
280
|
+
* 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.
|
|
281
|
+
*/
|
|
282
|
+
RENDITION_CHANGE: 'renditionchange';
|
|
283
|
+
/**
|
|
284
|
+
* 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.
|
|
285
|
+
*/
|
|
286
|
+
ORIENTATION_CHANGE: 'orientationchange';
|
|
287
|
+
/**
|
|
288
|
+
* Signals that an ad request is about to be made, or was just made but the response has not been received.
|
|
289
|
+
*
|
|
290
|
+
* In the process of the player retrieving an ad payload,
|
|
291
|
+
* multiple {@link MuxEvents.AD_REQUEST `adrequest`} and {@link MuxEvents.AD_RESPONSE `adresponse`} events may be fired (either due to waterfall,
|
|
292
|
+
* or for an ad break that has multiple ads). In the case that these requests are made in parallel,
|
|
293
|
+
* 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,
|
|
294
|
+
* so that Mux can match them up correctly.
|
|
295
|
+
*/
|
|
296
|
+
AD_REQUEST: 'adrequest';
|
|
297
|
+
/**
|
|
298
|
+
* Signals that a response was received from the ad server.
|
|
299
|
+
*
|
|
300
|
+
* In the process of the player retrieving an ad payload,
|
|
301
|
+
* multiple {@link MuxEvents.AD_REQUEST `adrequest`} and {@link MuxEvents.AD_RESPONSE `adresponse`} events may be fired (either due to waterfall,
|
|
302
|
+
* or for an ad break that has multiple ads). In the case that these requests are made in parallel,
|
|
303
|
+
* 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,
|
|
304
|
+
* so that Mux can match them up correctly.
|
|
305
|
+
*
|
|
306
|
+
* The adresponse event can only be fired by the player integration if the adrequest events are fired as well.
|
|
307
|
+
*/
|
|
308
|
+
AD_RESPONSE: 'adresponse';
|
|
309
|
+
/**
|
|
310
|
+
* 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.
|
|
311
|
+
*
|
|
312
|
+
* The `adbreakstart` event may come before, during, or after the adrequest/adresponse events, depending on the player’s configuration for making ad requests.
|
|
313
|
+
*/
|
|
314
|
+
AD_BREAK_START: 'adbreakstart';
|
|
315
|
+
/**
|
|
316
|
+
* 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.
|
|
317
|
+
*
|
|
318
|
+
* This event is the ad-specific equivalent of play.
|
|
319
|
+
*/
|
|
320
|
+
AD_PLAY: 'adplay';
|
|
321
|
+
/**
|
|
322
|
+
* 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.
|
|
323
|
+
*
|
|
324
|
+
* This event is the ad-specific equivalent of playing.
|
|
325
|
+
*/
|
|
326
|
+
AD_PLAYING: 'adplaying';
|
|
327
|
+
/**
|
|
328
|
+
* 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).
|
|
329
|
+
*
|
|
330
|
+
* This event is the ad-specific equivalent of pause.
|
|
331
|
+
*/
|
|
332
|
+
AD_PAUSE: 'adpause';
|
|
333
|
+
/**
|
|
334
|
+
* 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).
|
|
335
|
+
*/
|
|
336
|
+
AD_FIRST_QUARTILE: 'adfirstquartile';
|
|
337
|
+
/**
|
|
338
|
+
* 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).
|
|
339
|
+
*/
|
|
340
|
+
AD_MID_POINT: 'admidpoint';
|
|
341
|
+
/**
|
|
342
|
+
* 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).
|
|
343
|
+
*/
|
|
344
|
+
AD_THIRD_QUARTILE: 'adthirdquartile';
|
|
345
|
+
/**
|
|
346
|
+
* Signals that the advertisement has played to completion.
|
|
347
|
+
*
|
|
348
|
+
* This event is the ad-specific equivalent of ended.
|
|
349
|
+
*/
|
|
350
|
+
AD_ENDED: 'adended';
|
|
351
|
+
/**
|
|
352
|
+
* 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.
|
|
353
|
+
*
|
|
354
|
+
* There may be multiple adplay/adended combinations within a single ad break.
|
|
355
|
+
*/
|
|
356
|
+
AD_BREAK_END: 'adbreakend';
|
|
357
|
+
/**
|
|
358
|
+
* Signals that an error has occurred that relates to the ad break currently in play or the ad request/response.
|
|
359
|
+
*/
|
|
360
|
+
AD_ERROR: 'aderror';
|
|
361
|
+
/**
|
|
362
|
+
* Signals that a network request for a piece of content returned successfully.
|
|
363
|
+
*/
|
|
364
|
+
REQUEST_COMPLETED: 'requestcompleted';
|
|
365
|
+
/**
|
|
366
|
+
* Signals that a network request for a piece of content returned unsuccessfully.
|
|
367
|
+
*/
|
|
368
|
+
REQUEST_FAILED: 'requestfailed';
|
|
369
|
+
/**
|
|
370
|
+
* Signals that a network request for a piece of content was aborted before it could return (either successfully or unsuccessfully).
|
|
371
|
+
*/
|
|
372
|
+
REQUEST_CANCELLED: 'requestcanceled';
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
export type Options = {
|
|
376
|
+
/**
|
|
377
|
+
* Controls whether debug log statements are logged to the console
|
|
378
|
+
*/
|
|
379
|
+
debug?: boolean;
|
|
380
|
+
hlsjs?: Hls;
|
|
381
|
+
Hls?: typeof Hls;
|
|
382
|
+
data?: MetaData;
|
|
383
|
+
disableCookies?: boolean;
|
|
384
|
+
/** @deprecated */
|
|
385
|
+
beaconDomain?: string;
|
|
386
|
+
beaconCollectionDomain?: string;
|
|
387
|
+
/**
|
|
388
|
+
* Respect 'Do Not Track' when set within browsers.
|
|
389
|
+
*/
|
|
390
|
+
respectDoNotTrack?: boolean;
|
|
391
|
+
/**
|
|
392
|
+
* 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.
|
|
393
|
+
*/
|
|
394
|
+
automaticErrorTracking?: boolean;
|
|
395
|
+
/**
|
|
396
|
+
* 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.
|
|
397
|
+
*/
|
|
398
|
+
errorTranslator?: (error: ErrorEvent) => ErrorEvent | false;
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
export type AdEventTag = {
|
|
402
|
+
ad_request_id?: string;
|
|
403
|
+
ad_tag_url?: string;
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
export type AdEventAssets = {
|
|
407
|
+
ad_asset_url?: string;
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
export type ErrorEvent = {
|
|
411
|
+
player_error_code?: number;
|
|
412
|
+
player_error_message?: string;
|
|
413
|
+
player_error_context?: string;
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
export type TimeUpdateEvent = {
|
|
417
|
+
player_playhead_time?: number;
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
export type RenditionChangeEvent = {
|
|
421
|
+
video_source_bitrate: number;
|
|
422
|
+
video_source_width?: number;
|
|
423
|
+
video_source_height?: number;
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
export type OrientationChangeEvent = {
|
|
427
|
+
viewer_device_orientation: [number, number, number];
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
export type RequestCompletedEvent = {
|
|
431
|
+
request_bytes_loaded?: number;
|
|
432
|
+
request_response_start?: number;
|
|
433
|
+
request_response_end?: number;
|
|
434
|
+
request_response_headers?: Partial<Headers>;
|
|
435
|
+
request_media_duration?: number;
|
|
436
|
+
request_video_width?: number;
|
|
437
|
+
request_video_height?: number;
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
export type RequestFailedEvent = {
|
|
441
|
+
request_error: string;
|
|
442
|
+
request_error_code: number;
|
|
443
|
+
request_error_text: string;
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
export type NetworkEvent = {
|
|
447
|
+
request_type?: 'manifest' | 'video' | 'audio' | 'video_init' | 'audio_init' | 'media';
|
|
448
|
+
request_start?: number;
|
|
449
|
+
request_hostname?: string;
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
type EventParamsMap = {
|
|
453
|
+
[events.HEARTBEAT]: Partial<MetaData>;
|
|
454
|
+
[events.VIEW_INIT]: void;
|
|
455
|
+
[events.VIDEO_CHANGE]: void;
|
|
456
|
+
[events.PLAY]: void;
|
|
457
|
+
[events.PAUSE]: void;
|
|
458
|
+
[events.PLAYING]: void;
|
|
459
|
+
// This appears to be wrong (duplicate with mismatch below, which appears to be right from mux-embed)
|
|
460
|
+
// [events.TIME_UPDATE]: void;
|
|
461
|
+
[events.SEEKING]: void;
|
|
462
|
+
[events.SEEKED]: void;
|
|
463
|
+
[events.REBUFFER_START]: void;
|
|
464
|
+
[events.REBUFFER_END]: void;
|
|
465
|
+
[events.ERROR]: ErrorEvent;
|
|
466
|
+
[events.ENDED]: void;
|
|
467
|
+
[events.RENDITION_CHANGE]: RenditionChangeEvent;
|
|
468
|
+
[events.ORIENTATION_CHANGE]: OrientationChangeEvent;
|
|
469
|
+
[events.AD_REQUEST]: AdEventTag;
|
|
470
|
+
[events.AD_RESPONSE]: AdEventTag;
|
|
471
|
+
[events.AD_BREAK_START]: void;
|
|
472
|
+
[events.AD_PLAY]: AdEventAssets;
|
|
473
|
+
[events.AD_PLAYING]: AdEventAssets;
|
|
474
|
+
[events.AD_PAUSE]: AdEventAssets;
|
|
475
|
+
[events.AD_FIRST_QUARTILE]: void;
|
|
476
|
+
[events.AD_MID_POINT]: void;
|
|
477
|
+
[events.AD_THIRD_QUARTILE]: void;
|
|
478
|
+
[events.AD_ENDED]: AdEventAssets;
|
|
479
|
+
[events.AD_BREAK_END]: void;
|
|
480
|
+
[events.AD_ERROR]: void;
|
|
481
|
+
[events.REQUEST_COMPLETED]: RequestCompletedEvent & NetworkEvent;
|
|
482
|
+
[events.REQUEST_FAILED]: RequestFailedEvent & NetworkEvent;
|
|
483
|
+
[events.REQUEST_CANCELLED]: NetworkEvent;
|
|
484
|
+
[events.TIME_UPDATE]: TimeUpdateEvent;
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
type PlayerId = string | HTMLMediaElement;
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Monitor a video element
|
|
491
|
+
*/
|
|
492
|
+
export function monitor(id: PlayerId, options?: Options): void;
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Create a new generic player monitor
|
|
496
|
+
*/
|
|
497
|
+
export function init(id: PlayerId, options?: Options): void;
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Stop monitoring a normal video element
|
|
501
|
+
*/
|
|
502
|
+
export function destroyMonitor(playerId: PlayerId): void;
|
|
503
|
+
|
|
504
|
+
export type HlsOptions = {
|
|
505
|
+
hlsjs: Hls;
|
|
506
|
+
Hls?: typeof Hls;
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
// export type DashOptions = {
|
|
510
|
+
// dashjs: dashjs;
|
|
511
|
+
// Dash?: typeof dashjs;
|
|
512
|
+
// };
|
|
513
|
+
export function addHLSJS(playerId: PlayerId, options: HlsOptions): void;
|
|
514
|
+
// export function addDashJS(playerId: PlayerId, options: DashOptions): void;
|
|
515
|
+
export function removeHLSJS(playerId: PlayerId): void;
|
|
516
|
+
// export function removeDashJS(playerId: PlayerId): void;
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Emit an event to update the state of a player monitor.
|
|
520
|
+
*/
|
|
521
|
+
export function emit<K extends MuxEvents[keyof MuxEvents] & keyof EventParamsMap>(
|
|
522
|
+
playerId: PlayerId,
|
|
523
|
+
type: K,
|
|
524
|
+
payload?: EventParamsMap[K]
|
|
525
|
+
): void;
|
|
526
|
+
|
|
527
|
+
// Public Utils
|
|
528
|
+
type Headers = {
|
|
529
|
+
'x-cdn': string;
|
|
530
|
+
'content-type': string;
|
|
531
|
+
};
|
|
532
|
+
type HostnameDomain = [string, string?] | undefined;
|
|
533
|
+
type publicUtils = {
|
|
534
|
+
safeCall<Type, Key extends keyof Type>(object: Type, method: Key, arguments: any[]): any;
|
|
535
|
+
safeIncrement<Type, Key extends keyof Type>(object: Type, prop: Key, num?: number): void;
|
|
536
|
+
getComputedStyle<Key extends keyof CSSStyleDeclaration>(
|
|
537
|
+
el: HTMLElement,
|
|
538
|
+
prop: Key
|
|
539
|
+
): ReturnType<CSSStyleDeclaration['getPropertyValue']>;
|
|
540
|
+
secondsToMs(seconds: number): number;
|
|
541
|
+
headersStringToObject(headers: string): Partial<Headers>;
|
|
542
|
+
extractHostnameAndDomain(url: string): HostnameDomain;
|
|
543
|
+
extractHostname(url: string): HostnameDomain;
|
|
544
|
+
generateUUID(): string;
|
|
545
|
+
now(): number;
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
export const utils: publicUtils;
|
|
549
|
+
|
|
550
|
+
export const events: MuxEvents;
|
|
551
|
+
|
|
552
|
+
type MuxType = (task: any) => void;
|
|
553
|
+
type muxProps = {
|
|
554
|
+
utils: publicUtils;
|
|
555
|
+
events: MuxEvents;
|
|
556
|
+
monitor: typeof monitor;
|
|
557
|
+
init: typeof init;
|
|
558
|
+
destroyMonitor: typeof destroyMonitor;
|
|
559
|
+
addHLSJS: typeof addHLSJS;
|
|
560
|
+
removeHLSJS: typeof removeHLSJS;
|
|
561
|
+
emit: typeof emit;
|
|
562
|
+
};
|
|
563
|
+
interface MuxGlobal extends MuxType, muxProps {}
|
|
564
|
+
|
|
565
|
+
export const mux: MuxGlobal;
|
|
566
|
+
export default mux;
|
|
567
|
+
|
|
568
|
+
global {
|
|
569
|
+
type MuxOnVideoElement = {
|
|
570
|
+
deleted: false;
|
|
571
|
+
destroy: () => void;
|
|
572
|
+
swapElement: (playerId: PlayerId) => void;
|
|
573
|
+
emit: <K extends MuxEvents[keyof MuxEvents] & keyof EventParamsMap>(type: K, payload?: EventParamsMap[K]) => void;
|
|
574
|
+
addHLSJS: (options: HlsOptions) => void;
|
|
575
|
+
// addDashJS: (options: DashOptions) => void;
|
|
576
|
+
removeHLSJS: () => void;
|
|
577
|
+
// removeDashJS: () => void;
|
|
578
|
+
};
|
|
579
|
+
type DeletedMuxOnVideoElement = {
|
|
580
|
+
deleted: true;
|
|
581
|
+
destroy: () => void;
|
|
582
|
+
swapElement: () => void;
|
|
583
|
+
emit: () => void;
|
|
584
|
+
addHLSJS: () => void;
|
|
585
|
+
// addDashJS: () => void;
|
|
586
|
+
removeHLSJS: () => void;
|
|
587
|
+
// removeDashJS: () => void;
|
|
588
|
+
};
|
|
589
|
+
|
|
590
|
+
interface HTMLMediaElement {
|
|
591
|
+
mux?: MuxOnVideoElement | DeletedMuxOnVideoElement;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
/// <reference path="mux-embed.d.ts" />
|
|
1
2
|
import type { Options } from 'mux-embed';
|
|
3
|
+
import type { MediaError } from './errors';
|
|
2
4
|
import type { HlsInterface as Hls } from './hls';
|
|
3
5
|
type KeyTypes = string | number | symbol;
|
|
4
6
|
type Maybe<T> = T | null | undefined;
|
|
5
7
|
export declare const isKeyOf: <T extends {} = any>(k: KeyTypes, o: Maybe<T>) => k is keyof T;
|
|
6
8
|
export type ValueOf<T> = T[keyof T];
|
|
7
|
-
export type Metadata = Partial<Options['data']>;
|
|
9
|
+
export type Metadata = Partial<Required<Options>['data']>;
|
|
10
|
+
type MetaData = Metadata;
|
|
8
11
|
export type PlaybackEngine = Hls;
|
|
9
12
|
export type PlaybackCore = {
|
|
10
13
|
engine?: PlaybackEngine;
|
|
@@ -57,15 +60,16 @@ export type CuePoint<T = any> = {
|
|
|
57
60
|
value: T;
|
|
58
61
|
};
|
|
59
62
|
export type MuxMediaPropTypes = {
|
|
60
|
-
envKey:
|
|
63
|
+
envKey: MetaData['env_key'];
|
|
61
64
|
debug: Options['debug'] & Hls['config']['debug'];
|
|
62
65
|
metadata: Partial<Options['data']>;
|
|
66
|
+
maxResolution: string;
|
|
63
67
|
customDomain: string;
|
|
64
68
|
beaconCollectionDomain: Options['beaconCollectionDomain'];
|
|
65
69
|
errorTranslator: Options['errorTranslator'];
|
|
66
70
|
disableCookies: Options['disableCookies'];
|
|
67
71
|
playbackId: string;
|
|
68
|
-
playerInitTime:
|
|
72
|
+
playerInitTime: MetaData['player_init_time'];
|
|
69
73
|
preferPlayback: ValueOf<PlaybackTypes> | undefined;
|
|
70
74
|
type: MediaTypes;
|
|
71
75
|
streamType: ValueOf<StreamTypes>;
|
|
@@ -73,11 +77,12 @@ export type MuxMediaPropTypes = {
|
|
|
73
77
|
autoPlay?: Autoplay;
|
|
74
78
|
autoplay?: Autoplay;
|
|
75
79
|
preferCmcd: ValueOf<CmcdTypes> | undefined;
|
|
80
|
+
error?: HTMLMediaElement['error'] | MediaError;
|
|
76
81
|
};
|
|
77
|
-
export type HTMLMediaElementProps = Partial<Pick<HTMLMediaElement, 'src' | 'preload'>>;
|
|
82
|
+
export type HTMLMediaElementProps = Partial<Pick<HTMLMediaElement, 'src' | 'preload' | 'error'>>;
|
|
78
83
|
export type MuxMediaProps = HTMLMediaElementProps & MuxMediaPropTypes;
|
|
79
84
|
export type MuxMediaPropsInternal = MuxMediaProps & {
|
|
80
|
-
playerSoftwareName:
|
|
81
|
-
playerSoftwareVersion:
|
|
85
|
+
playerSoftwareName: MetaData['player_software_name'];
|
|
86
|
+
playerSoftwareVersion: MetaData['player_software_version'];
|
|
82
87
|
};
|
|
83
88
|
export {};
|
|
@@ -8,7 +8,8 @@ export declare class MediaError extends Error {
|
|
|
8
8
|
static defaultMessages: Record<number, string>;
|
|
9
9
|
name: string;
|
|
10
10
|
code: number;
|
|
11
|
+
context?: string;
|
|
11
12
|
fatal: boolean;
|
|
12
13
|
data?: any;
|
|
13
|
-
constructor(message?: string, code?: number, fatal?: boolean);
|
|
14
|
+
constructor(message?: string, code?: number, fatal?: boolean, context?: string);
|
|
14
15
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference path="mux-embed.d.ts" />
|
|
1
2
|
import mux from 'mux-embed';
|
|
2
3
|
import Hls from './hls';
|
|
3
4
|
import { HlsInterface } from './hls';
|
|
@@ -6,12 +7,13 @@ import { addTextTrack, removeTextTrack, addCuePoints, getCuePoints, getActiveCue
|
|
|
6
7
|
import { StreamTypes, ValueOf, PlaybackCore, MuxMediaProps, MuxMediaPropsInternal } from './types';
|
|
7
8
|
export { mux, Hls, MediaError, addTextTrack, removeTextTrack, addCuePoints, getCuePoints, getActiveCuePoint, getCuePointsTrack, setupCuePoints, };
|
|
8
9
|
export * from './types';
|
|
9
|
-
export declare const generatePlayerInitTime: () =>
|
|
10
|
-
export declare const generateUUID:
|
|
11
|
-
export declare const toMuxVideoURL: (playbackId?: string, { domain }?: {
|
|
10
|
+
export declare const generatePlayerInitTime: () => number;
|
|
11
|
+
export declare const generateUUID: () => string;
|
|
12
|
+
export declare const toMuxVideoURL: (playbackId?: string, { domain, maxResolution }?: {
|
|
12
13
|
domain?: string | undefined;
|
|
14
|
+
maxResolution?: string | undefined;
|
|
13
15
|
}) => string | undefined;
|
|
14
|
-
export declare const getError: (mediaEl: HTMLMediaElement) => MediaError | undefined;
|
|
16
|
+
export declare const getError: (mediaEl: HTMLMediaElement) => globalThis.MediaError | (globalThis.MediaError & MediaError) | null | undefined;
|
|
15
17
|
export declare const initialize: (props: Partial<MuxMediaPropsInternal>, mediaEl: HTMLMediaElement, core?: PlaybackCore) => {
|
|
16
18
|
engine: import("hls.js").default | undefined;
|
|
17
19
|
setAutoplay: (newAutoplay?: import("./types").Autoplay | undefined) => void;
|