Skip to main content
Your SDK Description - Documentation

JavaScript SDK Docs JavaScript SDK Docs

UnitManager

Base unit management class. Extend this to create custom unit management functionality. This can be used to implement custom media processing workflows, like DRM.

Constructor

new UnitManager() → {UnitManager}

Construct a new UnitManager.

Example
class CustomManager extends UnitManager {
   run() {
     console.log('running');
     player.setCurrentURL(videoUrl);
   }

   end() {
     console.log('end');
   }
}

const unit = new MediaUnit(videoUrl);
unit.manager = new CustomManager();

Members

(readonly) player :NediaPlayer

Reference to the player instance rendering the unit attached to the manager. This is injected by the player and is accessible in any of the manager methods.

(readonly) unit :MediaUnit

Reference to the unit attached to the manager. This is injected by the player and is accessible in any of the manager methods.

Methods

.duration()

Override this method in your class to return a custom duration for the media element being managed.

(async) .end()

Override this method in your class to run custom code required when media playback ends.

(async) .run()

Override this method in your class to run custom code required to begin media playback. Note that when handling a MediaUnit with an attached manager, the player will NOT begin playing back the unit. The manager should update the current unit url or construct a new unit and add it to the playlist, and then finally instruct the player to start playing.

(async) .update()

Override this method in your class to run code that needs to be executed periodically by your manager. This method is invoked by the player every second while the attached unit is rendering.