我正在构建rtmp视频播放器应用程序,但播放器出现错误。我已经为我的应用程序集成了KSYVideo
来播放rtmp格式的视频。该应用程序将正确构建,但我的应用程序将在图片中显示以下错误。
这是我的代码。
import React from "react";
import PropTypes from "prop-types";
import { View, StyleSheet, Text, Button } from "react-native";
import KSYVideo from "react-native-ksyvideo";
class VideoPlayer extends React.Component {
constructor(props) {
super(props);
this.state = {
paused: false
};
}
render() {
return (
<View>
<KSYVideo
source={{
uri: "rtmp://103.130.168.86:1935/ntv/live/live1"
}} // Can be a URL or a local file.
ref={ref => {
this.player = ref;
}} // Store reference
volume={1.0}
muted={false}
paused={this.state.paused} // Pauses playback entirely.
resizeMode="cover" // Fill the whole screen at aspect ratio.*
repeat={true} // Repeat forever.
playInBackground={true} // Audio continues to play when app entering
background.
progressUpdateInterval={250.0}
style={{ height: 400 }}
/>
{/*<Text>Video streaming....</Text>*/}
<View style={styles.buttonStyle}>
<Button
title={"Pause"}
style={styles.buttonStyle}
onPress={() => {
this.setState({ paused: true });
}}
color="#841584"
/>
</View>
<View style={styles.buttonStyle}>
<Button
title={"Play"}
onPress={() => {
this.setState({ paused: false });
}}
color="green"
/>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
backgroundVideo: {
position: "absolute",
top: 0,
left: 0,
bottom: 0,
right: 0
},
buttonStyle: {
marginHorizontal: 20,
marginTop: 5
}
});
export default VideoPlayer;