OGPlayer

interface OGPlayer

The ogplayer playback engine.

Create instances with OGPlayer.Builder. All methods must be called from the application main thread. Call release when done.

Types

Link copied to clipboard
class Builder(context: Context)
Link copied to clipboard
object Companion

Properties

Link copied to clipboard
abstract val adCuePositionsMs: List<Long>

Content positions of upcoming (unplayed) ad breaks in milliseconds — the cue markers a scrub bar renders. Postrolls report the content duration. Empty when no ad schedule is loaded.

Link copied to clipboard
abstract val audioTracks: List<AudioTrack>

Audio tracks (languages/audio descriptions) of the current media.

Link copied to clipboard
abstract val bufferedPositionMs: Long

Buffered position in the current media, in milliseconds.

Link copied to clipboard

The cast connector this player was built with, if any.

Link copied to clipboard
abstract val castDeviceName: String?

Friendly name of the connected cast device, null when not connected.

Link copied to clipboard
abstract val castState: CastState

Receiver connection state (NOT_CONNECTED when no connector is set).

Link copied to clipboard
abstract val currentItem: OGMediaItem?

The currently loaded media item, if any.

Link copied to clipboard
abstract val currentPositionMs: Long

Current playback position in milliseconds.

Link copied to clipboard
abstract val durationMs: Long

Duration of the current media in milliseconds, or 0 when unknown.

Link copied to clipboard
abstract val engine: Any

Handle to the underlying playback engine, for SDK-internal wiring only.

Link copied to clipboard
abstract val hasThumbnails: Boolean

Whether the current media item has a trick-play thumbnail track.

Link copied to clipboard
abstract val isCasting: Boolean

True while playback runs on a cast receiver instead of this device.

Link copied to clipboard
abstract val isLicensed: Boolean

True when a valid, unexpired license key bound to this app was set. SDK-internal: read by the UI to gate the unlicensed-build watermark.

Link copied to clipboard
abstract val isMuted: Boolean

Whether the player is muted. Muting preserves the previous volume.

Link copied to clipboard
abstract val isPlaying: Boolean

Whether playback is actively progressing.

Link copied to clipboard
abstract val isPlayingAd: Boolean

Whether an ad is currently playing (content is paused underneath).

Link copied to clipboard
abstract val liveInfo: LiveInfo?

Live-stream facts (window, edge, latency), or null while playing VOD.

Link copied to clipboard
abstract val playbackSpeed: Float

Current playback speed (1.0 = normal).

Link copied to clipboard

Amount applied by seekBackward, in milliseconds.

Link copied to clipboard

Amount applied by seekForward, in milliseconds.

Link copied to clipboard
abstract val state: PlaybackState

Current high-level playback state.

Link copied to clipboard

Current caption rendering style.

Link copied to clipboard
abstract val textTracks: List<TextTrack>

Subtitle/caption tracks of the current media (embedded + sideloaded).

Link copied to clipboard

Video renditions of the current media, highest first.

Link copied to clipboard
abstract val volume: Float

Player volume in 0..1 (independent of device volume).

Link copied to clipboard

How the volume slider behaves; see VolumeControlMode. Default VolumeControlMode.DEVICE — the hardware volume buttons move the slider.

Functions

Link copied to clipboard
abstract fun addAdListener(listener: AdListener)
Link copied to clipboard
Link copied to clipboard
abstract fun addListener(listener: PlaybackListener)
Link copied to clipboard
abstract fun clickAd()

Opens the current ad's clickthrough, firing the provider's click tracking (slot providers). No-op for IMA, which handles its own click UI, or when no ad is playing.

Link copied to clipboard
abstract suspend fun getThumbnail(positionMs: Long): Bitmap?

Loads the trick-play thumbnail for positionMs, or null when the item has no thumbnail track or loading fails. Safe to call while scrubbing; sprite sheets are cached internally.

Link copied to clipboard
abstract fun load(item: OGMediaItem, startPositionMs: Long = 0, playWhenReady: Boolean = true)

Loads item and prepares playback.

Link copied to clipboard
abstract fun pause()
Link copied to clipboard
abstract fun play()
Link copied to clipboard
abstract fun release()

Releases the underlying engine. The instance cannot be reused afterwards.

Link copied to clipboard
abstract fun removeAdListener(listener: AdListener)
Link copied to clipboard
Link copied to clipboard
abstract fun removeListener(listener: PlaybackListener)
Link copied to clipboard
abstract fun retry()

Reloads the last loaded item after a fatal error — VOD resumes at the last healthy playback position, live streams rejoin at the edge. The built-in error overlay's Retry button calls this; custom UIs can too. No-op before the first load.

Link copied to clipboard
abstract fun seekBackward()

Seeks backward by the configured increment (default 10s).

Link copied to clipboard
abstract fun seekForward()

Seeks forward by the configured increment (default 10s).

Link copied to clipboard
abstract fun seekTo(positionMs: Long)

Seeks to positionMs within the current media.

Link copied to clipboard
abstract fun seekToLiveEdge()

Seeks to the live edge (or default position) of the current media.

Link copied to clipboard
abstract fun selectAudioTrack(id: String)

Selects the audio track with the given AudioTrack.id.

Link copied to clipboard
abstract fun selectTextTrack(id: String?)

Selects the text track with the given TextTrack.id, or disables subtitles when null.

Link copied to clipboard
abstract fun selectVideoQuality(id: String?)

Pins playback to the rendition with the given VideoQuality.id, or returns to adaptive selection (Auto) when null.

Link copied to clipboard
abstract fun setAdViewGroup(viewGroup: Any?)

SDK-internal: the view group ads render into (set by OGPlayerView). Accepts a Media3 AdViewProvider or a plain ViewGroup.

Link copied to clipboard
abstract fun setMuted(muted: Boolean)

Mutes or unmutes without losing the previous volume.

Link copied to clipboard
abstract fun setPlaybackSpeed(speed: Float)

Sets the playback speed; speed must be positive.

Link copied to clipboard
abstract fun setSlotAdViewGroup(viewGroup: ViewGroup?)

SDK-internal: the ViewGroup slot-ad providers render into (set by OGPlayerView). Distinct from setAdViewGroup, which feeds the Media3/IMA ad view path.

Link copied to clipboard
abstract fun setSubtitleStyle(style: SubtitleStyle)

Sets the caption rendering style, applied immediately.

Link copied to clipboard
abstract fun setVolume(volume: Float)

Sets the player volume; volume is clamped to 0..1.

Link copied to clipboard
abstract fun skipAd()

Skips the currently playing ad, if it is skippable. No-op when no ad is playing or no ads provider is set. Whether a programmatic skip is honored is provider-dependent (see the ads module's documentation).