Skip to main content

Methods

Reference

play(): Promise<void>

Loads and starts playback of a media resource.

note

Promise is resolved when playback has been successfully started. Failure to begin playback for any reason, such as permission issues, result in the promise being rejected.

pause(issuer?: string): void

Pauses the current playback.

  • Issuer is 'api' by default if no value was specified.
  • You can pass 'ui' value, if you want to notify the player that the pause was caused by a user gesture.

Issuer of the pause affects some player features. For example, if a pause was caused by a user gesture, the player will show Exit Thumbnail instead of the regular one.

volume(value?: number): number

Returns or sets the volume level for audio portions of the media element. Volume should be set as a value between 0 and 100.

on(eventName: string, callbackFn: Function): void

Attaches an event listener to the player.

off(eventName: string, callbackFn: Function): void

Removes an event listener from the player.

muted(value?: boolean): boolean

Returns or sets a value that indicates whether the audio is muted.

currentTime(value?: number): number

Returns or sets the current playback position, in seconds.

duration(): number

Returns the duration in seconds of the current media resource. A NaN value is returned if duration is not available.

seek(value: number): void

Seeks the media to the specified time in seconds.

paused(): boolean

Returns a value that specifies whether playback is paused.

playing(): boolean

Returns a value that specifies whether playback is playing.

playbackRate(value?: number): number

Returns or sets the current rate of speed for the media resource to play. This speed is expressed as a multiple of the normal speed of the media resource.

isFullscreen(): boolean

Returns information about whether the player is in fullscreen mode or not.

ended(): boolean

Returns information about whether the playback has ended or not.

videoWidth(): number

Returns the intrinsic width of a video in CSS pixels, or zero if the dimensions are not known.

videoHeight(): number

Returns the intrinsic height of a video in CSS pixels, or zero if the dimensions are not known.

requestFullscreen(): Promise<void>

Requests the player to enter fullscreen mode.

exitFullscreen(): Promise<void>

Return the player to normal mode after been in fullscreen mode.