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();

和我設置寬度和視頻播放器的使用寬度和高度來自裝置的尺寸得到了高度...

如果你們有其他的方式,做份額:) 謝謝

相關問題