|
@@ -27,7 +27,7 @@ export default class CusVideo extends React.Component {
|
|
|
resizeMode: "stretch",
|
|
|
duration: 0.0,
|
|
|
currentTime: 0.0,
|
|
|
- paused: true,
|
|
|
+ paused: false,
|
|
|
wheel: false
|
|
|
};
|
|
|
|
|
@@ -39,7 +39,12 @@ export default class CusVideo extends React.Component {
|
|
|
source={{
|
|
|
uri: this.props.uri
|
|
|
}}
|
|
|
+ ref={ref => {
|
|
|
+ this.player = ref;
|
|
|
+ }}
|
|
|
+ // poster={this.props.poster}
|
|
|
resizeMode={this.state.resizeMode}
|
|
|
+ // posterResizeMode={this.state.resizeMode}
|
|
|
rate={this.state.rate} //播放速率
|
|
|
paused={this.state.paused} //暂停
|
|
|
volume={this.state.volume} //调节音量
|
|
@@ -52,6 +57,9 @@ export default class CusVideo extends React.Component {
|
|
|
onAudioBecomingNoisy={this.onAudioBecomingNoisy} //音频变得嘈杂时的回调 - 应暂停视频
|
|
|
onAudioFocusChanged={this.onAudioFocusChanged} //音频焦点丢失时的回调 - 如果焦点丢失则暂停
|
|
|
repeat={this.state.wheel} //确定在到达结尾时是否重复播放视频。
|
|
|
+ onError={this.onError} // 当视频不能加载,或出错后的回调函数
|
|
|
+ playInBackground={false} // 当app转到后台运行的时候,播放是否暂停
|
|
|
+ playWhenInactive={true} // [iOS] Video continues to play when control or notification center are shown. 仅适用于IOS
|
|
|
/>
|
|
|
<View style={[styles.player_controller]}>
|
|
|
<View
|
|
@@ -106,13 +114,22 @@ export default class CusVideo extends React.Component {
|
|
|
{formatTime(this.state.duration)}
|
|
|
</Text>
|
|
|
</View>
|
|
|
+ <TouchableOpacity
|
|
|
+ style={{ flex: 1 }}
|
|
|
+ onPress={() => this.presentFullscreenPlayer()}
|
|
|
+ >
|
|
|
+ <View style={{ flex: 1 }}>
|
|
|
+ {/* //放大按钮 */}
|
|
|
+ <Image style={[styles.player_pause_icon]} />
|
|
|
+ </View>
|
|
|
+ </TouchableOpacity>
|
|
|
</View>
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
loadStart() {
|
|
|
- // alert("准备加载视频");
|
|
|
+ // alert("loadStart");
|
|
|
}
|
|
|
onLoad = data => {
|
|
|
//获取的是秒数
|
|
@@ -123,6 +140,13 @@ export default class CusVideo extends React.Component {
|
|
|
currentTime: data.currentTime
|
|
|
});
|
|
|
};
|
|
|
+
|
|
|
+ onError() {
|
|
|
+ alert("播放器异常");
|
|
|
+ }
|
|
|
+ onEnd() {
|
|
|
+ alert("播放结束");
|
|
|
+ }
|
|
|
play() {
|
|
|
if (this.state.paused) {
|
|
|
this.start();
|
|
@@ -142,6 +166,11 @@ export default class CusVideo extends React.Component {
|
|
|
// ToastExample.message(params);
|
|
|
ToastExample.show(params, ToastExample.SHORT);
|
|
|
}
|
|
|
+ presentFullscreenPlayer() {
|
|
|
+ // alert("点击调用全屏");
|
|
|
+ this.props.videofullScreenPlayer();
|
|
|
+ // this.player.presentFullscreenPlayer();
|
|
|
+ }
|
|
|
|
|
|
refreshVideo() {
|
|
|
this.setState({
|
|
@@ -158,8 +187,7 @@ const styles = StyleSheet.create({
|
|
|
width: "100%",
|
|
|
height: 50,
|
|
|
alignItems: "center",
|
|
|
- bottom: 0,
|
|
|
- backgroundColor: "powderblue"
|
|
|
+ bottom: 0
|
|
|
},
|
|
|
player_pause_icon: {
|
|
|
width: "100%",
|
|
@@ -170,8 +198,8 @@ const styles = StyleSheet.create({
|
|
|
backgroundColor: "blue"
|
|
|
},
|
|
|
player_time: {
|
|
|
- backgroundColor: "red",
|
|
|
- fontSize: 30,
|
|
|
+ fontSize: 18,
|
|
|
+ color: "white",
|
|
|
alignItems: "center",
|
|
|
justifyContent: "center",
|
|
|
textAlignVertical: "center",
|