A representation of a single media entity, together with playback configuration and other settings, to be rendered by a player instance.
Constructor
new MediaUnit(url) → {MediaUnit}
Constructs a MediaUnit
instance.
Parameters:
-
url
( string )The media file URL.
Members
canReplay :boolean
Can media replay in the same playlist session? If true, the previous icon may be displayed in the control bar.
- Default Value:
-
-
true
-
controlsDisplay :CONTROLS_DISPLAY
Position of the controls bar.
- Default Value:
-
-
CONTROLS_DISPLAY.BOTTOM
-
controlsParameters :Object
Control bar configuration. See configuration docs.
(readonly) events :Array.<MediaEvent>
Array of events attached to the unit.
- Default Value:
-
-
[]
-
(readonly) id :string
A unique identifier assigned by the system.
initialPlaybackTime :number
Initial media playback time in seconds.
- Default Value:
-
-
0
-
manager :UnitManager
UnitManager
instance attached to this unit.
Use managers to implement custom media processing
workflows, like handling DRM or communicating with
backend services.
- See:
metadata :Object
Unit metadata information.
(readonly) overlays :Array.<MediaOverlay>
Array of overlays attached to the unit.
- Default Value:
-
-
[]
-
(readonly) player :MediaPlayer
Player instance currently rendering the unit.
shouldAutoplay :boolean
Should media autoplay?
- Default Value:
-
-
true
-
trackingURLs :Object
A key-value store for tracking events and the associated URLs. GET requests are sent to the specified URLs when specific media events are triggered.
- See:
Example
unit.trackingURLs = {
[EVENTS.LAUNCH]: 'https://analyticsservice.com/pixel',
[EVENTS.COMPLETE]: 'https://analyticsservice.com/pixel',
};
url :string
The media file URL.
Methods
.addEvent(event)
Add an event to the current unit.
Parameters:
-
event
( MediaEvent )The event to attach
.addEvents(events)
Add multiple events to the current unit.
Parameters:
-
events
( Array.<MediaEvent> )The events to attach
.addOverlay(overlay)
Add an overlay to the current unit.
Parameters:
-
overlay
( MediaOverlay )The overlay to attach
.addOverlays(overlays)
Add multiple overlays to the current unit.
Parameters:
-
overlays
( Array.<MediaOverlay> )The overlays to attach
.clearEvents()
Remove all attached events.
.clearOverlays()
Remove all attached overlays.