2

我想要处理一些将导航到video.js文件的应用程序,该文件将自动触发视频以横向全屏播放。将视频锁定为横向全屏方向(react-native-video)

我使用的反应本地视频 链接:https://github.com/react-native-community/react-native-video

render() { 
 

 
    return (
 
     <View style={styles.container}> 
 
     <View style={styles.fullScreen}> 
 
      <Video 
 
      ref={(ref) => { 
 
       this.player = ref 
 
      }} 
 
      source={require('../vid/intro-video.mp4')} 
 
      style={styles.nativeVideoControls} 
 
      rate={this.state.rate} 
 
      paused={this.state.paused} 
 
      volume={this.state.volume} 
 
      muted={this.state.muted} 
 
      resizeMode={this.state.resizeMode} 
 
      onLoad={this.onLoad} 
 
      onLoadStart={this.loadStart} 
 
      onBuffer={this.onBuffer} 
 
      onProgress={this.onProgress} 
 
      onEnd={debounce(this.onEnd, 100)} 
 
      repeat={false} 
 
      controls={this.state.controls} 
 
      /> 
 
     </View> 
 
     </View> 
 
    ); 
 
    }

我尝试添加loadStart函数内部的贝洛奥里藏特的代码,但它不工作..当我旋转如果不是全屏模式,视频将出现在我的屏幕底部。

this.player.presentFullscreenPlayer()

enter image description here

的解决方案,我想: 1)使用onLayout的视图标签,但什么都没有发生。 2)使用this.player.presentFullscreenPlayer()仍然没有解决问题。

回答

0

我仍然没有找到针对此问题的修复解决方案,但我只是想共享临时解决方案。

我使用另一封装反应天然取向和触发lockToLandscape()的内部componentWillMount,然后我使用尺寸得到该装置的宽度和高度

Orientation.lockToLandscape(); 
 
height = Dimensions.get('window').height; 
 
width = Dimensions.get('window').width;

和我还在onLoad方法中添加了presentFullScreenPlayer

this.player.presentFullscreenPlayer();

和我设置宽度和视频播放器的使用宽度和高度来自装置的尺寸得到了高度...

如果你们有其他的方式,做份额:) 谢谢

相关问题