A representation of an event to be triggered during
a rendered MediaUnit
, at specific timestamps.
Extend this class to create custom media events.
Constructor
new MediaEvent() → {MediaEvent}
Constructs a MediaOverlay
instance.
Members
(readonly) emitter :EventEmitter
Event emitter. Use this to subscribe to event state changes
Example
event.emitter.on('stateUpdate', () => console.log(`Event state changed to ${event.state}`));
endPoint :string|number
The end time of the event. Accepts an absolute value in seconds or a percentage. Returns -1 if the value depends on the unit duration, which is currently not available.
(readonly) id :string
A unique identifier assigned by the system.
(readonly) parentUnit :MediaUnit
The MediaUnit
that owns the currently rendered overlay.
(readonly) player :MediaPlayer
Player instance currently rendering the overlay.
preloadInterval :number
How many seconds before scheduled start time should the event start preloading.
- Default Value:
-
-
5
-
repeatAfter :number
Set this to configure an event to be re-scheduled during the current playback session after it has finished rendering. Set to the number of seconds to repeat the event after. Set to -1 to disable repeating.
- Default Value:
-
-
-1
-
startPoint :string|number
The start time of the event. Accepts an absolute value in seconds or a percentage. Returns -1 if the value depends on the unit duration, which is currently not available.
state :EVENT_STATE
Current event state.
- Default Value:
-
-
EVENT_STATE.UNLOADED
-
timeout :number
How many seconds into preloading should the system give up and discard the event.
- Default Value:
-
-
10
-
trackingURLs :Object
A key-value store for tracking events and the associated URLs. GET requests are sent to the specified URLs when specific event lifecycle steps are triggered.
- See:
Example
event.trackingURLs = {
[EVENTS.LAUNCH]: 'https://analyticsservice.com/pixel',
[EVENTS.COMPLETE]: 'https://analyticsservice.com/pixel',
};
Methods
(async) .onPreload()
Method that gets invoked when the event starts preloading.
Override this in your MediaEvent
extension to do the work
that needs to be done when your event gets preloaded during
media playback.
(async) .onTrigger()
Method that gets invoked when the event starts.
Override this in your MediaEvent
extension to do the work
that needs to be done when your event gets performed during
media playback.