Story Block (iOS)

Display Story Block

Use StoryBlockViewController

Integration

  1. Import FireworkVideo.

  2. Create a new StoryBlockViewController.

  3. Embed instantiated StoryBlockViewController.

import FireworkVideo

class ViewController: UIViewController {

    func embedStoryBlockInViewController() {
        let storyBlockVC = StoryBlockViewController(source: .discover)
        // Please ensure that viewConfiguration and isPictureInPictureEnabled are set
        // before attaching it to the parent view
        storyBlockVC.viewConfiguration = getStoryBlockConfiguration()
        storyBlockVC.isPictureInPictureEnabled = true

        self.addChild(storyBlockVC)

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

        storyBlockVC.didMove(toParent: self)
    }

    func getStoryBlockConfiguration() -> StoryBlockConfiguration {
        var viewConfiguration = StoryBlockConfiguration()
        viewConfiguration.playbackButton.isHidden = false
        viewConfiguration.fullScreenPlayerView.playbackButton.isHidden = false
        return viewConfiguration
    }
}

Use StoryBlockView

The StoryBlockView provides a UIView wrapper for the FireworkVideo.StoryBlockViewController. You can customize the StoryBlockView just like the FireworkVideo.StoryBlockViewController.

Integration

  1. Follow the instruction to install FireworkVideoUI.

  2. Import FireworkVideo and FireworkVideoUI.

  3. Instantiate StoryBlockView and embed it.

The following are the sample codes:

Use StoryBlockSwiftUIView(SwiftUI)

The StoryBlockSwiftUIView provides a SwiftUI View wrapper for the FireworkVideo.StoryBlockViewController. You can customize the StoryBlockSwiftUIView just like the FireworkVideo.StoryBlockViewController.

Integration

  1. Follow the instruction to install FireworkVideoUI.

  2. Import FireworkVideo and FireworkVideoUI.

  3. Instantiate StoryBlockSwiftUIView and embed it.

The following are the sample codes:

Story Block Content Source

The enum StoryBlockContentSource defines the different sources that can be used to populate the story block. The content source must be specified when the StoryBlockViewController is instantiated; StoryBlockViewController(source: .discover). By default, the feed will use the .discover content source.

Other content sources include

Channel

Displays content from the specified channel id.

Note: The user will only see videos they have not viewed before. If the user has viewed all the videos for a channel similar videos will automatically be provided.

Channel Playlist

Displays content from the specified playlist id.

Note: Unlike the channel content source, only content in the playlist will be shown to the user.

Dynamic Content

Displays dynamic content based on the provided channel id and content parameters.

Hashtag Playlist

Displays content based on the provided channel id and the hashtag expression.

Or a more advanced hashtag expression can be used to fine tune the results

Single Video or Live Stream

Displays a single video or live stream content.

Video Ads

Displays video ads based on vast XML.

Receive story block events

  1. Set the delegate

  1. Conform to StoryBlockViewControllerDelegate protocol

Play and pause StoryBlock programmatically

Use StoryBlockViewController

Use StoryBlockView

Player configurations

Please refer to Player configurations (iOS).

Story block layout

You can customize the width and height of the story block to achieve either a horizontal or vertical layout.

Vertical layout

As shown in the following code snippets, we set the story block’s width to 350 and height to 533 to achieve a horizontal layout.

Use StoryBlockViewController

Use StoryBlockView

Use StoryBlockSwiftUIView

Horizontal layout

As shown in the following code snippets, we set the story block’s width to 533 and height to 255 to achieve a horizontal layout.

Use StoryBlockViewController

Use StoryBlockView

Use StoryBlockSwiftUIView

Loading indicator color

You can use the following code snippets to customize loading indicator color.

Last updated

Was this helpful?