Player Deck (iOS) (Beta)

Display Player Deck

Use PlayerDeckView

The PlayerDeckView provides a UIView wrapper for the PlayerDeckFeedViewController.

Integration

  1. Import FireworkVideo.

  2. Instantiate PlayerDeckView and embed it.

The following are the sample codes:

import UIKit
import FireworkVideo

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

    func addPlayerDeckView() {
        let channelID = "<Encoded Channel ID>"
        let playlistID = "<Encoded Playlist ID>"
        let playerDeckView = PlayerDeckView(source: .channelPlaylist(channelID: channelID, playlistID: playlistID))
        playerDeckView.viewConfiguration = getPlayerDeckContentConfiguration()

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

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

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

Use PlayerDeckSwiftUIView(SwiftUI)

The PlayerDeckSwiftUIView provides a SwiftUI View wrapper for the PlayerDeckFeedViewController.

Integration

  1. Import FireworkVideo.

  2. Instantiate PlayerDeckSwiftUIView 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

A PlayerDeckView or PlayerDeckSwiftUIView 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 PlayerDeckFeedViewControllerDelegate protocol

Viewport-based autoplay support

By default, autoplay is enabled, and the video begins playing as soon as the component is instantiated. However, when the component is embedded within a ScrollView, TableView, or CollectionView, a more seamless user experience is achieved by initiating autoplay only when the component enters the viewport, and pausing playback when it leaves.

Customization

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 additionalViewportExcludedInset, which allows you to exclude additional custom insets. The final viewport is therefore determined by subtracting the combined insets of both the safe area and additionalViewportExcludedInset from the screen bounds.

Player Deck configurations

Please refer to Player Deck Configurations (iOS).

Player configurations

Please refer to Player configurations (iOS).

Last updated

Was this helpful?