Skip to content

Instantly share code, notes, and snippets.

@joaquin-viera
Last active Jul 7, 2021
Embed
What would you like to do?
Streaming - PlayStream.js
import React, { useState, useEffect } from "react";
import { View, Button } from "react-native";
import { NodePlayerView } from "react-native-nodemediaclient";
const PlayStream = (props) => {
const [playerRef, setPlayerRef] = useState(null);
useEffect(() => {
return () => {
if (playerRef) playerRef.stop();
};
}, []);
return (
<View style={{ flex: 1 }}>
<NodePlayerView
style={{ flex: 1, backgroundColor: "#333" }}
ref={(vp) => {
setPlayerRef(vp);
}}
inputUrl={props.route.params.playserver + props.route.params.stream}
scaleMode={"ScaleAspectFill"}
bufferTime={300}
maxBufferTime={1000}
autoplay={true}
onStatus={(code, msg) => {
console.log("onStatus=" + code + " msg=" + msg);
}}
/>
<Button
onPress={() => {
props.navigation.goBack();
}}
title="Back"
/>
</View>
);
};
export default PlayStream;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment