-
-
Save joaquin-viera/dc96849c2bf0cdd50bea65ffdd571840 to your computer and use it in GitHub Desktop.
Streaming - PlayStream.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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