GuidesAPI ReferenceRelease Notes
HomeLog InHome
Guides

View-Based Inline Player Methods & APIs

This section covers all available methods for controlling the view-based inline player, managing states, and handling playback.

Methods

embedPlaceholder

method signature

fun embedPlaceholder()

Creates placeholder view from the viewing history if available.

Shows static preview representing user's last viewing session. Uses snapshot from last position or preview image.

When to call:

  • Loading feed item that was previously viewed
  • Transitioning from active player to preview
  • Implementing lazy loading for performance

State behavior:

  • From active player → Dismiss player, shows placeholder
  • From empty → Creates placeholder directly

Result: Static preview with click interaction, no resource consumption

embedPlayer

method signature

fun embedPlayer(shouldAutoPlayOnStart: Boolean)

Embeds an active player in the inline container.

Replaces any existing placeholder with a functional video player.

When to call:

  • User clicks placeholder to start playback
  • Programmatically activating player in feed
  • Restoring player after configuration changes

State behavior:

  • From placeholder → Creates active player
  • From empty → Creates player directly

Result: Player ready for immediate interaction and playback

Parameters:

  • shouldAutoPlayOnStart: Whether the player should automatically start playback when embedded

resetToPlaceholder

method signature

fun resetToPlaceholder()

Resets inline container to clean placeholder state.

Removes active player and creates fresh placeholder with updated viewing data.

When to call:

  • User dismisses or closes player
  • Scrolling away for resource cleanup

State behavior:

  • From active player → Removes player, creates fresh placeholder

Resource management: Stops playback, releases resources, saves viewing progress

Result: Updated placeholder with latest progress, resources released

disposeContainer

method signature

fun disposeContainer()

Disposes the inline container and releases all resources.

Permanently cleans up the container, releasing all players, placeholders, and associated resources.

When to call:

  • Container no longer needed
  • Fragment/Activity destruction
  • Memory cleanup operations
  • Permanent removal from feed

What happens:

  • Stops all active playback
  • Releases all media resources
  • Clears viewing records and cache
  • Removes all views from inline container
  • Cancels ongoing operations

Result: Inline container fully disposed, all resources released

resumePlayer

method signature

fun resumePlayer()

Resumes player playback and removes any pause lock.

Resumes playback and allows normal lifecycle events and other controls to manage the player state again. Removes any "pause lock" created by pausePlayer().

Behavior after resume:

  • Player starts playing immediately
  • Lifecycle events can pause/resume the player normally
  • Other programmatic controls work normally
  • User can pause/resume if UI interaction is enabled

Use cases: Item becomes visible, app returns from background, autoplay scenarios

pausePlayer

method signature

fun pausePlayer()

Pauses player playback and creates a "pause lock".

Pauses the player and prevents it from resuming until either:

  • resumePlayer() is called programmatically, OR
  • User manually resumes (only if UI interaction is not blocked)

Pause lock behavior:

  • Lifecycle events cannot resume the player
  • Other programmatic events cannot resume the player
  • Player stays paused until explicitly unlocked

Lock can be removed by:

  • Calling resumePlayer() programmatically
  • User manual resume (if blockInteraction() not active)

Use cases: Item scrolls away, app goes to background, resource conservation

blockInteraction

method signature

fun blockInteraction()

Blocks user interaction with player controls.

Disables all player UI controls while preserving current playback state. When blocked, users cannot override pausePlayer()/resumePlayer() calls. Programmatic control methods still work. Use unblockInteraction() to restore.

Use cases: Loading states, preview-only mode, programmatic sequences

unblockInteraction

method signature

fun unblockInteraction()

Restores user interaction with player controls.

Re-enables all player UI controls after blockInteraction(). Users can now manually override pausePlayer()/resumePlayer() states.

Use cases: After loading completes, transitioning to interactive mode

enterFullScreen

method signature

fun enterFullScreen()

Enters full screen player mode.

This method is used to switch the player to full screen mode if it's currently in inline mode.

onVolumeChanged

method signature

fun onVolumeChanged()

Notifies the player of volume changes.

Updates player's internal volume state and UI indicators. Call when detecting volume key presses or programmatic volume changes.

Use cases: Volume key events, audio focus changes, programmatic volume updates

For more information about implementing volume change detection, see the Player Audio section below.

Static Methods

prepareVideos

method signature

fun prepareVideos(
    containerId: String,
    dataSource: BlazeDataSourceType,
    shouldOrderContentsByReadStatus: Boolean = true,
    cachePolicyLevel: BlazeCachingLevel = BlazeSDK.cachingLevel
)

Prepare video content for a specific dataSource type - static method.

This static method preloads videos for the given dataSource, which is built using BlazeDataSourceType.

Important: BlazeRecommendationsType.FOR_YOU is unsupported for preparation and throws a onDataLoadComplete error. This type of data source should be used only to play content directly, using the embedPlayer method.

Parameters:

  • containerId: Represents the identifier of the Blaze Player Container. This identifier MUST be unique per instance in the app.
  • dataSource: Represents the dataSourceType associated with the Blaze Player Container. dataSourceType is built with BlazeDataSourceType.
  • shouldOrderContentsByReadStatus: Controls whether videos should be ordered by their read status. Takes effect only when repository is clean/fresh (after disposal, first load, or when data source changes). During normal operations, content order remains stable regardless of this setting. Defaults to true.
  • cachePolicyLevel: Represents the cache policy level of the Blaze Player Container. Defaults to The policy level that was defined in the global level.

Usage

You can prepare the content in advance, from any context you would like (i.e., call this from host Activity, so when user enters the Container tab, content will already be fetched).

Example:

BlazeVideosInlinePlayer.prepareVideos(
    containerId = "video-player-unique-id",
    dataSource = BlazeDataSourceType.Labels(BlazeWidgetLabel.singleLabel("videos"))
)

IMPORTANT - Player Audio

To preserve the 'out-of-the-box' behavior regarding mute/unmute (i.e., when the user increases/decreases his device volume, the mute/unmute state of the player behaves accordingly) - application developers must include the following code in the player host Activity:

override fun onKeyUp(keyCode: Int, event: KeyEvent?): Boolean {
    return if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
        // videosInlinePlayer should be assigned with the BlazeVideosInlinePlayer instance.
        videosInlinePlayer.onVolumeChanged()
        true
    } else {
        super.onKeyUp(keyCode, event)
    }
}

The SDK will handle the player's audio behavior after onVolumeChanged is called.


Did this page help you?