Video Feed (iOS)

Display Video Feed

Use VideoFeedViewController

Integration

  1. Import FireworkVideo.

  2. Create a new VideoFeedViewController.

  3. Present, push or embed the instantiated VideoFeedViewController.

import UIKit
import FireworkVideo

class ViewController: UIViewController {

    func addFeedToTabBarController() {
        let channelID = "<Encoded Channel ID>"
        let playlistID = "<Encoded Playlist ID>"
        let feedVC = VideoFeedViewController(source: .channelPlaylist(channelID: channelID, playlistID: playlistID))
        feedVC.viewConfiguration = getVideoFeedContentConfiguration()
        feedVC.tabBarItem = UITabBarItem(title: "Videos", image: nil, selectedImage: nil)
        self.tabBarController?.viewControllers?.append(feedVC)
    }

    func pushFeedOnNavigationController() {
        let channelID = "<Encoded Channel ID>"
        let playlistID = "<Encoded Playlist ID>"
        let feedVC = VideoFeedViewController(source: .channelPlaylist(channelID: channelID, playlistID: playlistID))
        feedVC.viewConfiguration = getVideoFeedContentConfiguration()
        self.navigationController?.pushViewController(feedVC, animated: true)
    }

    func embedFeedInViewController() {
        let channelID = "<Encoded Channel ID>"
        let playlistID = "<Encoded Playlist ID>"
        let feedVC = VideoFeedViewController(source: .channelPlaylist(channelID: channelID, playlistID: playlistID))
        feedVC.viewConfiguration = getVideoFeedContentConfiguration()

        self.addChild(feedVC)

        feedVC.view.translatesAutoresizingMaskIntoConstraints = false
        self.view.addSubview(feedVC.view)
        NSLayoutConstraint.activate([
            feedVC.view.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
            feedVC.view.trailingAnchor.constraint(equalTo: self.view.trailingAnchor),
            feedVC.view.heightAnchor.constraint(equalToConstant: 240),
            feedVC.view.centerYAnchor.constraint(equalTo: self.view.centerYAnchor)
        ])

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

Use VideoFeedView

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

Integration

  1. Follow the instruction to install FireworkVideoUI.

  2. Import FireworkVideo and FireworkVideoUI.

  3. Instantiate VideoFeedView and embed it.

The following are the sample codes:

Use VideoFeedSwiftUIView(SwiftUI)

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

Integration

  1. Follow the instruction to install FireworkVideoUI.

  2. Import FireworkVideo and FireworkVideoUI.

  3. Instantiate VideoFeedSwiftUIView and embed it.

The following are the sample codes:

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

A VideoFeedViewController can be forced to refreshed by calling the refresh() method on the instance that should be refreshed. This functionality is useful if your feed is embedded along with other components that are also updated and you support features like pull to refresh.

Receive video feed events

  1. Set the delegate

  1. Conform to VideoFeedViewControllerDelegate protocol

Video feed configurations

Please refer to Video feed configurations (iOS).

Player configurations

Please refer to Player configurations (iOS).

Last updated

Was this helpful?