VideoPlayerMediaSource class

A media source that outputs the playback of a video file. Provides methods for controlling the video playback.

Signature:

export declare class VideoPlayerMediaSource extends O3hMediaSource 

Extends: O3hMediaSource

Remarks

Use MediaSourceManager.createVideoPlayerSource() to create an instance of this class.

Methods

MethodModifiersDescription
getCurrentTime()Returns the current playback time position in the video.
getTimer()Returns an object implementing ITimer that acts as a proxy to the video player.
getTimeUpdates()Observe changes to the video playback time position.
getVideoLength()Returns the duration of the video.
loadVideo(assetOrUrl)Load the video and wait for it to be ready to be played.
pause()Pause video playback.
play()Plays the video loaded into this media source.
reset()Resets the playback position and speed of the video source to their original values. Does not unload the video.
resume()Resume video playback if paused.
seek(time)Seek the video to the given time between 0 and the length of the video.
setAudioVolume(volume)Set the volume of the video player audio.
setLooping(loop)Control if the video player loops when reaching the end or not
setPlaybackSpeed(speed)Control the speed at which the video plays, relative to it's normal playback rate.
stop()Stops the currently playing video.

VideoPlayerMediaSource.getCurrentTime() method

Returns the current playback time position in the video.

Signature:

getCurrentTime(): Promise<number>;

Returns:

Promise<number>

A promise that resolves with the current video time in milliseconds.

VideoPlayerMediaSource.getTimer() method

Returns an object implementing ITimer that acts as a proxy to the video player.

Signature:

getTimer(): Promise<ITimer>;

Returns:

Promise<ITimer>

Remarks

Calls on the returned object such as ITimer.start(), ITimer.stop() and ITimer.getTime() will perform the corresponding action on the player. The timer can also be used to create a ReplayRecorder to record replay data synced to the video time.

VideoPlayerMediaSource.getTimeUpdates() method

Observe changes to the video playback time position.

Signature:

getTimeUpdates(): Subject<number>;

Returns:

Subject<number>

A Subject that can be used to subscribe to changes to the video playback time position. It will be updated with the latest time in milliseconds on every frame.

VideoPlayerMediaSource.getVideoLength() method

Returns the duration of the video.

Signature:

getVideoLength(): Promise<number>;

Returns:

Promise<number>

A promise that resolves with the video duration in milliseconds.

VideoPlayerMediaSource.loadVideo() method

Load the video and wait for it to be ready to be played.

Signature:

loadVideo(assetOrUrl: VideoAsset | string): Promise<void>;

Parameters

ParameterTypeDescription
assetOrUrlVideoAsset | stringA VideoAsset, an absolute URL of a video, or a relative path to a static video delivered with your module (relative to your index.html)

Returns:

Promise<void>

A promise that resolves when the video is loaded and ready to be played

Remarks

Use VideoAsset.getVideoPath() to get the path of a video asset. This call can take more than half a second to run, try to perform this operation behind the scenes.

VideoPlayerMediaSource.pause() method

Pause video playback.

Signature:

pause(): void;

Returns:

void

VideoPlayerMediaSource.play() method

Plays the video loaded into this media source.

Signature:

play(): Promise<void>;

Returns:

Promise<void>

A promise that resolves when the video has reached the end and finished playing. This promise will never resolve if video playback is set to loop.

Remarks

This must not be called before VideoPlayerMediaSource.loadVideo().

VideoPlayerMediaSource.reset() method

Resets the playback position and speed of the video source to their original values. Does not unload the video.

Signature:

reset(): Promise<void>;

Returns:

Promise<void>

A promise that resolves when the video has seeked to its start time.

VideoPlayerMediaSource.resume() method

Resume video playback if paused.

Signature:

resume(): void;

Returns:

void

VideoPlayerMediaSource.seek() method

Seek the video to the given time between 0 and the length of the video.

Signature:

seek(time: number): Promise<void>;

Parameters

ParameterTypeDescription
timenumberThe video player's time position in milliseconds

Returns:

Promise<void>

A promise that resolves when the seek operation is complete

VideoPlayerMediaSource.setAudioVolume() method

Set the volume of the video player audio.

Signature:

setAudioVolume(volume: number): void;

Parameters

ParameterTypeDescription
volumenumberThe desired video playback volume, with values between 0 and 1. Volume defaults to 1 if this isn't called

Returns:

void

VideoPlayerMediaSource.setLooping() method

Control if the video player loops when reaching the end or not

Signature:

setLooping(loop: boolean): void;

Parameters

ParameterTypeDescription
loopbooleanEnable or disable looping of the video

Returns:

void

VideoPlayerMediaSource.setPlaybackSpeed() method

Control the speed at which the video plays, relative to it's normal playback rate.

Signature:

setPlaybackSpeed(speed: number): void;

Parameters

ParameterTypeDescription
speednumberA fraction of 1. ie: 2 plays at twice normal speed and 0.5 half the normal speed

Returns:

void

Remarks

Values larger then 2 or smaller then -2 will cause the video to skip between key frames instead of providing smooth playback.

VideoPlayerMediaSource.stop() method

Stops the currently playing video.

Signature:

stop(): void;

Returns:

void