Skip to main content

Chromecast (Google Cast)

The Cast SDK allows a user to select streaming audio-visual content using a sender (Lura Player), and play it on (or cast it to) another device known as the receiver, while controlling playback using the sender.

To enable Google Cast SDK on your player, you need to do the following configuration:

AttributeTypeOptionalDescription
enabledbooleantrueWhether casting is enabled in available devices. (Defaults to false)
appIdstringfalseChromecast receiver application ID.
import React, { useRef, useEffect, useState } from "react";
import { SafeAreaView, StyleSheet, View } from "react-native";
import { LuraPlayer, type UnifiedPlayer, type Configuration } from "@akta-tech/lura-player-react-native";
import { LuraPlayerControls } from "@akta-tech/lura-player-react-native-ui";

export default function App() {
const playerRef = useRef<UnifiedPlayer>(null);
const config: Configuration = {
...
cast: {
chromecast: {
enabled: true,
appId: "12345678"
}
},
...
};
useEffect(() => {
playerRef.current?.setConfig(config)
}, [playerRef]);
return (
<View>
<SafeAreaView />
<LuraPlayer ref={playerRef} style={styles.player}>
<LuraPlayerControls></LuraPlayerControls>
</LuraPlayer>
</View>
);
}

const styles = StyleSheet.create({
player: {
backgroundColor: "#000",
width: "100%",
maxWidth: 640,
aspectRatio: 16 / 9,
},
});