A-ANing / react-native-rn-videoplayer

基于react-native-video的视频播放器(上下滑动改变音量屏幕亮度,缓冲进度,双击暂停等ios Android)
94 stars 40 forks source link
brightness gesture player react-native react-native-rn-videoplayer react-native-video slide video

已废弃不会更新,不推荐使用(由于没有mac设备等问题)

已废弃不会更新,不推荐使用(由于没有mac设备等问题)

已废弃不会更新,不推荐使用(由于没有mac设备等问题)

已废弃不会更新,不推荐使用(由于没有mac设备等问题)

react-native-rn-videoplayer

博客文档地址        免VPN视频预览

gif预览 iosandroid 不是最新版

    

增加功能

    

    

Getting started

  1. npm install react-native-rn-videoplayer --save
  2. - - android

    Open up android/app/src/main/java/[...]/MainActivity.java

+import android.content.Intent; 
+import android.content.res.Configuration;
public class MainActivity extends ReactActivity {

   ...

+ @Override
+      public void onConfigurationChanged(Configuration newConfig) {
+        super.onConfigurationChanged(newConfig);
+        Intent intent = new Intent("onConfigurationChanged");
+        intent.putExtra("newConfig", newConfig);
+        this.sendBroadcast(intent);
+    }
    ...
}

- - iOS

Add the following to your project's AppDelegate.m:

+#import "Orientation.h"
+#import <RNIndicator.h>

@implementation AppDelegate

// ...

+- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
+  return [Orientation getOrientation];
+}

//找到这行
UIViewController *rootViewController = [UIViewController new];

//改为
UIViewController *rootViewController = [HomeIndicatorView new];

@end

RN >= 0.60

ios

    cd ios 

    pod install

Android.

Most of them are automatically linked. If you can’t find XX, you should link manually


-  app/build.gradle

  ```diff
  dependencies {
+    implementation project(':react-native-svg')
+    implementation project(':react-native-linear-gradient')
+    implementation project(':react-native-orientation-locker')
+    implementation project(':react-native-system-setting')
+    implementation project(':react-native-video')
  }

RN <= 0.59

react-native link react-native-linear-gradient
react-native link react-native-orientation-locker
react-native link react-native-svg
react-native link react-native-system-setting
react-native link react-native-video

Android

  1. Append the following lines to android/settings.gradle:

    include ':react-native-rn-videoplayer'
    project(':react-native-rn-videoplayer').projectDir = new File(rootProject.projectDir,   '../node_modules/react-native-rn-videoplayer/android')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:

      compile project(':react-native-rn-videoplayer')
  3. Open up android/app/src/main/java/[...]/MainApplication.java

    • Add
      
      import com.ngxu.videoplayer.RNVideoplayerPackage;

    new RNVideoplayerPackage() //to the list returned by the getPackages() method

Usage

import VideoPlayer from 'react-native-rn-videoplayer';

<VideoPlayer
url={"xxxxx.mp4"}
autoPlay={false}//是否自动播放,默认为true v2.2.5增加
poster={"http://XXX.jpg"}//视频封面
ref={(ref)=>this.player=ref}
lockControl={true}//控件锁定功能 v2.0.6增加
moreSetting={() => null}//右上角更多按钮 输出null则不显示
onSmallBack={()=>{this.props.navigation.goBack()}}
/>

api

暴露方法

import {NgxuSetting} from 'react-native-rn-videoplayer'

显示或者隐藏安卓底部虚拟按键

const Setting = new NgxuSetting()
Setting.hideAndroidBottom()
Setting.showAndroidBottom()

获取手机系统亮度

const Setting = new NgxuSetting()
Setting.getBrightness((e)=>{consoloe.log(e)})

改变ios系统亮度 android 当前app亮度