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.
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))
Story Block Configuration
StoryBlockViewController provides a StoryBlockConfiguration API to configure the UI elements of the video player. A story block's video player can be configured differently when displaying in embedded mode or when expanded to full screen. Please refer to API documentation for more details.
let storyBlockVC =StoryBlockViewController(source: .discover)var configuration =StoryBlockConfiguration()// Hide the share button for embedded modeconfiguration.shareButton.isHidden =true// Hide the share button for full screen modeconfiguration.fullScreenPlayerView.shareButton.isHidden =true// Configuring the sharing URL for embedded modeconfiguration.shareButton.behavior.baseURL =URL(string:"your.custom.url")// Configuring the sharing URL for full screen modeconfiguration.fullScreenPlayerView.shareButton.behavior.baseURL =URL(string:"your.custom.url")// Configuring CTA for embedded modeconfiguration.ctaButton.contentConfiguration.backgroundColor =<Color>configuration.ctaButton.contentConfiguration.textColor =<Color>configuration.ctaButton.contentConfiguration.font =<Font>// Configuring CTA for full screen modeconfiguration.fullScreenPlayerView.ctaButton.contentConfiguration.backgroundColor =<Color>configuration.fullScreenPlayerView.ctaButton.contentConfiguration.textColor =<Color>configuration.fullScreenPlayerView.ctaButton.contentConfiguration.font =<Font>// Configuring player style for embedded modeconfiguration.playerStyle = .fit// Configuring player style for full screen modeconfiguration.fullScreenPlayerView.playerStyle = .fit// Show or hide the countdown timer for embedded mode. Default is hiddenconfiguration.countdownTimerConfiguration.isHidden =false// Show or hide the countdown timer for full screen mode. Default is hiddenconfiguration.fullScreenPlayerView.countdownTimerConfiguration.isHidden =false// Configuring the behavior on first displayconfiguration.onFirstDisplay = .unmuted // Or .default// Show playback button for embedded modeconfiguration.playbackButton.isHidden =false// Show playback button for full screen modeconfiguration.fullScreenPlayerView.playbackButton.isHidden =false// Customize play icon for embedded modeconfiguration.playbackButton.playDisplay.displayMode = .image(someImage)// Customize play icon for full screen modeconfiguration.fullScreenPlayerView.playbackButton.playDisplay.displayMode = .image(someImage)// Customize pause icon for embedded modeconfiguration.playbackButton.pauseDisplay.displayMode = .image(someImage)// Customize pause icon for full screen modeconfiguration.fullScreenPlayerView.pauseDisplay.pauseDisplay.displayMode = .image(someImage)// Customize the more option icon for embedded modeconfiguration.videoDetailButtonDisplayConfiguration.displayMode = .image(someImage)// Customize the more option icon for full screen modeconfiguration.fullScreenPlayerView.videoDetailButtonDisplayConfiguration.displayMode = .image(someImage)// Customize the mute icon for embedded modeconfiguration.muteButton.muteDisplay.displayMode = .image(someImage)// Customize the mute icon for full screen modeconfiguration.fullScreenPlayerView.muteButton.muteDisplay.displayMode = .image(someImage)// Customize the unmute icon for embedded modeconfiguration.muteButton.unmuteDisplay.displayMode = .image(someImage)// Customize the unmute icon for full screen modeconfiguration.fullScreenPlayerView.unmuteDisplay.displayMode = .image(someImage)// Customize the close icon for full screen modeconfiguration.fullScreenPlayerView.closeButtonConfiguration.closeDisplay.displayMode = .image(someImage)// Customize the pip icon for full screen modeconfiguration.fullScreenPlayerView.pipButtonConfiguration.pipDisplay.displayMode = .image(someImage)// Disable autoplayconfiguration.autoplay.isEnabled =false// Disable full screen mode(full screen icon is hidden)configuration.playerFullScreen.isEnabled =false// Hide ad badge for embedded modeconfiguration.sponsored.isHidden =true// Hide ad badge for full screen modeconfiguration.fullScreenPlayerView.sponsored.isHidden =true// Hide player caption for embedded modeconfiguration.playerCaption.isHidden =true// Hide player caption for full screen modeconfiguration.fullScreenPlayerView.playerCaption.isHidden =true// Hide player video detail button(ellipsis button) for embedded modeconfiguration.videoDetailButton.isHidden =true// Hide player video detail button(ellipsis button) for full screen modeconfiguration.fullScreenPlayerView.videoDetailButton.isHidden =true// Set the viewConfiguration property to apply the changesstoryBlockVC.viewConfiguration = configuration
Receive story block events
Set the delegate
storyBlockVC.delegate = self
Conform to StoryBlockViewControllerDelegate protocol
funcstoryBlockDidLoadFeed(_viewController: StoryBlockViewController) {debugPrint("Story block loaded successfully.")}funcstoryBlock(_viewController: StoryBlockViewController,didFailToLoadFeederror: StoryBlockError) {debugPrint("Story block did fail loading.")ifcase .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 ProgrammaticallystoryBlockVC.play()// Pause StoryBlock ProgrammaticallystoryBlockVC.pause()
Use StoryBlockView
let storyBlockView =StoryBlockView(source: .discover)// Play StoryBlock ProgrammaticallystoryBlockView.play()// Pause StoryBlock ProgrammaticallystoryBlockView.pause()