Configure Video Feed View

FwVideoFeedView is a custom view that displays video thumbnails in a scrollable feed. Users can tap on any thumbnail to launch the fullscreen video player. The feed supports multiple layout types (horizontal, vertical, grid) and can display content from various sources.

Integration

Add to Layout

Add FwVideoFeedView to your layout XML file:

<com.firework.videofeed.FwVideoFeedView
    android:id="@+id/videoFeedView"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

Initialize

Initialize the feed view by calling init():

class MainActivity : AppCompatActivity() {
    private lateinit var videoFeedView: FwVideoFeedView
    
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        
        videoFeedView = findViewById(R.id.videoFeedView)
        
        // Simple initialization with defaults
        videoFeedView.init()
    }
    
    override fun onDestroy() {
        videoFeedView.destroy()
        super.onDestroy()
    }
}

Initialize with ViewOptions

Provide ViewOptions to customize the feed:

Configuration Options

Feed Source (BaseOption)

Configure the content source for the feed. See Feed Sources for detailed information on each type.

For more feed types (HashtagPlaylist, DynamicContent, ShareUrl), see BaseOption Configuration.

Layout Configuration (LayoutOption)

Control the visual layout and appearance of the video feed.

Feed Layout Types

Spacing and Appearance

Title Position

For complete layout options, see LayoutOption Configuration.

Title Configuration (TitleOption)

Customize the appearance of feed titles.

Gradient Background

For complete title options, see TitleOption Configuration.

Player Configuration (PlayerOption)

Configure the fullscreen video player that opens when users tap on video thumbnails.

For complete player configuration options, see Video Player Configuration.

CTA Configuration (CtaOption)

Configure Call-to-Action button behavior.

Delay Units:

  • CtaDelayUnit.SECONDS - Delay in seconds (0.0 - 10.0, default: 3)

  • CtaDelayUnit.PERCENTAGE - Percentage of video duration (0.0 - 1.0, default: 0.2)

For CTA handling, see Shopping Integration.

Ad Badge Configuration (AdBadgeOption)

Customize the ad badge appearance on sponsored content.

Chat Configuration (ChatOption)

Configure livestream chat appearance.

Feed Refresh

Manually refresh the feed to reload content:

Example with SwipeRefreshLayout:

Feed State Monitoring

Feed View State Listener

Monitor feed loading states and respond to state changes:

Feed View States:

  • Loading - Feed is currently loading content

  • LoadData - Data has been successfully loaded

  • EmptyFeed - Feed has no content to display

  • EndOfFeed - End of available content reached

  • Error - Error occurred with message

Error Listener

Handle errors during feed operations:

Error Types:

  • SdkLevelError.SdkNotInitialized - SDK not initialized

  • VideoFeedError.LoadingFailed - Feed loading failed

  • AdsError - Ad-related errors (VideoLoadFailed, PlaybackFailed, ImaAdFailed)

  • LivestreamError - Livestream errors (MissingLivestreamInitializer, EngineFailed)

  • ShareContentError - Share errors (EmptyShareUrl, SharingFailed)

  • NetworkError - Network-related errors

  • PlayerError - Video playback errors

Feed Item Click Listener

Track when users tap on feed items:

FeedItem Properties:

  • id - Video content ID

  • title - Video title

  • indexInTheList - Position in feed

  • duration - Video duration in milliseconds

  • videoInfo - Detailed video information

Lifecycle Management

Destroy in Activity

Call destroy() when the feed view is no longer needed:

Destroy in Fragment

In fragments, call destroy() in onDestroyView():

Complete Configuration Examples

Grid Layout Feed

Horizontal Story Feed

Important Notes

  • Always call init() before the feed view can display content

  • The SDK must be initialized (via FireworkSdk.init()) before calling init() on the feed view

  • Always call destroy() when the feed view is no longer needed to free resources

  • ViewOptions provided to init() allow complete customization of the feed

  • For grid layout, columnCount determines the number of columns

  • Autoplay on thumbnails can impact battery and data usage

  • Use dpToPx() for density-independent pixel values

  • Use spToPx() for text size values

See Also

Last updated

Was this helpful?