Links

Video Feed

Currently, there are five source types of video feed:
  • Discover
  • Channel
  • Playlist
  • Playlist Group(Only supported on iOS)
  • Dynamic Content
  • Hashtag Playlist
  • SKU
  • Single Content

Integration

import {
VideoFeed,
} from 'react-native-firework-sdk';
// discover
<VideoFeed
style={{ height: 200 }}
source="discover"
/>
// channel
<VideoFeed
style={{ height: 200 }}
source="channel"
mode="row"
channel="your encoded channel id"
/>
// playlist
<VideoFeed
style={{ height: 200 }}
source="playlist"
mode="row"
playlist="your encoded playlist id"
channel="your encoded channel id"
/>
// playlist group(only supported on iOS)
<VideoFeed
style={{ height: 200 }}
source="playlistGroup"
mode="row"
playlistGroup="your encoded playlist group id"
/>
// dynamic content
<VideoFeed
style={{ height: 200 }}
source="dynamicContent"
mode="row"
channel="your encoded channel id"
dynamicContentParameters={{
'<cohort key>': ['<cohort value1>', '<cohort value2>'],
}}
/>
// hashtag playlist
<VideoFeed
style={{ height: 200 }}
source="hashtagPlaylist"
mode="row"
channel="your encoded channel id"
hashtagFilterExpression="<hashtag filter expression>"
/>
// sku
<VideoFeed
style={{ height: 200 }}
source="sku"
mode="row"
channel="your encoded channel id"
productIds={['prodct_id_1', 'product_id_2']}
/>
// single content
<VideoFeed
style={{ height: 200 }}
source="singleContent"
mode="row"
contentId="your encoded video or live stream id"
/>
Please refer to the Encoded IDs help article to learn about how to find your encoded channel ID, playlist ID and playlist group ID.

Mode

VideoFeed component supports three modes: row, column, and grid.
Use grid mode:
<VideoFeed
style={{ flex: 1 }}
source="discover"
mode="grid"
/>

Video feed configuration

VideoFeed component provides videoFeedConfiguration prop for configuring Video Feed. The current configurable are backgroundColor, cornerRadius, and enableAutoplay etc. Please refer to VideoFeedConfiguration for more details.
<VideoFeed
style={{ height: 200 }}
source="discover"
videoFeedConfiguration={{
title: { hidden: false },
titlePosition: 'nested',
enableAutoplay: true, // enable autoplaying thumbnails
}}
/>

Video player configuration

VideoFeed component provides videoPlayerConfiguration prop for configuring Video Player. The current configurable properties are playerStyle, videoCompleteAction, and ctaButtonStyle etc. Please refer to VideoPlayerConfiguration for more details.
<VideoFeed
style={{ height: 200 }}
source="discover"
videoPlayerConfiguration={{
playerStyle: 'full',
videoCompleteAction: 'advanceToNext',
showShareButton: true,
}}
/>

Customize player button icons

Set up the iOS project
Add your custom button icons to the asset catalogs(e.g. Images.xcassets, Assets.xcassets or other names) in your iOS project. Such as:
Set up the Android project
Add your custom button icons to the drawable directory(App resources overview and Support different pixel densities) in your Android project. Such as:
Config player button icon names on the JS side
<VideoFeed
style={{ height: 200 }}
source="discover"
mode="row"
videoFeedConfiguration={videoFeedConfiguration}
videoPlayerConfiguration={{
buttonConfiguration: {
videoDetailButton: { imageName: 'custom_more' },
closeButton: { imageName: 'custom_close' },
muteButton: { imageName: 'custom_mute' },
unmuteButton: { imageName: 'custom_unmute' },
playButton: { imageName: 'custom_play' },
pauseButton: { imageName: 'custom_pause' },
},
}}
/>
You could also pass the buttonConfiguration when opening the player.
FireworkSDK.getInstance().openVideoPlayer(url, {
buttonConfiguration: {
videoDetailButton: { imageName: 'custom_more' },
closeButton: { imageName: 'custom_close' },
muteButton: { imageName: 'custom_mute' },
unmuteButton: { imageName: 'custom_unmute' },
playButton: { imageName: 'custom_play' },
pauseButton: { imageName: 'custom_pause' },
},
});
Please refer to buttonConfiguration for more details.
  1. 1.
    Show the logo for the creator of the media
<VideoFeed
style={{ height: 200 }}
source="discover"
videoPlayerConfiguration={{
videoPlayerLogoConfiguration: {
option: 'creator',
encodedId: 'encoded channel id', // encoded channel id
}
}}
/>
  1. 2.
    Shows the channel aggregator's logo
<VideoFeed
style={{ height: 200 }}
source="discover"
videoPlayerConfiguration={{
videoPlayerLogoConfiguration: {
option: 'channelAggregator',
encodedId: 'encoded channel id', // encoded channel id
}
}}
/>

Video feed loading result callback

VideoFeed component provides onVideoFeedLoadFinished prop for setting video feed loading result callback.
<VideoFeed
style={{ height: 200 }}
source="discover"
onVideoFeedLoadFinished={(error) => {
/**
* if error is undefined, it means that video feed loaded successfully.
* Otherwise, it means that video feed failed to load.
*/
console.log('onVideoFeedLoadFinished error', error);
}}
/>

Force refreshing video feed

const feedRef = useRef<VideoFeed>(null);
const handleRefresh = () => {
//force refreshing video feed
feedRef.current?.refresh();
};
<VideoFeed
style={{ height: 200 }}
source="discover"
ref={feedRef}
/>
<Button
onPress={handleRefresh}
title="Refresh"
/>

Floating Player

You could set enablePictureInPicture to true to enable the floating player.
<VideoFeed
style={{ height: 200 }}
source="discover"
enablePictureInPicture=true
/>

OS Picture in Picture

You also need to set enablePictureInPicture to true to enable the OS Picture in Picture.
<VideoFeed
style={{ height: 200 }}
source="discover"
enablePictureInPicture=true
/>
This feature allows the user to watch media while the application is in a background state. While in background mode a video will display in a floating, resizable window.

Set up the iOS project

To enable OS Picture in Picture on the iOS side, you also need to add Background Modes capability via Signing & Capabilities in your iOS project settings. More information about this can be found here: Apple Documentation
To use Picture in Picture, we configure the app to support background audio playback. See Configuring the Audio Playback of iOS and tvOS Apps for more details.
As the following screenshot, we should select "Audio, AirPlay, and Picture in Picture".

onVideoFeedClick

The callback is triggered when users click the video feed item. The event type is VideoFeedClickEvent.
FireworkSDK.getInstance().onVideoFeedClick = (event) => {};

onCustomCTAClick

The callback is triggered when users click the CTA button on the video in the video player. We start the floating player in the following sample codes. The event type is CustomCTAClickEvent.
FireworkSDK.getInstance().onCustomCTAClick = async (event) => {
const result = await FireworkSDK.getInstance().navigator.startFloatingPlayer();
if (!result) {
/* when the result is false, the current fullscreen player may not
* enable the floating player. In that case, we could call the
* following method to close the fullscreen player.
*/
await FireworkSDK.getInstance().navigator.popNativeContainer();
}
// Navigate to the RN webview page of the host app.
navigation.navigate('LinkContent', { url: event.url });
}

Reference