Skip to content

Instantly share code, notes, and snippets.

@joaquin-viera
Created July 7, 2021 05:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joaquin-viera/b8aca9d06c545fc9c25a3b272dc5d069 to your computer and use it in GitHub Desktop.
Save joaquin-viera/b8aca9d06c545fc9c25a3b272dc5d069 to your computer and use it in GitHub Desktop.
Streaming - StreamContent.js
import React, { useState, useEffect } from "react";
import { View, Button, StyleSheet } from "react-native";
import { NodeCameraView } from "react-native-nodemediaclient";
const StreamContent = (props) => {
const [playerRef, setPlayerRef] = useState(null);
useEffect(() => {
return () => {
if (playerRef) playerRef.stop();
};
}, []);
return (
<View style={{ flex: 1, backgroundColor: "#333" }}>
<NodeCameraView
style={{ flex: 1 }}
ref={(vb) => {
setPlayerRef(vb);
}}
outputUrl={props.route.params.pushserver + props.route.params.stream}
camera={{ cameraId: 1, cameraFrontMirror: true }}
audio={{ bitrate: 32000, profile: 1, samplerate: 44100 }}
video={{
preset: 1,
bitrate: 500000,
profile: 1,
fps: 15,
videoFrontMirror: false,
}}
smoothSkinLevel={3}
autopreview={true}
onStatus={(code, msg) => {
console.log("onStatus=" + code + " msg=" + msg);
}}
/>
<View>
<Button
onPress={() => {
playerRef.switchCamera();
}}
color="red"
title="Reverse Camera"
/>
<Button
onPress={() => {
playerRef.start();
}}
color="green"
title="Publish"
/>
<Button
onPress={() => {
props.navigation.goBack();
}}
title="Back"
/>
</View>
</View>
);
};
export default StreamContent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment