onPlayerEvents([callback], [remove])
Class: MediaPlayer.
Description:
Registers, unregisters, and gets an Array of event handlers for the MediaPlayer.
Parameters:
| Name | Type | Description |
|---|---|---|
|
|
function |
Handler function receiving PlayerEvent object. Pass |
|
|
boolean |
Set to |
Returns:
Returns this component instance if adding or removing the handler, otherwise returns an array of added handler functions.
Type: MediaPlayer | Array.<function()>
Examples:
// Example of PlayerEvent object
PlayerEvent {
type: string, // One of: `loadstart`, `loadedmetadata`, `seeking`, `timeupdate`, `play`, `stop`.
mediaType: string, // The type of media that is set to play in the player. One of: `File`, `InputDevice`, `URL`.
media: Media, // A Media formatted object that contains details about loaded media.
currentTime: number, // Current play time.
duration: number, // Duration of the media in seconds. When event type is `timeupdate`.
reason: string, // Reason for stopping: `Control`, `EndOfMediaFile`, `EndOfAudioStream`, `EndOfVideoStream`, `EndOfErrorStream`, `Error`
}
// Example of a Media object
Media {
duration: number, // Duration of the media in seconds. Present unless it's a live stream.
videoStreams: VideoStream[], // An array of detailed information about each available video stream.
audioStreams: AudioStream[], // An array of detailed information about each available audio stream.
subtitleStreams: SubtitleStream[], // An array of detailed information about each available subtitle stream.
}
// Example of a VideoStream object
VideoStream {
sampleWidth: number,
sampleHeight: number,
width: number,
height: number,
pixelAspectRatio: string,
displayAspectRatio: string,
frameRate: number,
codec: string,
pixelFormat: string,
progressive: boolean,
default: boolean
}
// Example of a AudioStream object
AudioStream {
sampleRate: number,
channels: number,
bitDepth: number,
codec: string,
default: boolean
}
// Example of a SubtitleStream object
SubtitleStream {
language: string,
codec: string,
default: boolean
}
