StoryBlock

FwStoryBlockView is an inline video player that can be embedded directly into your view hierarchy. It provides a story-like video experience where videos play automatically within your layout.

Story block integrated into the layout

Overview

FwStoryBlockView allows you to embed a Firework video player directly into your app's view hierarchy without launching a separate activity. It's ideal for creating immersive, story-like video experiences.

Lifecycle

FwStoryBlockView has a simple lifecycle:

  1. Created - Instantiate the view in your layout

  2. Init - Call init() once to start playback

  3. Live - View is active and playing videos

  4. Destroy - Call destroy() once when done

Important: Do not call init() or destroy() more than once.

Integration

XML Layout

Add FwStoryBlockView to your layout:

Initialization

Initialize the StoryBlock with required parameters:

Using Builder Pattern

For Java compatibility or when you prefer builders:

Configuration

Player Modes

FwStoryBlockView supports two player modes:

FIT_MODE

Scales video with a 9:16 aspect ratio. The StoryBlock container should be placed in a ConstraintLayout with app:layout_constraintDimensionRatio="9:16":

FULL_BLEED_MODE

Fills the entire container following its width and height:

StoryBlock Specific Options

You can configure StoryBlock-specific behavior using StoryBlockOption:

For detailed configuration options, see StoryBlockOption Configuration.

Pause When Not Visible

The pauseWhenNotVisible parameter controls automatic pause/resume:

When set to true, the StoryBlock automatically:

  • Pauses (or mutes for livestreams) when the view becomes invisible

  • Resumes normal playback when the view becomes visible again

Fullscreen and Compact Modes

FwStoryBlockView can display in two states:

Compact Mode

The default embedded state within your layout. In compact mode:

  • Limited UI components are displayed

  • Shopping and livestream chat are not available

  • Video plays within the container bounds

Fullscreen Mode

Expanded to fill the screen. In fullscreen mode:

  • All UI components are available

  • Shopping and livestream chat are supported

  • Full player controls are shown

Programmatic Fullscreen

Open fullscreen mode programmatically:

Playback Control

Control video playback programmatically:

Play

Pause

Note: The pause() method does not work for livestreams (they will continue playing or switch to mute mode).

Feed Loading State

Monitor the feed loading state:

Feed Load States

  • FeedLoadState.Loading - Feed is currently loading

  • FeedLoadState.FeedLoaded - Feed loaded successfully and ready

  • FeedLoadState.EmptyFeed - Feed loaded but contains no content

  • FeedLoadState.EndOfFeed - End of feed reached

Best Practice: Set the listener before calling init() to receive all state changes.

Error Handling

Set an error listener to handle StoryBlock errors:

Remove Error Listener

Complete Example

Important Notes

  • StoryBlock is a heavy component - limit to 1-2 instances per screen

  • Call destroy() when the StoryBlock is no longer needed to free resources

  • Do not call init() or destroy() more than once

  • Set listeners before calling init() to receive all callbacks

  • Shopping and livestream chat features only work in fullscreen mode

  • The pause() method does not affect livestreams

  • Use pauseWhenNotVisible=true for better battery and performance

See Also

Last updated

Was this helpful?