The StoryBlockView provides a UIView wrapper for the FireworkVideo.StoryBlockViewController. You can customize the StoryBlockView just like the FireworkVideo.StoryBlockViewController.
Integration
Follow the instruction to install FireworkVideoUI.
The StoryBlockSwiftUIView provides a SwiftUI View wrapper for the FireworkVideo.StoryBlockViewController. You can customize the StoryBlockSwiftUIView just like the FireworkVideo.StoryBlockViewController.
Integration
Follow the instruction to install FireworkVideoUI.
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.
let channelID = "<Channel ID>"
let storyBlockVC = StoryBlockViewController(source: .channel(channelID: channelID))
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.
let channelID = "<Your Channel ID>"
let playlistID = "<Playlist ID>"
let storyBlockVC = StoryBlockViewController(source: .channelPlaylist(channelID: channelID, playlistID: playlistID))
Dynamic Content
Displays dynamic content based on the provided channel id and content parameters.
let channelID = "<Channel ID>"
let parameters: DynamicContentParameters = ["<cohort key>": ["<cohort value 1>", "<cohort value 2>"]]
let storyBlockVC = StoryBlockViewController(source: .dynamicContent(channelID: channelID, parameters: parameters))
Hashtag Playlist
Displays content based on the provided channel id and the hashtag expression.
let channelID = "<Channel ID>"
let singleHashtag = "dogs"
let storyBlockVC = StoryBlockViewController(source: .hashtagPlaylist(channelID: channelID, filterExpression: singleHashtag))
Or a more advanced hashtag expression can be used to fine tune the results
let channelID = "<Channel ID>"
let filterExpression = "(and sport (or food comedy))"
let storyBlockVC = StoryBlockViewController(source: .hashtagPlaylist(channelID: channelID, filterExpression: filterExpression))
Single Video or Live Stream
Displays a single video or live stream content.
let videoOrLiveStreamID = "<Video or LiveStream ID>"
let storyBlockVC = StoryBlockViewController(source: .singleContent(videoOrLiveStreamID: videoOrLiveStreamID))
Video Ads
Displays video ads based on vast XML.
// Specifies which channel the video ads should be created under.
let adChannelId = "<Channel ID>"
// The vast XML.
let vastXml = "<Vast XML>"
let storyBlockVC = StoryBlockViewController(source: .videoAds(adChannelId: adChannelId, vastXml: vastXml))
Receive story block events
Set the delegate
storyBlockVC.delegate = self
Conform to StoryBlockViewControllerDelegate protocol
func storyBlockDidLoadFeed(
_ viewController: StoryBlockViewController
) {
debugPrint("Story block loaded successfully.")
}
func storyBlock(
_ viewController: StoryBlockViewController,
didFailToLoadFeed error: StoryBlockError
) {
debugPrint("Story block did fail loading.")
if case .contentSourceError(let feedContentSourceError) = error,
case .emptyFeed = feedContentSourceError {
// This is a specific error.
// SDK will trigger this error when the story block is empty.
// For example, this error will be triggered when loading an empty playlist.
} else {
// Other error
}
}
Play and pause StoryBlock programmatically
Use StoryBlockViewController
let storyBlockVC = StoryBlockViewController(source: .discover)
// Play StoryBlock Programmatically
storyBlockVC.play()
// Pause StoryBlock Programmatically
storyBlockVC.pause()
Use StoryBlockView
let storyBlockView = StoryBlockView(source: .discover)
// Play StoryBlock Programmatically
storyBlockView.play()
// Pause StoryBlock Programmatically
storyBlockView.pause()