react-native-video解决安卓无法全屏
2021-07-13 本文已影响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 ,样子应该是这个样子的:
![](https://img.haomeiwen.com/i9126595/b15f48439d44301b.png)