Skip to content

Instantly share code, notes, and snippets.

@vizbee
vizbee / RNVizbeeCastButton.js
Last active October 25, 2023 10:48
RNVizbeeSender: add cast button
// import
import { VizbeeCastButton } from 'react-native-vizbee-sender-sdk';
// in render component
<VizbeeCastButton style={styles.castButton} tintColor="#FFFFFF"></VizbeeCastButton>
// styles (important to set width & height)
const styles = StyleSheet.create({
castButton: {
width: 32,
@vizbee
vizbee / RNVizbeeSession.js
Last active May 6, 2021 15:44
RNVizbeeSender: session start and end listeners
// imports
import { VizbeeManager } from 'react-native-vizbee-sender-sdk';
//---
// setup listeners
//---
private subscriptions = [];
public addListeners() {
@vizbee
vizbee / RNVizbeeSmartPlay.js
Last active December 14, 2023 08:46
RNVizbeeSender: smart play
// imports
import { VizbeeManager, VizbeeVideo } from 'react-native-vizbee-sender-sdk';
// create VizbeeVideo
let vizbeeVideo = new VizbeeVideo();
vizbeeVideo.guid = appVideoObject.guid;
vizbeeVideo.title = appVideoObject.title;
vizbeeVideo.subtitle = appVideoObject.subtitle;
vizbeeVideo.imageUrl = appVideoObject.imageUrl;
vizbeeVideo.startPositionInSeconds = appVideoObject.startPositionInSeconds;
@vizbee
vizbee / RNVizbeeSenderSDKSnippets.md
Last active September 26, 2023 13:11
Snippets for Vizbee React Native Sender SDK

Snippets for Vizbee React Native Sender SDK

Initialization

Build Setup

Scenario Snippet
1 Add Vizbee RN Sender SDK to your repo and setup iOS and Android dependencies Snippet
@vizbee
vizbee / VizbeeChromecastCAFSnippets.md
Last active November 9, 2020 23:02
Snippets for Vizbee Chromecast CAF SDK

Snippets for Vizbee Chromecast CAF SDK

Instructions

  • Look up the use case or scenario related to Vizbee SDK integration in the list below.
  • The corresponding snippet provides template code to address the scenario.
  • Copy the template code and update based on your app's requirements.

Scenarios & Snippets

Initialization

@vizbee
vizbee / VizbeeChromecastCAF_Initialization.js
Last active October 29, 2020 01:15
Add and Initialise Vizbee Chromecast CAF SDK
// add Vizbee Chromecast CAF SDK library in entry (receiver.html) file of your receiver
<script src="https://static.claspws.tv/sdk/receivers/chromecast/v6/vizbee.js"></script>
// initialize the Vizbee SDK before CastReceiverContext.start in your receiver and
// replace the vzbxxxxxxx with Vizbee appID assigned for your app
let vzbContext = vizbee.framework.ContinuityContext.getInstance();
vzbContext.start('vzbxxxxxxx');
@vizbee
vizbee / VizbeeChromecastCAF_AddVizbeeChannelWithDefaultOptions.js
Last active October 29, 2020 00:51
Add Vizbee custom channel to CastReceiverContext start API with default CastReceiverOptions
// add Vizbee customNamespace in CastReceiverOptions for CastReceiverContext start
let context = cast.framework.CastReceiverContext.getInstance();
context.start({
supportedCommands: cast.framework.messages.Command.ALL_BASIC_MEDIA
customNamespaces: {
'urn:x-cast:tv.vizbee.sync': cast.framework.system.MessageType.STRING
}
});
@vizbee
vizbee / VizbeeChromecastCAF_AddVizbeeNamespaceWithCustomOptions.js
Last active October 29, 2020 01:15
Add Vizbee custom channel to CastReceiverContext start API with customized CastReceiverOptions (ie., Queue & PlaybackConfig)
// optional: Import your own CastQueue if any for playlist implementation
import { CastQueue } from './queuing.js';
// optional: Set the player to start playback as soon as there are five seconds of
// media content buffered. Default is 10.
const playbackConfig = new cast.framework.PlaybackConfig();
playbackConfig.autoResumeDuration = 5;
// add Vizbee custom namespace in CastReceiverOptions for CastReceiverContext start
let context = cast.framework.CastReceiverContext.getInstance();
@vizbee
vizbee / VizbeeChromecastCAF_NoLoadRequestInterceptor.js
Last active October 29, 2020 00:54
Vizbee LoadRequestInterceptor is not added since host receiver doesn't need any customData from Vizbee
// intercept the LOAD request to be able to read in a contentId and get data
playerManager.setMessageInterceptor(cast.framework.messages.MessageType.LOAD, loadRequestData => {
// host app performs updates to loadRequestData as needed ...
return loadRequestData;
});
@vizbee
vizbee / VizbeeChromecastCAF_LoadRequestInterceptor.js
Last active October 29, 2020 01:21
Vizbee LoadRequestInterceptor is added since host receiver needs customData from Vizbee
// create Vizbee LoadRequestInterceptor to intercept and convert loadRequestData sent by Vizbee sdk
let vzbLoadRequestInterceptor = new vizbee.framework.LoadRequestInterceptor((vzbLoadRequestData) => {
// update vzbLoadRequestData to loadRequestData format expected by your receiver
let updatedLoadRequestData = vzbLoadRequestData;
updatedLoadRequestData.media.contentId = vzbLoadRequestData.media.customData.guid;
return updatedLoadRequestData;
});
// intercept the LOAD request to be able to read in a contentId and get data