Methods

The Ravnur Media Player provides a comprehensive set of methods to control and manipulate media playback within web applications. Customize playback controls, dynamically load media sources, select quality levels, audio tracks, and more. This provides the flexibility and control needed to create interactive media experiences.

Usage
Most methods are accessed via the controller: player.controller.methodName(). Some methods are available directly on the player instance: player.methodName().

Controller Methods

These methods are accessed via player.controller and provide core playback control functionality.

MethodParametersReturnsDescription
getCurrentTime()-numberRetrieves the current playback time in seconds (includes timecode offset).
setCurrentTime(time, silent?)time: number, silent?: booleanvoidSets the playback position to the specified time in seconds. If silent is false, focuses the player.
isPaused()-booleanReturns true if the media is currently paused.
isEnded()-booleanReturns true if the media has reached the end or clip endpoint.
isMuted()-booleanReturns true if the player is currently muted.
play(silent?)silent?: booleanPromise<void>Initiates media playback. Returns a Promise that resolves when playback begins. If silent is false, focuses the player.
pause(silent?)silent?: booleanvoidPauses the current playback. If silent is false, focuses the player.
prevFrame()-voidSteps backward to the previous frame based on the configured frame rate.
nextFrame()-voidSteps forward to the next frame based on the configured frame rate.
getDuration()-number | nullRetrieves the total duration of the media in seconds (respects clip boundaries).
setMuted(muted, silent?)muted: boolean, silent?: booleanvoidSets the muted state of the player. If silent is false, focuses the player.
getVolume()-numberRetrieves the current volume level (0.0 to 1.0).
setVolume(volume, silent?)volume: number, silent?: booleanvoidSets the volume level (0.0 to 1.0). If silent is false, focuses the player.
getLevels()-any[]Retrieves all available quality levels for the current media.
getLevel()-anyRetrieves the currently active quality level.
setLevel(level)level: anyvoidSets the quality level. Pass the level object from getLevels().
isMultiQuality()-booleanReturns true if the media has multiple quality levels available.
isMultiAudioTracks()-booleanReturns true if the media has multiple audio tracks available.
getAudioTracks()-any[]Retrieves all available audio tracks.
getAudioTrack()-numberRetrieves the index of the currently active audio track.
setAudioTrack(index)index: numbervoidSets the active audio track by index.
load(sources)sources: PlayerSourcevoidLoads a new media source into the player.
getBufferedPercent()-numberRetrieves the percentage of media that has been buffered (0 to 100).
getElement()-HTMLVideoElement | HTMLAudioElementRetrieves the underlying HTML media element.
setPlaybackRate(rate)rate: numbervoidSets the playback speed. 1.0 is normal speed, 0.5 is half speed, 2.0 is double speed.
isLive()-booleanReturns true if the current media is a live stream.
goToLive()-voidJumps to the live edge of a live stream.
getTimeCode()-numberRetrieves the configured timecode offset in seconds.
focus()-voidFocuses the player element for keyboard interaction.

Player Methods

These methods are accessed directly on the player instance.

MethodParametersReturnsDescription
setup(playlist, options)playlist: PlayerSource | PlayerSource[], options?: Partial<PlayerInputOptions>voidInitializes the player with media source(s) and configuration options. Call this once to set up the player.
playPart(from?, to?, lazy?)from?: number, to?: number, lazy?: booleanvoidPlays a specific segment of the media. If lazy is true, does not auto-play.
refreshCrawlExtension(crawl, visibility?)crawl: PlayerCrawlOptions, visibility?: booleanvoidUpdates or creates the scrolling text crawl with new options.
changeFullScreenMode()-voidToggles fullscreen mode on/off.
changeLayout(lang, fontSize, location)lang: string, fontSize: PlayerCCFontSize, location: PlayerCCLocationvoidChanges the caption display layout settings.
isShownExtensions()-booleanReturns true if player controls/extensions are currently visible.
appearExtensions()-voidShows the player controls/extensions immediately.
disappearExtensions()-voidHides the player controls/extensions immediately.
destroy()-voidDestroys the player instance and cleans up all resources. Call this when removing the player.