GuidesAPI ReferenceRelease Notes
HomeLog InHome
Guides

View-Based Inline Player Overview

This section provides a technical overview of implementing inline video players using traditional Android Views and XML layouts.

Technical Architecture

The view-based implementation leverages the traditional Android View system with imperative programming patterns. It provides direct control over the player lifecycle and integrates seamlessly with existing Android applications.

Main Player Class

  • BlazeVideosInlinePlayer - Core player implementation
  • Constructor-based configuration with required parameters
  • Manages video playback, UI state, and container lifecycle

ViewGroup Integration

  • Embeds directly into any existing ViewGroup container
  • Works with all standard Android ViewGroup types
  • Maintains proper view hierarchy and z-ordering

Lifecycle Integration

  • Integrates with Android's lifecycle components
  • Provides resource management capabilities

Event System

  • Receive feedback and flow updates through BlazePlayerInInlineDelegate
  • Data loading events, fullscreen transitions, and user actions

State Overview

The player operates in three distinct states:

EMPTYPLACEHOLDERPLAYER

  • EMPTY: No content displayed, initial state
  • PLACEHOLDER: Static preview/thumbnail with click interaction
  • PLAYER: Active video player with full functionality

Implementation Approach

The view-based implementation follows traditional Android patterns with direct method calls and explicit state management.

1. Inline Container Creation

Create the inline container with required parameters and configuration:

val videosInlinePlayer = BlazeVideosInlinePlayer(
    lifecycleOwner = this,
    storeOwner = this,
    containerView = frameLayoutContainer,
    containerId = "unique-player-id",
    dataSource = dataSource,
    playerMode = playerMode,
    playerDelegate = playerDelegate
)

Required Parameters:

  • lifecycleOwner, storeOwner, containerView, containerId
  • Choose player mode (Preview or Interactive)
  • Set up event delegate for callbacks

Complete constructor details →

2. Inline Container Control

After creation, control the container through direct method calls:

// Embedding control
videosInlinePlayer.embedPlaceholder()
videosInlinePlayer.embedPlayer(shouldAutoPlayOnStart = true)
videosInlinePlayer.resetToPlaceholder()

// Playback control
videosInlinePlayer.pausePlayer()
videosInlinePlayer.resumePlayer()
videosInlinePlayer.blockInteraction()

Complete methods documentation →

3. Event Handling

Receive feedback about container flow and user actions:

val playerDelegate = object : BlazePlayerInInlineDelegate {
    override fun onPlaceholderClicked(playerType: BlazePlayerType, sourceId: String?) {
        // Called when placeholder is clicked in Preview mode
        // Fullscreen player opens automatically, returns to placeholder when closed
    }
    
    override fun onPlayerDidEnterFullScreen(playerType: BlazePlayerType, sourceId: String?) {
        // Called when player enters fullscreen mode
    }
    
    // Additional callbacks for data loading, state changes, etc.
}

Note: Placeholder is only clickable in Preview mode. In Interactive mode, placeholder has no click behavior.

Complete delegate documentation →

4. Resource Disposal

⚠️ Always dispose the container when no longer needed:

override fun onDestroy() {
    videosInlinePlayer.disposeContainer()
    super.onDestroy()
}

This prevents memory leaks and ensures proper resource cleanup.

Container State Flow

Common Usage Patterns

// Start with placeholder (recommended for feeds)
videosInlinePlayer.embedPlaceholder()  // EMPTY → PLACEHOLDER

// When you want to show active player (user scrolled into view, clicked item, etc.)
videosInlinePlayer.embedPlayer(shouldAutoPlayOnStart = true)  // PLACEHOLDER → PLAYER

// When user scrolls away or you want to save resources
videosInlinePlayer.resetToPlaceholder()  // PLAYER → PLACEHOLDER

// When completely done (onDestroy, item removed, etc.)
videosInlinePlayer.disposeContainer()  // Any state → EMPTY

Usage Patterns

The view-based implementation provides complete control over the player lifecycle with simple integration patterns suitable for any Android application architecture.



Did this page help you?