-
Notifications
You must be signed in to change notification settings - Fork 28
/
events.js
912 lines (870 loc) · 25.1 KB
/
events.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
// Copyright 2014 Globo.com Player authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
import Log from '../../components/log'
import { uniqueId } from '../../utils'
const slice = Array.prototype.slice
const eventSplitter = /\s+/
const eventsApi = function(obj, action, name, rest) {
if (!name) return true
// Handle event maps.
if (typeof name === 'object') {
for (const key in name)
obj[action].apply(obj, [key, name[key]].concat(rest))
return false
}
// Handle space separated event names.
if (eventSplitter.test(name)) {
const names = name.split(eventSplitter)
for (let i = 0, l = names.length; i < l; i++)
obj[action].apply(obj, [names[i]].concat(rest))
return false
}
return true
}
const triggerEvents = function(events, args, klass, name) {
let ev, i = -1
const l = events.length, a1 = args[0], a2 = args[1], a3 = args[2]
run()
function run() {
try {
switch (args.length) {
/* eslint-disable curly */
case 0: while (++i < l) { (ev = events[i]).callback.call(ev.ctx) } return
case 1: while (++i < l) { (ev = events[i]).callback.call(ev.ctx, a1) } return
case 2: while (++i < l) { (ev = events[i]).callback.call(ev.ctx, a1, a2) } return
case 3: while (++i < l) { (ev = events[i]).callback.call(ev.ctx, a1, a2, a3) } return
default: while (++i < l) { (ev = events[i]).callback.apply(ev.ctx, args) } return
}
} catch (exception) {
Log.error.apply(Log, [klass, 'error on event', name, 'trigger','-', exception])
run()
}
}
}
/**
* @class Events
* @constructor
* @module base
*/
export default class Events {
/**
* listen to an event indefinitely, if you want to stop you need to call `off`
* @method on
* @param {String} name
* @param {Function} callback
* @param {Object} context
*/
on(name, callback, context) {
if (!eventsApi(this, 'on', name, [callback, context]) || !callback) return this
this._events || (this._events = {})
const events = this._events[name] || (this._events[name] = [])
events.push({ callback: callback, context: context, ctx: context || this })
return this
}
/**
* listen to an event only once
* @method once
* @param {String} name
* @param {Function} callback
* @param {Object} context
*/
once(name, callback, context) {
let once
if (!eventsApi(this, 'once', name, [callback, context]) || !callback) return this
const off = () => this.off(name, once)
once = function() {
off(name, once)
callback.apply(this, arguments)
}
return this.on(name, once, context)
}
/**
* stop listening to an event
* @method off
* @param {String} name
* @param {Function} callback
* @param {Object} context
*/
off(name, callback, context) {
let retain, ev, events, names, i, l, j, k
if (!this._events || !eventsApi(this, 'off', name, [callback, context])) return this
if (!name && !callback && !context) {
this._events = void 0
return this
}
names = name ? [name] : Object.keys(this._events)
// jshint maxdepth:5
for (i = 0, l = names.length; i < l; i++) {
name = names[i]
events = this._events[name]
if (events) {
this._events[name] = retain = []
if (callback || context) {
for (j = 0, k = events.length; j < k; j++) {
ev = events[j]
if ((callback && callback !== ev.callback && callback !== ev.callback._callback) ||
(context && context !== ev.context))
retain.push(ev)
}
}
if (!retain.length) delete this._events[name]
}
}
return this
}
/**
* triggers an event given its `name`
* @method trigger
* @param {String} name
*/
trigger(name) {
const klass = this.name || this.constructor.name
Log.debug.apply(Log, [klass].concat(Array.prototype.slice.call(arguments)))
if (!this._events) return this
const args = slice.call(arguments, 1)
if (!eventsApi(this, 'trigger', name, args)) return this
const events = this._events[name]
const allEvents = this._events.all
if (events) triggerEvents(events, args, klass, name)
if (allEvents) triggerEvents(allEvents, arguments, klass, name)
return this
}
/**
* stop listening an event for a given object
* @method stopListening
* @param {Object} obj
* @param {String} name
* @param {Function} callback
*/
stopListening(obj, name, callback) {
let listeningTo = this._listeningTo
if (!listeningTo) return this
const remove = !name && !callback
if (!callback && typeof name === 'object') callback = this
if (obj) (listeningTo = {})[obj._listenId] = obj
for (const id in listeningTo) {
obj = listeningTo[id]
obj.off(name, callback, this)
if (remove || Object.keys(obj._events).length === 0) delete this._listeningTo[id]
}
return this
}
static register(eventName) {
Events.Custom || (Events.Custom = {})
let property = typeof eventName === 'string' && eventName.toUpperCase().trim()
if (property && !Events.Custom[property]) {
Events.Custom[property] = property.toLowerCase().split('_').map(
(value, index) => index === 0 ? value : value = (value[0].toUpperCase() + value.slice(1))
).join('')
} else
Log.error('Events', 'Error when register event: ' + eventName)
}
static listAvailableCustomEvents() {
Events.Custom || (Events.Custom = {})
return Object.keys(Events.Custom).filter((property) => typeof Events.Custom[property] === 'string')
}
}
/**
* listen to an event indefinitely for a given `obj`
* @method listenTo
* @param {Object} obj
* @param {String} name
* @param {Function} callback
* @param {Object} context
* @example
* ```javascript
* this.listenTo(this.core.playback, Events.PLAYBACK_PAUSE, this.callback)
* ```
*/
/**
* listen to an event once for a given `obj`
* @method listenToOnce
* @param {Object} obj
* @param {String} name
* @param {Function} callback
* @param {Object} context
* @example
* ```javascript
* this.listenToOnce(this.core.playback, Events.PLAYBACK_PAUSE, this.callback)
* ```
*/
const listenMethods = { listenTo: 'on', listenToOnce: 'once' }
Object.keys(listenMethods).forEach(function(method) {
Events.prototype[method] = function(obj, name, callback) {
const listeningTo = this._listeningTo || (this._listeningTo = {})
const id = obj._listenId || (obj._listenId = uniqueId('l'))
listeningTo[id] = obj
if (!callback && typeof name === 'object') callback = this
obj[listenMethods[method]](name, callback, this)
return this
}
})
// PLAYER EVENTS
/**
* Fired when the player is ready on startup
*
* @event PLAYER_READY
*/
Events.PLAYER_READY = 'ready'
/**
* Fired when player resizes
*
* @event PLAYER_RESIZE
* @param {Object} currentSize an object with the current size
*/
Events.PLAYER_RESIZE = 'resize'
/**
* Fired when player changes its fullscreen state
*
* @event PLAYER_FULLSCREEN
* @param {Boolean} whether or not the player is on fullscreen mode
*/
Events.PLAYER_FULLSCREEN = 'fullscreen'
/**
* Fired when player starts to play
*
* @event PLAYER_PLAY
*/
Events.PLAYER_PLAY = 'play'
/**
* Fired when player pauses
*
* @event PLAYER_PAUSE
*/
Events.PLAYER_PAUSE = 'pause'
/**
* Fired when player stops
*
* @event PLAYER_STOP
*/
Events.PLAYER_STOP = 'stop'
/**
* Fired when player ends the video
*
* @event PLAYER_ENDED
*/
Events.PLAYER_ENDED = 'ended'
/**
* Fired when player seeks the video
*
* @event PLAYER_SEEK
* @param {Number} time the current time in seconds
*/
Events.PLAYER_SEEK = 'seek'
/**
* Fired when player receives an error
*
* @event PLAYER_ERROR
* @param {Object} error the error
*/
Events.PLAYER_ERROR = 'playererror'
/**
* Fired when there is an error
*
* @event ERROR
* @param {Object} error
* the error with the following format `{code, description, level, raw, origin, scope}`
* @param {String} [options.code]
* error's code: code to identify error in the following format: origin:code
* @param {String} [options.description]
* error's description: description of the error
* @param {String} [options.level]
* error's level: FATAL or WARN.
* @param {String} [options.origin]
* error's origin. Example: hls, html5, etc
* @param {String} [options.scope]
* error's scope. Example: playback, container, etc
* @param {String} [options.raw]
* raw error: the initial error received
*/
Events.ERROR = 'error'
/**
* Fired when the time is updated on player
*
* @event PLAYER_TIMEUPDATE
* @param {Object} progress Data
* progress object
* @param {Number} [progress.current]
* current time (in seconds)
* @param {Number} [progress.total]
* total time (in seconds)
*/
Events.PLAYER_TIMEUPDATE = 'timeupdate'
/**
* Fired when player updates its volume
*
* @event PLAYER_VOLUMEUPDATE
* @param {Number} volume the current volume
*/
Events.PLAYER_VOLUMEUPDATE = 'volumeupdate'
/**
* Fired when subtitle is available
*
* @event PLAYER_SUBTITLE_AVAILABLE
*/
Events.PLAYER_SUBTITLE_AVAILABLE = 'subtitleavailable'
// Playback Events
/** Fired when picture-in-picture mode is entered
*
* @event PLAYBACK_PIP_ENTER
*/
Events.PLAYBACK_PIP_ENTER = 'playback:picture-in-picture:enter'
/** Fired when picture-in-picture mode is exited
*
* @event PLAYBACK_PIP_EXIT
*/
Events.PLAYBACK_PIP_EXIT = 'playback:picture-in-picture:exit'
/**
* Fired when the playback is downloading the media
*
* @event PLAYBACK_PROGRESS
* @param progress {Object}
* Data progress object
* @param [progress.start] {Number}
* start position of buffered content at current position
* @param [progress.current] {Number}
* end position of buffered content at current position
* @param [progress.total] {Number}
* total content to be downloaded
* @param buffered {Array}
* array of buffered segments ({start, end}). [Only for supported playbacks]
*/
Events.PLAYBACK_PROGRESS = 'playback:progress'
/**
* Fired when the time is updated on playback
*
* @event PLAYBACK_TIMEUPDATE
* @param {Object} progress Data
* progress object
* @param {Number} [progress.current]
* current time (in seconds)
* @param {Number} [progress.total]
* total time (in seconds)
*/
Events.PLAYBACK_TIMEUPDATE = 'playback:timeupdate'
/**
* Fired when playback is ready
*
* @event PLAYBACK_READY
*/
Events.PLAYBACK_READY = 'playback:ready'
/**
* Fired when the playback starts having to buffer because
* playback can currently not be smooth.
*
* This corresponds to the playback `buffering` property being
* `true`.
*
* @event PLAYBACK_BUFFERING
*/
Events.PLAYBACK_BUFFERING = 'playback:buffering'
/**
* Fired when the playback has enough in the buffer to be
* able to play smoothly, after previously being unable to
* do this.
*
* This corresponds to the playback `buffering` property being
* `false`.
*
* @event PLAYBACK_BUFFERFULL
*/
Events.PLAYBACK_BUFFERFULL = 'playback:bufferfull'
/**
* Fired when playback changes any settings (volume, seek and etc)
*
* @event PLAYBACK_SETTINGSUPDATE
*/
Events.PLAYBACK_SETTINGSUPDATE = 'playback:settingsupdate'
/**
* Fired when playback loaded its metadata
*
* @event PLAYBACK_LOADEDMETADATA
* @param {Object} metadata Data
* settings object
* @param {Number} [metadata.duration]
* the playback duration
* @param {Object} [metadata.data]
* extra meta data
*/
Events.PLAYBACK_LOADEDMETADATA = 'playback:loadedmetadata'
/**
* Fired when playback updates its video quality
*
* @event PLAYBACK_HIGHDEFINITIONUPDATE
* @param {Boolean} isHD
* true when is on HD, false otherwise
*/
Events.PLAYBACK_HIGHDEFINITIONUPDATE = 'playback:highdefinitionupdate'
/**
* Fired when playback updates its bitrate
*
* @event PLAYBACK_BITRATE
* @param {Object} bitrate Data
* bitrate object
* @param {Number} [bitrate.bandwidth]
* bitrate bandwidth when it's available
* @param {Number} [bitrate.width]
* playback width (ex: 720, 640, 1080)
* @param {Number} [bitrate.height]
* playback height (ex: 240, 480, 720)
* @param {Number} [bitrate.level]
* playback level when it's available, it could be just a map for width (0 => 240, 1 => 480, 2 => 720)
*/
Events.PLAYBACK_BITRATE = 'playback:bitrate'
/**
* Fired when the playback has its levels
*
* @event PLAYBACK_LEVELS_AVAILABLE
* @param {Array} levels
* the ordered levels, each one with the following format `{id: 1, label: '500kbps'}` ps: id should be a number >= 0
* @param {Number} initial
* the initial level otherwise -1 (AUTO)
*/
Events.PLAYBACK_LEVELS_AVAILABLE = 'playback:levels:available'
/**
* Fired when the playback starts to switch level
*
* @event PLAYBACK_LEVEL_SWITCH_START
*
*/
Events.PLAYBACK_LEVEL_SWITCH_START = 'playback:levels:switch:start'
/**
* Fired when the playback ends the level switch
*
* @event PLAYBACK_LEVEL_SWITCH_END
*
*/
Events.PLAYBACK_LEVEL_SWITCH_END = 'playback:levels:switch:end'
/**
* Fired when playback internal state changes
*
* @event PLAYBACK_PLAYBACKSTATE
* @param {Object} state Data
* state object
* @param {String} [state.type]
* the playback type
*/
Events.PLAYBACK_PLAYBACKSTATE = 'playback:playbackstate'
/**
* Fired when DVR becomes enabled/disabled.
*
* @event PLAYBACK_DVR
* @param {boolean} state true if dvr enabled
*/
Events.PLAYBACK_DVR = 'playback:dvr'
// TODO doc
Events.PLAYBACK_MEDIACONTROL_DISABLE = 'playback:mediacontrol:disable'
// TODO doc
Events.PLAYBACK_MEDIACONTROL_ENABLE = 'playback:mediacontrol:enable'
/**
* Fired when the media for a playback ends.
*
* @event PLAYBACK_ENDED
* @param {String} name the name of the playback
*/
Events.PLAYBACK_ENDED = 'playback:ended'
/**
* Fired when user requests `play()`
*
* @event PLAYBACK_PLAY_INTENT
*/
Events.PLAYBACK_PLAY_INTENT = 'playback:play:intent'
/**
* Fired when the media for a playback starts playing.
* This is not necessarily when the user requests `play()`
* The media may have to buffer first.
* I.e. `isPlaying()` might return `true` before this event is fired,
* because `isPlaying()` represents the intended state.
*
* @event PLAYBACK_PLAY
*/
Events.PLAYBACK_PLAY = 'playback:play'
/**
* Fired when the media for a playback pauses.
*
* @event PLAYBACK_PAUSE
*/
Events.PLAYBACK_PAUSE = 'playback:pause'
/**
* Fired when the media for a playback is seeking.
*
* @event PLAYBACK_SEEK
*/
Events.PLAYBACK_SEEK = 'playback:seek'
/**
* Fired when the media for a playback is seeked.
*
* @event PLAYBACK_SEEKED
*/
Events.PLAYBACK_SEEKED = 'playback:seeked'
/**
* Fired when the media for a playback is stopped.
*
* @event PLAYBACK_STOP
*/
Events.PLAYBACK_STOP = 'playback:stop'
/**
* Fired if an error occurs in the playback.
*
* @event PLAYBACK_ERROR
* @param {Object} error An object containing the error details
* @param {String} name Playback name
*/
Events.PLAYBACK_ERROR = 'playback:error'
// TODO doc
Events.PLAYBACK_STATS_ADD = 'playback:stats:add'
// TODO doc
Events.PLAYBACK_FRAGMENT_LOADED = 'playback:fragment:loaded'
// TODO doc
Events.PLAYBACK_LEVEL_SWITCH = 'playback:level:switch'
/**
* Fired when subtitle is available on playback for display
*
* @event PLAYBACK_SUBTITLE_AVAILABLE
*/
Events.PLAYBACK_SUBTITLE_AVAILABLE = 'playback:subtitle:available'
/**
* Fired when playback subtitle track has changed
*
* @event CONTAINER_SUBTITLE_CHANGED
* @param {Object} track Data
* track object
* @param {Number} [track.id]
* selected track id
*/
Events.PLAYBACK_SUBTITLE_CHANGED = 'playback:subtitle:changed'
/**
* Fired when audio tracks are available to be used on the playback
* @event PLAYBACK_AUDIO_AVAILABLE
* @param {import('../playback/playback').AudioTrack[]} tracks - list of available audio tracks
*/
Events.PLAYBACK_AUDIO_AVAILABLE = 'playback:audio:available'
/**
* Fired whenever the current audio track has changed
* @event PLAYBACK_AUDIO_CHANGED
* @param {import('../playback/playback').AudioTrack} track - audio track active after change
*/
Events.PLAYBACK_AUDIO_CHANGED = 'playback:audio:changed'
// Core Events
/**
* Fired when the containers are created
*
* @event CORE_CONTAINERS_CREATED
*/
Events.CORE_CONTAINERS_CREATED = 'core:containers:created'
/**
* Fired when the active container changed
*
* @event CORE_ACTIVE_CONTAINER_CHANGED
*/
Events.CORE_ACTIVE_CONTAINER_CHANGED = 'core:active:container:changed'
/**
* Fired when the options were changed for the core
*
* @event CORE_OPTIONS_CHANGE
* @param {Object} new options provided to configure() method
*/
Events.CORE_OPTIONS_CHANGE = 'core:options:change'
/**
* Fired after creating containers, when the core is ready
*
* @event CORE_READY
*/
Events.CORE_READY = 'core:ready'
/**
* Fired when the fullscreen state change
*
* @event CORE_FULLSCREEN
* @param {Boolean} whether or not the player is on fullscreen mode
*/
Events.CORE_FULLSCREEN = 'core:fullscreen'
/**
* Fired when core updates size
*
* @event CORE_RESIZE
* @param {Object} currentSize an object with the current size
*/
Events.CORE_RESIZE = 'core:resize'
/**
* Fired when the screen orientation has changed.
* This event is trigger only for mobile devices.
*
* @event CORE_SCREEN_ORIENTATION_CHANGED
* @param {Object} screen An object with screen orientation
* screen object
* @param {Object} [screen.event]
* window resize event object
* @param {String} [screen.orientation]
* screen orientation (ie: 'landscape' or 'portrait')
*/
Events.CORE_SCREEN_ORIENTATION_CHANGED = 'core:screen:orientation:changed'
/**
* Fired when occurs mouse move event on core element
*
* @event CORE_MOUSE_MOVE
* @param {Object} event a DOM event
*/
Events.CORE_MOUSE_MOVE = 'core:mousemove'
/**
* Fired when occurs mouse leave event on core element
*
* @event CORE_MOUSE_LEAVE
* @param {Object} event a DOM event
*/
Events.CORE_MOUSE_LEAVE = 'core:mouseleave'
// Container Events
/**
* Fired when the container internal state changes
*
* @event CONTAINER_PLAYBACKSTATE
* @param {Object} state Data
* state object
* @param {String} [state.type]
* the playback type
*/
Events.CONTAINER_PLAYBACKSTATE = 'container:playbackstate'
Events.CONTAINER_PLAYBACKDVRSTATECHANGED = 'container:dvr'
/**
* Fired when the container updates its bitrate
*
* @event CONTAINER_BITRATE
* @param {Object} bitrate Data
* bitrate object
* @param {Number} [bitrate.bandwidth]
* bitrate bandwidth when it's available
* @param {Number} [bitrate.width]
* playback width (ex: 720, 640, 1080)
* @param {Number} [bitrate.height]
* playback height (ex: 240, 480, 720)
* @param {Number} [bitrate.level]
* playback level when it's available, it could be just a map for width (0 => 240, 1 => 480, 2 => 720)
*/
Events.CONTAINER_BITRATE = 'container:bitrate'
Events.CONTAINER_STATS_REPORT = 'container:stats:report'
Events.CONTAINER_DESTROYED = 'container:destroyed'
/**
* Fired when the container is ready
*
* @event CONTAINER_READY
*/
Events.CONTAINER_READY = 'container:ready'
/**
* Fired when the container was resized.
*
* Some fullscreen modes won't trigger this resize since they don't affect the container, only the playback contents.
*
* @event CONTAINER_RESIZE
*/
Events.CONTAINER_RESIZE = 'container:resize'
Events.CONTAINER_ERROR = 'container:error'
/**
* Fired when the container loaded its metadata
*
* @event CONTAINER_LOADEDMETADATA
* @param {Object} metadata Data
* settings object
* @param {Number} [metadata.duration]
* the playback duration
* @param {Object} [metadata.data]
* extra meta data
*/
Events.CONTAINER_LOADEDMETADATA = 'container:loadedmetadata'
/**
* Fired when subtitle is available on container for display
*
* @event CONTAINER_SUBTITLE_AVAILABLE
*/
Events.CONTAINER_SUBTITLE_AVAILABLE = 'container:subtitle:available'
/**
* Fired when subtitle track has changed
*
* @event CONTAINER_SUBTITLE_CHANGED
* @param {Object} track Data
* track object
* @param {Number} [track.id]
* selected track id
*/
Events.CONTAINER_SUBTITLE_CHANGED = 'container:subtitle:changed'
/**
* Fired when audio tracks are available to be used on the container
* @event CONTAINER_AUDIO_AVAILABLE
* @param {import('../playback/playback').AudioTrack[]} tracks - list of available audio tracks
*/
Events.CONTAINER_AUDIO_AVAILABLE = 'container:audio:available'
/**
* Fired whenever the current audio track has changed
* @event CONTAINER_AUDIO_CHANGED
* @param {import('../playback/playback').AudioTrack} track - audio track active after change
*/
Events.CONTAINER_AUDIO_CHANGED = 'container:audio:changed'
/**
* Fired when the time is updated on container
*
* @event CONTAINER_TIMEUPDATE
* @param {Object} progress Data
* progress object
* @param {Number} [progress.current]
* current time (in seconds)
* @param {Number} [progress.total]
* total time (in seconds)
*/
Events.CONTAINER_TIMEUPDATE = 'container:timeupdate'
/**
* Fired when the container is downloading the media
*
* @event CONTAINER_PROGRESS
* @param {Object} progress Data
* progress object
* @param {Number} [progress.start]
* initial downloaded content
* @param {Number} [progress.current]
* current dowloaded content
* @param {Number} [progress.total]
* total content to be downloaded
*/
Events.CONTAINER_PROGRESS = 'container:progress'
Events.CONTAINER_PLAY = 'container:play'
Events.CONTAINER_STOP = 'container:stop'
Events.CONTAINER_PAUSE = 'container:pause'
Events.CONTAINER_ENDED = 'container:ended'
Events.CONTAINER_CLICK = 'container:click'
Events.CONTAINER_DBLCLICK = 'container:dblclick'
Events.CONTAINER_CONTEXTMENU = 'container:contextmenu'
Events.CONTAINER_MOUSE_ENTER = 'container:mouseenter'
Events.CONTAINER_MOUSE_LEAVE = 'container:mouseleave'
Events.CONTAINER_MOUSE_UP = 'container:mouseup'
Events.CONTAINER_MOUSE_DOWN = 'container:mousedown'
/**
* Fired when the container enters on Picture-in-Picture mode
* @event CONTAINER_PIP_ENTER
*/
Events.CONTAINER_PIP_ENTER = 'container:picture-in-picture:enter'
/**
* Fired when the container exits from Picture-in-Picture mode
* @event CONTAINER_PIP_EXIT
*/
Events.CONTAINER_PIP_EXIT = 'container:picture-in-picture:exit'
/**
* Fired when the container seeks the video
*
* @event CONTAINER_SEEK
* @param {Number} time the current time in seconds
*/
Events.CONTAINER_SEEK = 'container:seek'
/**
* Fired when the container was finished the seek video
*
* @event CONTAINER_SEEKED
* @param {Number} time the current time in seconds
*/
Events.CONTAINER_SEEKED = 'container:seeked'
Events.CONTAINER_VOLUME = 'container:volume'
Events.CONTAINER_FULLSCREEN = 'container:fullscreen'
/**
* Fired when container is buffering
*
* @event CONTAINER_STATE_BUFFERING
*/
Events.CONTAINER_STATE_BUFFERING = 'container:state:buffering'
/**
* Fired when the container filled the buffer
*
* @event CONTAINER_STATE_BUFFERFULL
*/
Events.CONTAINER_STATE_BUFFERFULL = 'container:state:bufferfull'
/**
* Fired when the container changes any settings (volume, seek and etc)
*
* @event CONTAINER_SETTINGSUPDATE
*/
Events.CONTAINER_SETTINGSUPDATE = 'container:settingsupdate'
/**
* Fired when container updates its video quality
*
* @event CONTAINER_HIGHDEFINITIONUPDATE
* @param {Boolean} isHD
* true when is on HD, false otherwise
*/
Events.CONTAINER_HIGHDEFINITIONUPDATE = 'container:highdefinitionupdate'
/**
* Fired when the media control shows
*
* @event CONTAINER_MEDIACONTROL_SHOW
*/
Events.CONTAINER_MEDIACONTROL_SHOW = 'container:mediacontrol:show'
/**
* Fired when the media control hides
*
* @event CONTAINER_MEDIACONTROL_HIDE
*/
Events.CONTAINER_MEDIACONTROL_HIDE = 'container:mediacontrol:hide'
Events.CONTAINER_MEDIACONTROL_DISABLE = 'container:mediacontrol:disable'
Events.CONTAINER_MEDIACONTROL_ENABLE = 'container:mediacontrol:enable'
Events.CONTAINER_STATS_ADD = 'container:stats:add'
/**
* Fired when the options were changed for the container
*
* @event CONTAINER_OPTIONS_CHANGE
*/
Events.CONTAINER_OPTIONS_CHANGE = 'container:options:change'
// MediaControl Events
Events.MEDIACONTROL_RENDERED = 'mediacontrol:rendered'
/**
* Fired when the player enters/exit on fullscreen
*
* @event MEDIACONTROL_FULLSCREEN
*/
Events.MEDIACONTROL_FULLSCREEN = 'mediacontrol:fullscreen'
/**
* Fired when the media control shows
*
* @event MEDIACONTROL_SHOW
*/
Events.MEDIACONTROL_SHOW = 'mediacontrol:show'
/**
* Fired when the media control hides
*
* @event MEDIACONTROL_HIDE
*/
Events.MEDIACONTROL_HIDE = 'mediacontrol:hide'
/**
* Fired when mouse enters on the seekbar
*
* @event MEDIACONTROL_MOUSEMOVE_SEEKBAR
* @param {Object} event
* the javascript event
*/
Events.MEDIACONTROL_MOUSEMOVE_SEEKBAR = 'mediacontrol:mousemove:seekbar'
/**
* Fired when mouse leaves the seekbar
*
* @event MEDIACONTROL_MOUSELEAVE_SEEKBAR
* @param {Object} event
* the javascript event
*/
Events.MEDIACONTROL_MOUSELEAVE_SEEKBAR = 'mediacontrol:mouseleave:seekbar'
/**
* Fired when the media is being played
*
* @event MEDIACONTROL_PLAYING
*/
Events.MEDIACONTROL_PLAYING = 'mediacontrol:playing'
/**
* Fired when the media is not being played
*
* @event MEDIACONTROL_NOTPLAYING
*/
Events.MEDIACONTROL_NOTPLAYING = 'mediacontrol:notplaying'
/**
* Fired when the container was changed
*
* @event MEDIACONTROL_CONTAINERCHANGED
*/
Events.MEDIACONTROL_CONTAINERCHANGED = 'mediacontrol:containerchanged'
/**
* Fired when the options were changed for the mediacontrol
*
* @event MEDIACONTROL_OPTIONS_CHANGE
*/
Events.MEDIACONTROL_OPTIONS_CHANGE = 'mediacontrol:options:change'