For the complete documentation index, see llms.txt. This page is also available as Markdown.

Video Feed (iOS)

Display Video Feed

Use FWSVideoFeedView

The FWSVideoFeedView provides a UIView wrapper for the VideoFeedViewController. You can customize the FWSVideoFeedView just like the VideoFeedViewController.

Integration

  1. Import FireworkVideo.

  2. Instantiate FWSVideoFeedView and embed it.

The following are the sample codes:

import UIKit
import FireworkVideo

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        self.addVideoFeedView()
    }

    func addVideoFeedView() {
        let channelID = "<Encoded Channel ID>"
        let playlistID = "<Encoded Playlist ID>"
        let videoFeedView = FWSVideoFeedView(source: .channelPlaylist(channelID: channelID, playlistID: playlistID))
        videoFeedView.viewConfiguration = getVideoFeedContentConfiguration()

        videoFeedView.translatesAutoresizingMaskIntoConstraints = false
        self.view.addSubview(videoFeedView)

        NSLayoutConstraint.activate([
            videoFeedView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
            videoFeedView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor),
            videoFeedView.heightAnchor.constraint(equalToConstant: 240),
            videoFeedView.centerYAnchor.constraint(equalTo: self.view.centerYAnchor)
        ])
    }

    func getVideoFeedContentConfiguration() -> VideoFeedContentConfiguration {
        var viewConfiguration = VideoFeedContentConfiguration()
        viewConfiguration.itemView.autoplay.isEnabled = true
        viewConfiguration.playerView.playbackButton.isHidden = false
        return viewConfiguration
    }
}

Use FWSVideoFeedSwiftUIView(SwiftUI)

The FWSVideoFeedSwiftUIView provides a SwiftUI View wrapper for the VideoFeedViewController. You can customize the FWSVideoFeedSwiftUIView just like the VideoFeedViewController.

Integration

  1. Import FireworkVideo.

  2. Instantiate FWSVideoFeedSwiftUIView and embed it.

The following are the sample codes:

Content Source

Please refer to Video Feed Content Source (iOS).

Custom Call-To-Action Button Handling

Custom Call-To-Action button handling is done via the FireworkVideoCTADelegate protocol. This provides control over what occurs when a call-to-action button is tapped.

  1. Set the delegate:

2. Conform to protocol:

Force Refresh

You can force a VideoFeedViewController to reload its content by calling the refresh() method on the instance you want to update. This is useful when your feed is embedded alongside other components that refresh together, or when you support features like pull-to-refresh.

Receive video feed events

  1. Set the delegate

  1. Conform to VideoFeedViewControllerDelegate protocol

Receive onVideosLoaded callback

The onVideosLoaded closure is called whenever videos are loaded into the video feed, including the initial page and every subsequent page loaded via pagination. The closure receives a VideoFeedVideosLoadedInfo value whose videos property contains the [VideoDetails] that were loaded for that page.

Use FWSVideoFeedView

onVideosLoaded is exposed as a property on FWSVideoFeedView:

Use FWSVideoFeedSwiftUIView(SwiftUI)

onVideosLoaded is exposed as an initializer parameter on FWSVideoFeedSwiftUIView:

Autoplay

Autoplay lets the video feed automatically start playing the first eligible item without requiring user interaction. To enable it, set:

All behavior described below assumes this prerequisite is met. Which item is picked as "eligible" depends on the visibility threshold (viewConfiguration.itemView.autoplay.triggerVisibilityPercentage) and on whether viewport-based autoplay is turned on (useSafeAreaViewport).

Container-based autoplay (default)

When useSafeAreaViewport = false (the default), visibility is measured against the feed component's own bounds:

  • Autoplay is active whenever the component is at least partially on screen, and inactive when the component is fully off-screen.

  • While active, the first item whose visibility within the component's bounds is greater than or equal to triggerVisibilityPercentage starts playing automatically.

Viewport-based autoplay

When the component is embedded in a ScrollView, TableView, or CollectionView, you can opt into viewport-based autoplay by setting useSafeAreaViewport = true on FWSVideoFeedView or FWSVideoFeedSwiftUIView. In this mode, visibility is measured against the viewport rather than the component's own bounds:

  • The first item whose visibility within the viewport is greater than or equal to triggerVisibilityPercentage starts playing automatically.

  • The viewport itself is customizable via safeAreaEdges and additionalViewportExcludedInset (see below).

Customize viewport

The default viewport is defined as the screen bounds minus the safe area insets—such as the status bar, top navigation bar, bottom tab bar, and bottom home indicator.

However, you can further refine this viewport by specifying safeAreaEdges and additionalViewportExcludedInset. Please refer to the following code snippets for more details.

Video feed configurations

Please refer to Video feed configurations (iOS).

Player configurations

Please refer to Player configurations (iOS).

Last updated

Was this helpful?