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
open val currentAd: AdInfo?

SDK-internal: the ad currently rendering, null between ads and outside breaks.

Link copied to clipboard
abstract val currentItem: OGMediaItem?

The currently loaded media item, if any.

Link copied to clipboard

Index of the playing playlist item, or -1 without a playlist.

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

SDK-internal: whether the ad that is on screen is paused. Read by the chrome to seed its ad transport from the player's state (a view that attaches mid-break — an Activity recreate — never saw the events).

Link copied to clipboard

SDK-internal: whether the ads provider's own UI has a dialog open (IMA's "About this ad").

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 isLooping: Boolean

Whether the current item restarts automatically when it ends. Default false.

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

The upcoming playlist item, or null at the end / without a playlist.

Link copied to clipboard
abstract val playbackSpeed: Float

Current playback speed (1.0 = normal).

Link copied to clipboard
abstract val playlist: List<OGMediaItem>

The active playlist; empty when a single item was loaded.

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 sessionId: String?

Id of the current analytics session — a fresh UUID per load, stamped on every AnalyticsEvent of that load. Null before the first load.

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). While muted this reports the retained value, not 0 — isMuted alone signals silence (same model on every platform).

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 fun emitViewAnalytics(event: AnalyticsEvent)

Feeds a view-layer analytics event (AnalyticsEvent.FullscreenChanged, AnalyticsEvent.OrientationChanged, AnalyticsEvent.PictureInPictureChanged) into this player's analytics stream, session-stamped like every other event. Called by the SDK's own views — not host-app API.

Link copied to clipboard
open fun focusAdUi(): Boolean

SDK-internal: hands the remote's focus to the ads provider's own UI (IMA's skip button / "About this ad") — see com.ogplayer.api.ads.AdsProvider.focusUi.

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. Clears any active playlist.

Link copied to clipboard
abstract fun loadPlaylist(items: List<OGMediaItem>, startIndex: Int = 0, playWhenReady: Boolean = true)

Loads a playlist: items play in order, each item auto-advancing to the next when it completes (its postrolls included). The UI module's "Up next" countdown card renders during the configurable lead window before each transition; hosts that hide it get silent advancing. PlaybackListener.onPlaylistItemChanged fires on every transition, including the initial item.

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 setBufferRole(role: OGBufferRole)

Switches the buffering role of a player built with Builder.setStandbyBufferProfile — the vertical-feed pool keeps preloaded players on OGBufferRole.STANDBY and promotes the visible one to OGBufferRole.ACTIVE. No-op when no standby profile was configured.

Link copied to clipboard
abstract fun setLooping(looping: Boolean)

Enables or disables single-item looping. While looping the player never reaches the ENDED state — it seeks back to the start and keeps playing.

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. While muted the change lands on the retained value without unmuting.

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).

Link copied to clipboard
abstract fun skipToNext()

Skips to the next playlist item immediately (the "Up next" card's tap action). No-op without a next item.

Link copied to clipboard
abstract fun skipToPrevious()

Skips to the previous playlist item immediately (the TV chrome's "previous" button, the remote's previous-track key). No-op on the first item or without a playlist.