美文网首页
react-native-video解决安卓无法全屏

react-native-video解决安卓无法全屏

作者: 朱传武 | 来源:发表于2021-07-13 21:26 被阅读0次

安卓默认不支持全屏,如果需要全屏,需要使用这个PR
https://github.com/react-native-video/react-native-video/pull/2073
具体用法:

yarn add https://github.com/r0b0t3d/react-native-video.git#feature/android-fullscreen

手动Link android/settings.gradle(如果直接使用默认播放器则无需手动,如果需要使用ExoPlayer 则不管是不是0.60之上都需要手动连接,默认播放器无法全屏,也没有全屏按钮)

include ':react-native-video'
project(':react-native-video').projectDir = new File(rootProject.projectDir, './node_modules/react-native-video/android-exoplayer')

android/app/build.gradle引入react-native-video

dependencies {
   ...
   implementation project(':react-native-video')
}
 protected List<ReactPackage> getPackages() {
          @SuppressWarnings("UnnecessaryLocalVariable")
          List<ReactPackage> packages = new PackageList(this).getPackages();
          // Packages that cannot be autolinked yet can be added manually here, for example:
          packages.add(new ReactVideoPackage());
          return packages;
        }

如果成功使用ExoPlayer ,样子应该是这个样子的:


image.png

相关文章

网友评论

      本文标题:react-native-video解决安卓无法全屏

      本文链接:https://www.haomeiwen.com/subject/xjaspltx.html