# Video Feed (React Native)

Currently, there are five source types of video feed:

* Discover
* Channel
* Playlist
* Playlist Group
* Dynamic Content
* Hashtag Playlist
* SKU
* Single Content

## Integration

```tsx
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
<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"
/>
```

{% hint style="info" %}
Please refer to the [Encoded IDs](/firework-for-developers/additional-resources/encoded-ids.md) help article to learn about how to find your encoded channel ID, playlist ID and playlist group ID.
{% endhint %}

### Mode

`VideoFeed` component supports three modes: `row`, `column`, and `grid`.

Use `grid` mode:

```tsx
<VideoFeed
  style={{ flex: 1 }}
  source="discover"
  mode="grid"
/>
```

### Video feed configurations

Please consult [Video feed configurations (React Native)](/firework-for-developers/react-native-sdk/integration-guide-v2/customization-react-native/video-feed-configurations-react-native.md).

### Video player configurations

Please consult [Player configurations (React Native)](/firework-for-developers/react-native-sdk/integration-guide-v2/customization-react-native/player-configurations-react-native.md).

### Video feed loading result callback

`VideoFeed` component provides `onVideoFeedLoadFinished` prop for setting video feed loading result callback.

```tsx
<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

```tsx
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"
/>
```

### Enable PiP(Picture in Picture)

Please refer to [Enable PiP(Picture in Picture)](https://docs.firework.com/firework-for-developers/react-native-sdk/integration-guide-v2/customization-react-native/player-configurations-react-native#enable-pip-picture-in-picture).

### onVideoFeedClick

The callback is triggered when users click the video feed item. The event type is [VideoFeedClickEvent](https://eng.firework.com/fw_flutter_sdk/v2/fw_flutter_sdk/VideoFeedClickEvent-class.html).

<pre class="language-dart"><code class="lang-dart"><strong>FireworkSDK.getInstance().onVideoFeedClick = (event) => {};
</strong></code></pre>

### 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](https://eng.firework.com/react-native-firework-sdk/v2/interfaces/CustomCTAClickEvent.html).

<pre class="language-typescript"><code class="lang-typescript"><strong>FireworkSDK.getInstance().onCustomCTAClick = async (event) => {
</strong>  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 });
}
</code></pre>

## Reference

[VideoFeed](https://eng.firework.com/react-native-firework-sdk/v2/classes/VideoFeed.html)

[IVideoFeedProps](https://eng.firework.com/react-native-firework-sdk/v2/interfaces/IVideoFeedProps.html)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.firework.com/firework-for-developers/react-native-sdk/integration-guide-v2/video-feed-react-native.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
