├── .gitignore ├── utils ├── getMaxdata.js └── formatSeconds.js ├── android ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── ngxu │ │ └── videoplayer │ │ ├── RNVideoplayerModule.java │ │ ├── SetAppBrightness.java │ │ ├── RNVideoplayerPackage.java │ │ ├── AppBrightness.java │ │ ├── HideBottomNa.java │ │ └── HeidBottomBtn.java └── build.gradle ├── ios ├── RNIndicator.h ├── RNIndicator.m └── RNIndicator.xcodeproj │ └── project.pbxproj ├── RNIndicator.podspec ├── package.json ├── README.md ├── view └── index.js ├── component └── svg.js └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | example -------------------------------------------------------------------------------- /utils/getMaxdata.js: -------------------------------------------------------------------------------- 1 | export const getMaxdata=(a,b)=>{ 2 | if(a<=0){ 3 | return 0 4 | } 5 | if(a>=b){ 6 | return b 7 | } 8 | return a 9 | } -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ios/RNIndicator.h: -------------------------------------------------------------------------------- 1 | 2 | #if __has_include("RCTBridgeModule.h") 3 | #import "RCTBridgeModule.h" 4 | #else 5 | #import 6 | #endif 7 | 8 | #import 9 | 10 | 11 | 12 | @interface HomeIndicatorView : UIViewController 13 | @property BOOL refsAutoHidden; 14 | @end 15 | 16 | @interface RNIndicator : NSObject 17 | @end -------------------------------------------------------------------------------- /utils/formatSeconds.js: -------------------------------------------------------------------------------- 1 | export const formatSeconds = (value) => { 2 | let result = parseInt(value) 3 | let h = Math.floor(result / 3600) < 10 ? '0' + Math.floor(result / 3600) : Math.floor(result / 3600) 4 | let m = Math.floor((result / 60 % 60)) < 10 ? '0' + Math.floor((result / 60 % 60)) : Math.floor((result / 60 % 60)) 5 | let s = Math.floor((result % 60)) < 10 ? '0' + Math.floor((result % 60)) : Math.floor((result % 60)) 6 | if (Math.floor(result / 3600) === 0) { 7 | result = `${m}:${s}` 8 | } else { 9 | result = `${h}:${m}:${s}` 10 | } 11 | 12 | return result 13 | } 14 | -------------------------------------------------------------------------------- /android/src/main/java/com/ngxu/videoplayer/RNVideoplayerModule.java: -------------------------------------------------------------------------------- 1 | 2 | package com.ngxu.videoplayer; 3 | 4 | import com.facebook.react.bridge.ReactApplicationContext; 5 | import com.facebook.react.bridge.ReactContextBaseJavaModule; 6 | import com.facebook.react.bridge.ReactMethod; 7 | import com.facebook.react.bridge.Callback; 8 | 9 | public class RNVideoplayerModule extends ReactContextBaseJavaModule { 10 | 11 | private final ReactApplicationContext reactContext; 12 | 13 | public RNVideoplayerModule(ReactApplicationContext reactContext) { 14 | super(reactContext); 15 | this.reactContext = reactContext; 16 | } 17 | 18 | @Override 19 | public String getName() { 20 | return "RNVideoplayer"; 21 | } 22 | } -------------------------------------------------------------------------------- /RNIndicator.podspec: -------------------------------------------------------------------------------- 1 | 2 | Pod::Spec.new do |s| 3 | s.name = "RNIndicator" 4 | s.version = "1.0.0" 5 | s.summary = "RNIndicator" 6 | s.description = <<-DESC 7 | RNIndicator 8 | DESC 9 | s.homepage = "https://github.com/A-ANing/react-native-rn-videoplayer" 10 | s.license = "MIT" 11 | # s.license = { :type => "MIT", :file => "FILE_LICENSE" } 12 | s.author = { "author" => "author@domain.cn" } 13 | s.platform = :ios, "7.0" 14 | s.source = { :git => "https://github.com/A-ANing/react-native-rn-videoplayer.git", :tag => "master" } 15 | s.source_files = "ios/**/*.{h,m}" 16 | s.requires_arc = true 17 | 18 | 19 | s.dependency "React" 20 | #s.dependency "others" 21 | 22 | end 23 | 24 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | buildscript { 3 | repositories { 4 | jcenter() 5 | maven { 6 | url 'https://maven.google.com/' 7 | name 'Google' 8 | } 9 | google() 10 | } 11 | 12 | dependencies { 13 | classpath 'com.android.tools.build:gradle:3.3.1' 14 | } 15 | } 16 | 17 | apply plugin: 'com.android.library' 18 | 19 | android { 20 | compileSdkVersion 28 21 | buildToolsVersion "28.0.3" 22 | 23 | defaultConfig { 24 | minSdkVersion 16 25 | targetSdkVersion 28 26 | versionCode 1 27 | versionName "1.0" 28 | } 29 | lintOptions { 30 | abortOnError false 31 | } 32 | } 33 | 34 | repositories { 35 | mavenCentral() 36 | google() 37 | } 38 | 39 | dependencies { 40 | compile 'com.facebook.react:react-native:+' 41 | } 42 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-rn-videoplayer", 3 | "version": "2.2.12", 4 | "description": "A customisable React Native video player for Android and IOS", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/A-ANing/react-native-rn-videoplayer.git" 12 | }, 13 | "keywords": [ 14 | "react-native", 15 | "react-native-video", 16 | "videoplayer", 17 | "video", 18 | "player", 19 | "gesture", 20 | "control", 21 | "volume", 22 | "brightness", 23 | "progress" 24 | ], 25 | "author": { 26 | "name": "A-ANing", 27 | "email": "839650216@qq.com" 28 | }, 29 | "license": "", 30 | "homepage": "https://github.com/A-ANing/react-native-rn-videoplayer#readme", 31 | "dependencies": { 32 | "react-native-linear-gradient": "^2.5.6", 33 | "react-native-orientation-locker": "^1.1.8", 34 | "react-native-svg": "^12.1.1", 35 | "react-native-system-setting": "^1.7.2", 36 | "react-native-video": "^5.1.1" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /android/src/main/java/com/ngxu/videoplayer/SetAppBrightness.java: -------------------------------------------------------------------------------- 1 | 2 | package com.ngxu.videoplayer; 3 | import android.os.Build; 4 | 5 | import android.app.Activity; 6 | import java.lang.ref.WeakReference; 7 | import android.view.View; 8 | 9 | import android.view.WindowManager; 10 | import android.view.Window; 11 | 12 | public class SetAppBrightness { 13 | 14 | private static WeakReference mActivity; 15 | public static void goSetAppBrightness(Activity activity, final float brightnessPercent) 16 | { 17 | 18 | mActivity=new WeakReference(activity); 19 | 20 | if (activity == null) { 21 | if (mActivity == null) { 22 | return; 23 | } 24 | activity = mActivity.get(); 25 | } 26 | 27 | if (activity == null) return; 28 | 29 | final Activity _activity = activity; 30 | 31 | _activity.runOnUiThread(new Runnable() { 32 | @Override 33 | public void run() { 34 | Window window = _activity.getWindow(); 35 | WindowManager.LayoutParams layoutParams = window.getAttributes(); 36 | layoutParams.screenBrightness = brightnessPercent; 37 | window.setAttributes(layoutParams); 38 | } 39 | }); 40 | } 41 | 42 | } 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /android/src/main/java/com/ngxu/videoplayer/RNVideoplayerPackage.java: -------------------------------------------------------------------------------- 1 | 2 | package com.ngxu.videoplayer; 3 | 4 | import java.util.Arrays; 5 | import java.util.Collections; 6 | import java.util.List; 7 | 8 | import com.facebook.react.ReactPackage; 9 | import com.facebook.react.bridge.NativeModule; 10 | import com.facebook.react.bridge.ReactApplicationContext; 11 | import com.facebook.react.uimanager.ViewManager; 12 | import com.facebook.react.bridge.JavaScriptModule; 13 | import java.util.ArrayList; 14 | public class RNVideoplayerPackage implements ReactPackage { 15 | 16 | @Override 17 | public List createNativeModules(ReactApplicationContext reactContext) { 18 | List modules = new ArrayList<>(); 19 | 20 | modules.add( 21 | new AppBrightness(reactContext) 22 | ); 23 | modules.add( 24 | new HideBottomNa(reactContext) 25 | ); 26 | return modules; 27 | } 28 | 29 | 30 | // Deprecated from RN 0.47 31 | public List> createJSModules() { 32 | return Collections.emptyList(); 33 | } 34 | 35 | @Override 36 | public List createViewManagers(ReactApplicationContext reactContext) { 37 | return Collections.emptyList(); 38 | } 39 | } -------------------------------------------------------------------------------- /ios/RNIndicator.m: -------------------------------------------------------------------------------- 1 | #import "RNIndicator.h" 2 | 3 | @implementation HomeIndicatorView 4 | 5 | - (BOOL)prefersHomeIndicatorAutoHidden { 6 | return self.refsAutoHidden; 7 | } 8 | 9 | @end 10 | 11 | 12 | @implementation RNIndicator 13 | 14 | - (id) init { 15 | [self setrefsAutoHidden:NO]; 16 | return [super init]; 17 | } 18 | 19 | - (void) setrefsAutoHidden: (BOOL) newValue { 20 | HomeIndicatorView *rootViewController = [self getHomeIndicatorView]; 21 | 22 | rootViewController.refsAutoHidden = newValue; 23 | if (@available(iOS 11.0, *)) { 24 | [rootViewController setNeedsUpdateOfHomeIndicatorAutoHidden]; 25 | } 26 | } 27 | 28 | - (HomeIndicatorView*) getHomeIndicatorView { 29 | UIViewController *rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController; 30 | NSAssert( 31 | [rootViewController isKindOfClass:[HomeIndicatorView class]], 32 | @"rootViewController is not of type HomeIndicatorView as expected." 33 | ); 34 | return (HomeIndicatorView*) rootViewController; 35 | } 36 | 37 | - (dispatch_queue_t)methodQueue { 38 | return dispatch_get_main_queue(); 39 | } 40 | 41 | + (BOOL)requiresMainQueueSetup { 42 | return YES; 43 | } 44 | 45 | RCT_EXPORT_MODULE() 46 | 47 | RCT_EXPORT_METHOD(alwaysVisible) { 48 | [self setrefsAutoHidden:NO]; 49 | } 50 | 51 | RCT_EXPORT_METHOD(autoHidden) { 52 | [self setrefsAutoHidden:YES]; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /android/src/main/java/com/ngxu/videoplayer/AppBrightness.java: -------------------------------------------------------------------------------- 1 | package com.ngxu.videoplayer; 2 | 3 | import android.widget.Toast; 4 | import android.app.Activity; 5 | import android.content.Context; 6 | import com.facebook.react.bridge.NativeModule; 7 | import com.facebook.react.bridge.ReactApplicationContext; 8 | import com.facebook.react.bridge.ReactContext; 9 | import com.facebook.react.bridge.ReactContextBaseJavaModule; 10 | import com.facebook.react.bridge.ReactMethod; 11 | import android.os.Build; 12 | import java.util.Map; 13 | import java.util.HashMap; 14 | import android.view.View; 15 | import java.lang.ref.WeakReference; 16 | 17 | public class AppBrightness extends ReactContextBaseJavaModule { 18 | 19 | private static final String DURATION_SHORT_KEY = "SHORT"; 20 | private static final String DURATION_LONG_KEY = "LONG"; 21 | private static WeakReference activity; 22 | public AppBrightness(ReactApplicationContext reactContext) { 23 | super(reactContext); 24 | } 25 | 26 | @Override 27 | public String getName() { 28 | return "AppBrightness"; 29 | } 30 | 31 | @Override 32 | public Map getConstants() { 33 | final Map constants = new HashMap<>(); 34 | constants.put(DURATION_SHORT_KEY, Toast.LENGTH_SHORT); 35 | constants.put(DURATION_LONG_KEY, Toast.LENGTH_LONG); 36 | return constants; 37 | } 38 | 39 | 40 | 41 | @ReactMethod 42 | 43 | public void setAppBrightness(float brightnessPercent) { 44 | SetAppBrightness.goSetAppBrightness(getCurrentActivity(),brightnessPercent); 45 | } 46 | 47 | 48 | 49 | 50 | } -------------------------------------------------------------------------------- /android/src/main/java/com/ngxu/videoplayer/HideBottomNa.java: -------------------------------------------------------------------------------- 1 | package com.ngxu.videoplayer; 2 | 3 | import android.widget.Toast; 4 | import android.app.Activity; 5 | import android.content.Context; 6 | import com.facebook.react.bridge.NativeModule; 7 | import com.facebook.react.bridge.ReactApplicationContext; 8 | import com.facebook.react.bridge.ReactContext; 9 | import com.facebook.react.bridge.ReactContextBaseJavaModule; 10 | import com.facebook.react.bridge.ReactMethod; 11 | import android.os.Build; 12 | import java.util.Map; 13 | import java.util.HashMap; 14 | import android.view.View; 15 | import java.lang.ref.WeakReference; 16 | 17 | public class HideBottomNa extends ReactContextBaseJavaModule { 18 | 19 | private static final String DURATION_SHORT_KEY = "SHORT"; 20 | private static final String DURATION_LONG_KEY = "LONG"; 21 | private static WeakReference activity; 22 | public HideBottomNa(ReactApplicationContext reactContext) { 23 | super(reactContext); 24 | } 25 | 26 | @Override 27 | public String getName() { 28 | return "HideBottomNa"; 29 | } 30 | 31 | @Override 32 | public Map getConstants() { 33 | final Map constants = new HashMap<>(); 34 | constants.put(DURATION_SHORT_KEY, Toast.LENGTH_SHORT); 35 | constants.put(DURATION_LONG_KEY, Toast.LENGTH_LONG); 36 | return constants; 37 | } 38 | 39 | 40 | /** 41 | * 要导出一个方法给JavaScript使用,Java方法需要使用注解@ReactMethod。方法的返回类型必须为void。 42 | * @param message 43 | * @param duration 44 | */ 45 | @ReactMethod 46 | 47 | public void hide() { 48 | HeidBottomBtn.goHide(getCurrentActivity(),"123"); 49 | } 50 | 51 | @ReactMethod 52 | 53 | public void show() { 54 | HeidBottomBtn.goShow(getCurrentActivity(),"123"); 55 | } 56 | 57 | 58 | 59 | } -------------------------------------------------------------------------------- /android/src/main/java/com/ngxu/videoplayer/HeidBottomBtn.java: -------------------------------------------------------------------------------- 1 | package com.ngxu.videoplayer; 2 | import android.os.Build; 3 | import android.view.View; 4 | import android.app.Activity; 5 | import java.lang.ref.WeakReference; 6 | import android.view.View; 7 | import android.graphics.Color; 8 | import android.view.WindowManager; 9 | import android.view.Window; 10 | public class HeidBottomBtn { 11 | 12 | private static WeakReference mActivity; 13 | public static void goHide( Activity activity,String message) { 14 | 15 | 16 | 17 | mActivity=new WeakReference(activity); 18 | 19 | if (activity == null) { 20 | if (mActivity == null) { 21 | return; 22 | } 23 | activity = mActivity.get(); 24 | } 25 | 26 | if (activity == null) return; 27 | 28 | final Activity _activity = activity; 29 | 30 | _activity.runOnUiThread(new Runnable() { 31 | @Override 32 | public void run() { 33 | //隐藏虚拟按键 34 | 35 | 36 | if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower api 37 | View v = _activity.getWindow().getDecorView(); 38 | v.setSystemUiVisibility(View.GONE); 39 | } else if (Build.VERSION.SDK_INT >= 19) { 40 | //for new api versions. 41 | View decorView = _activity.getWindow().getDecorView(); 42 | 43 | int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION //隐藏系统NavigationBar。 44 | | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 45 | |View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION 46 | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE 47 | | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY|View.SYSTEM_UI_FLAG_IMMERSIVE 48 | |View.SYSTEM_UI_FLAG_FULLSCREEN;//隐藏StatusBar。(>=api16) 49 | 50 | decorView.setSystemUiVisibility(uiOptions); 51 | //设置页面全屏显示 52 | if (Build.VERSION.SDK_INT >= 28) { 53 | WindowManager.LayoutParams lp = _activity.getWindow().getAttributes(); 54 | lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; 55 | //设置页面延伸到刘海区显示 56 | _activity.getWindow().setAttributes(lp); 57 | } 58 | } 59 | 60 | } 61 | }); 62 | 63 | // Toast.makeText(getReactApplicationContext(), message, duration).show(); 64 | 65 | } 66 | 67 | 68 | 69 | public static void goShow( Activity activity,String message) { 70 | 71 | 72 | 73 | mActivity=new WeakReference(activity); 74 | 75 | if (activity == null) { 76 | if (mActivity == null) { 77 | return; 78 | } 79 | activity = mActivity.get(); 80 | } 81 | 82 | if (activity == null) return; 83 | 84 | final Activity _activity = activity; 85 | 86 | _activity.runOnUiThread(new Runnable() { 87 | @Override 88 | public void run() { 89 | 90 | 91 | 92 | //显示虚拟按键 93 | if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { 94 | //低版本sdk 95 | View v = _activity.getWindow().getDecorView(); 96 | v.setSystemUiVisibility(View.VISIBLE); 97 | } else if (Build.VERSION.SDK_INT >= 19) { 98 | View decorView = _activity.getWindow().getDecorView(); 99 | int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN; 100 | decorView.setSystemUiVisibility(uiOptions); 101 | } 102 | 103 | 104 | } 105 | }); 106 | 107 | // Toast.makeText(getReactApplicationContext(), message, duration).show(); 108 | 109 | } 110 | 111 | 112 | } -------------------------------------------------------------------------------- /ios/RNIndicator.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | B3E7B58A1CC2AC0600A0062D /* RNIndicator.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* RNIndicator.m */; }; 11 | /* End PBXBuildFile section */ 12 | 13 | /* Begin PBXCopyFilesBuildPhase section */ 14 | 58B511D91A9E6C8500147676 /* CopyFiles */ = { 15 | isa = PBXCopyFilesBuildPhase; 16 | buildActionMask = 2147483647; 17 | dstPath = "include/$(PRODUCT_NAME)"; 18 | dstSubfolderSpec = 16; 19 | files = ( 20 | ); 21 | runOnlyForDeploymentPostprocessing = 0; 22 | }; 23 | /* End PBXCopyFilesBuildPhase section */ 24 | 25 | /* Begin PBXFileReference section */ 26 | 134814201AA4EA6300B7C361 /* libRNIndicator.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNIndicator.a; sourceTree = BUILT_PRODUCTS_DIR; }; 27 | B3E7B5881CC2AC0600A0062D /* RNIndicator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNIndicator.h; sourceTree = ""; }; 28 | B3E7B5891CC2AC0600A0062D /* RNIndicator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNIndicator.m; sourceTree = ""; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | 58B511D81A9E6C8500147676 /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | ); 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXFrameworksBuildPhase section */ 40 | 41 | /* Begin PBXGroup section */ 42 | 134814211AA4EA7D00B7C361 /* Products */ = { 43 | isa = PBXGroup; 44 | children = ( 45 | 134814201AA4EA6300B7C361 /* libRNIndicator.a */, 46 | ); 47 | name = Products; 48 | sourceTree = ""; 49 | }; 50 | 58B511D21A9E6C8500147676 = { 51 | isa = PBXGroup; 52 | children = ( 53 | B3E7B5881CC2AC0600A0062D /* RNIndicator.h */, 54 | B3E7B5891CC2AC0600A0062D /* RNIndicator.m */, 55 | 134814211AA4EA7D00B7C361 /* Products */, 56 | ); 57 | sourceTree = ""; 58 | }; 59 | /* End PBXGroup section */ 60 | 61 | /* Begin PBXNativeTarget section */ 62 | 58B511DA1A9E6C8500147676 /* RNIndicator */ = { 63 | isa = PBXNativeTarget; 64 | buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNIndicator" */; 65 | buildPhases = ( 66 | 58B511D71A9E6C8500147676 /* Sources */, 67 | 58B511D81A9E6C8500147676 /* Frameworks */, 68 | 58B511D91A9E6C8500147676 /* CopyFiles */, 69 | ); 70 | buildRules = ( 71 | ); 72 | dependencies = ( 73 | ); 74 | name = RNIndicator; 75 | productName = RCTDataManager; 76 | productReference = 134814201AA4EA6300B7C361 /* libRNIndicator.a */; 77 | productType = "com.apple.product-type.library.static"; 78 | }; 79 | /* End PBXNativeTarget section */ 80 | 81 | /* Begin PBXProject section */ 82 | 58B511D31A9E6C8500147676 /* Project object */ = { 83 | isa = PBXProject; 84 | attributes = { 85 | LastUpgradeCheck = 0830; 86 | ORGANIZATIONNAME = Facebook; 87 | TargetAttributes = { 88 | 58B511DA1A9E6C8500147676 = { 89 | CreatedOnToolsVersion = 6.1.1; 90 | }; 91 | }; 92 | }; 93 | buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNIndicator" */; 94 | compatibilityVersion = "Xcode 3.2"; 95 | developmentRegion = English; 96 | hasScannedForEncodings = 0; 97 | knownRegions = ( 98 | en, 99 | ); 100 | mainGroup = 58B511D21A9E6C8500147676; 101 | productRefGroup = 58B511D21A9E6C8500147676; 102 | projectDirPath = ""; 103 | projectRoot = ""; 104 | targets = ( 105 | 58B511DA1A9E6C8500147676 /* RNIndicator */, 106 | ); 107 | }; 108 | /* End PBXProject section */ 109 | 110 | /* Begin PBXSourcesBuildPhase section */ 111 | 58B511D71A9E6C8500147676 /* Sources */ = { 112 | isa = PBXSourcesBuildPhase; 113 | buildActionMask = 2147483647; 114 | files = ( 115 | B3E7B58A1CC2AC0600A0062D /* RNIndicator.m in Sources */, 116 | ); 117 | runOnlyForDeploymentPostprocessing = 0; 118 | }; 119 | /* End PBXSourcesBuildPhase section */ 120 | 121 | /* Begin XCBuildConfiguration section */ 122 | 58B511ED1A9E6C8500147676 /* Debug */ = { 123 | isa = XCBuildConfiguration; 124 | buildSettings = { 125 | ALWAYS_SEARCH_USER_PATHS = NO; 126 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 127 | CLANG_CXX_LIBRARY = "libc++"; 128 | CLANG_ENABLE_MODULES = YES; 129 | CLANG_ENABLE_OBJC_ARC = YES; 130 | CLANG_WARN_BOOL_CONVERSION = YES; 131 | CLANG_WARN_CONSTANT_CONVERSION = YES; 132 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 133 | CLANG_WARN_EMPTY_BODY = YES; 134 | CLANG_WARN_ENUM_CONVERSION = YES; 135 | CLANG_WARN_INFINITE_RECURSION = YES; 136 | CLANG_WARN_INT_CONVERSION = YES; 137 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 138 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 139 | CLANG_WARN_UNREACHABLE_CODE = YES; 140 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 141 | COPY_PHASE_STRIP = NO; 142 | ENABLE_STRICT_OBJC_MSGSEND = YES; 143 | ENABLE_TESTABILITY = YES; 144 | GCC_C_LANGUAGE_STANDARD = gnu99; 145 | GCC_DYNAMIC_NO_PIC = NO; 146 | GCC_NO_COMMON_BLOCKS = YES; 147 | GCC_OPTIMIZATION_LEVEL = 0; 148 | GCC_PREPROCESSOR_DEFINITIONS = ( 149 | "DEBUG=1", 150 | "$(inherited)", 151 | ); 152 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 153 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 154 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 155 | GCC_WARN_UNDECLARED_SELECTOR = YES; 156 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 157 | GCC_WARN_UNUSED_FUNCTION = YES; 158 | GCC_WARN_UNUSED_VARIABLE = YES; 159 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 160 | MTL_ENABLE_DEBUG_INFO = YES; 161 | ONLY_ACTIVE_ARCH = YES; 162 | SDKROOT = iphoneos; 163 | }; 164 | name = Debug; 165 | }; 166 | 58B511EE1A9E6C8500147676 /* Release */ = { 167 | isa = XCBuildConfiguration; 168 | buildSettings = { 169 | ALWAYS_SEARCH_USER_PATHS = NO; 170 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 171 | CLANG_CXX_LIBRARY = "libc++"; 172 | CLANG_ENABLE_MODULES = YES; 173 | CLANG_ENABLE_OBJC_ARC = YES; 174 | CLANG_WARN_BOOL_CONVERSION = YES; 175 | CLANG_WARN_CONSTANT_CONVERSION = YES; 176 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 177 | CLANG_WARN_EMPTY_BODY = YES; 178 | CLANG_WARN_ENUM_CONVERSION = YES; 179 | CLANG_WARN_INFINITE_RECURSION = YES; 180 | CLANG_WARN_INT_CONVERSION = YES; 181 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 182 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 183 | CLANG_WARN_UNREACHABLE_CODE = YES; 184 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 185 | COPY_PHASE_STRIP = YES; 186 | ENABLE_NS_ASSERTIONS = NO; 187 | ENABLE_STRICT_OBJC_MSGSEND = YES; 188 | GCC_C_LANGUAGE_STANDARD = gnu99; 189 | GCC_NO_COMMON_BLOCKS = YES; 190 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 191 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 192 | GCC_WARN_UNDECLARED_SELECTOR = YES; 193 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 194 | GCC_WARN_UNUSED_FUNCTION = YES; 195 | GCC_WARN_UNUSED_VARIABLE = YES; 196 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 197 | MTL_ENABLE_DEBUG_INFO = NO; 198 | SDKROOT = iphoneos; 199 | VALIDATE_PRODUCT = YES; 200 | }; 201 | name = Release; 202 | }; 203 | 58B511F01A9E6C8500147676 /* Debug */ = { 204 | isa = XCBuildConfiguration; 205 | buildSettings = { 206 | HEADER_SEARCH_PATHS = ( 207 | "$(inherited)", 208 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 209 | "$(SRCROOT)/../../../React/**", 210 | "$(SRCROOT)/../../react-native/React/**", 211 | ); 212 | LIBRARY_SEARCH_PATHS = "$(inherited)"; 213 | OTHER_LDFLAGS = "-ObjC"; 214 | PRODUCT_NAME = RNIndicator; 215 | SKIP_INSTALL = YES; 216 | }; 217 | name = Debug; 218 | }; 219 | 58B511F11A9E6C8500147676 /* Release */ = { 220 | isa = XCBuildConfiguration; 221 | buildSettings = { 222 | HEADER_SEARCH_PATHS = ( 223 | "$(inherited)", 224 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 225 | "$(SRCROOT)/../../../React/**", 226 | "$(SRCROOT)/../../react-native/React/**", 227 | ); 228 | LIBRARY_SEARCH_PATHS = "$(inherited)"; 229 | OTHER_LDFLAGS = "-ObjC"; 230 | PRODUCT_NAME = RNIndicator; 231 | SKIP_INSTALL = YES; 232 | }; 233 | name = Release; 234 | }; 235 | /* End XCBuildConfiguration section */ 236 | 237 | /* Begin XCConfigurationList section */ 238 | 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNIndicator" */ = { 239 | isa = XCConfigurationList; 240 | buildConfigurations = ( 241 | 58B511ED1A9E6C8500147676 /* Debug */, 242 | 58B511EE1A9E6C8500147676 /* Release */, 243 | ); 244 | defaultConfigurationIsVisible = 0; 245 | defaultConfigurationName = Release; 246 | }; 247 | 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNIndicator" */ = { 248 | isa = XCConfigurationList; 249 | buildConfigurations = ( 250 | 58B511F01A9E6C8500147676 /* Debug */, 251 | 58B511F11A9E6C8500147676 /* Release */, 252 | ); 253 | defaultConfigurationIsVisible = 0; 254 | defaultConfigurationName = Release; 255 | }; 256 | /* End XCConfigurationList section */ 257 | }; 258 | rootObject = 58B511D31A9E6C8500147676 /* Project object */; 259 | } 260 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 已废弃不会更新,不推荐使用(由于没有mac设备等问题) 2 | 3 | # 已废弃不会更新,不推荐使用(由于没有mac设备等问题) 4 | 5 | # 已废弃不会更新,不推荐使用(由于没有mac设备等问题) 6 | 7 | # 已废弃不会更新,不推荐使用(由于没有mac设备等问题) 8 | 9 | 10 | 11 | # react-native-rn-videoplayer 12 | 13 | 14 | 15 | 16 | - 视频上下滑动调节音量、屏幕亮度、长按左右两边快进退、左右滑动以及拖动进度条调节视频进度,视频控件锁定,全屏切换,缓冲进度,双击视频暂停,等功能,基于react-native-video 17 | - ps:Android改变亮度无需获取高级权限,只改变当前active也就是当前页面的亮度,改变亮度后,返回进入到其他页面会恢复到原来的亮度。 18 | 19 | - 如果你的视频全屏后尺寸没发生改变,参考[全屏尺寸问题18](https://github.com/A-ANing/react-native-rn-videoplayer/issues/18) 20 | 21 | - Version 2.x requires react-native >= 0.60.0 22 | - Version 1.3.2 requires react-native <= 0.59.9 23 | 24 | 25 |

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

26 | 27 | 28 | ## gif预览 [ios](https://vkceyugu.cdn.bspapp.com/VKCEYUGU-imgbed/43621fcd-e016-4f94-967e-47000082529c.gif) 和 [android](https://vkceyugu.cdn.bspapp.com/VKCEYUGU-imgbed/683885c8-fcfd-4434-88b3-f52e90ccfc7f.gif) 不是最新版 29 | 30 |      31 | 32 | 33 | # 增加功能 34 | 35 | - v2.2.10 支持左右两边长按快进退,返回按钮右边显示视频名字、自定义缓冲提示图标和文字、暂停文字、快进退的文字! 36 | 37 |      38 | 39 | 40 | 41 | - v2.2.9 showSmallCont={false}小屏是否显示返回按钮,默认为true; 自定义进度条颜色(见api) 42 | 43 | - v2.2.8 当ios设备为iPhone X以上,全屏时隐藏底部小横条 44 | 45 | - v2.2.5 autoPlay={false}是否自动播放,默认为true 46 | 47 | - v2.2.1 增加手势左右滑动视频区域(非进度条上的点)来调整视频进度 48 | 49 | - v2.0.8 自定义小屏状态栏 类型fun 50 | 默认状态栏为沉浸式,黑底白字,有状态栏高度,可查看view/index.js 的Header组件 51 | ``` 52 | null}//不使用默认状态栏 跟当前app保持一致 54 | statusBar={()=>}//自定义 55 | /> 56 | ``` 57 | 58 | - v2.0.6 增加锁定视频控件,锁定用户操作(调节音量/亮度,展示隐藏控件) 59 | 60 | ` 61 | lockControl (true/false 默认关闭) 62 | ` 63 | 64 |      65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | ## Getting started 81 | 1. 82 | ```shell 83 | npm install react-native-rn-videoplayer --save 84 | ``` 85 | 86 | 2. 87 | ## - - android 88 | 89 | Open up `android/app/src/main/java/[...]/MainActivity.java` 90 | 91 | ```diff 92 | +import android.content.Intent; 93 | +import android.content.res.Configuration; 94 | public class MainActivity extends ReactActivity { 95 | 96 | ... 97 | 98 | + @Override 99 | + public void onConfigurationChanged(Configuration newConfig) { 100 | + super.onConfigurationChanged(newConfig); 101 | + Intent intent = new Intent("onConfigurationChanged"); 102 | + intent.putExtra("newConfig", newConfig); 103 | + this.sendBroadcast(intent); 104 | + } 105 | ... 106 | } 107 | ``` 108 | 109 | ## - - iOS 110 | 111 | Add the following to your project's `AppDelegate.m`: 112 | 113 | ```diff 114 | +#import "Orientation.h" 115 | +#import 116 | 117 | @implementation AppDelegate 118 | 119 | // ... 120 | 121 | +- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { 122 | + return [Orientation getOrientation]; 123 | +} 124 | 125 | //找到这行 126 | UIViewController *rootViewController = [UIViewController new]; 127 | 128 | //改为 129 | UIViewController *rootViewController = [HomeIndicatorView new]; 130 | 131 | 132 | @end 133 | ``` 134 | 135 | ## RN >= 0.60 136 | 137 | ### ios 138 | ``` 139 | cd ios 140 | 141 | pod install 142 | ``` 143 | 144 | ### Android. 145 | #### Most of them are automatically linked. If you can’t find XX, you should link manually 146 | - settings.gradle 147 | ```diff 148 | rootProject.name = 'TestPack622' 149 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 150 | 151 | + include ':react-native-linear-gradient' 152 | + project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linear-gradient/android') 153 | + include ':react-native-svg' 154 | + project(':react-native-svg').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-svg/android') 155 | + include ':react-native-orientation-locker' 156 | + project(':react-native-orientation-locker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-orientation-locker/android') 157 | + include ':react-native-video' 158 | + project(':react-native-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android-exoplayer') 159 | + include ':react-native-system-setting' 160 | + project(':react-native-system-setting').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-system-setting/android') 161 | 162 | include ':app' 163 | ``` 164 | 165 | - MainApplication.java 166 | 167 | ```diff 168 | 169 | + import com.horcrux.svg.SvgPackage; 170 | + import com.BV.LinearGradient.LinearGradientPackage; // <--- This! 171 | + import org.wonday.orientation.OrientationPackage; 172 | + import com.ninty.system.setting.SystemSettingPackage; 173 | + import com.brentvatne.react.ReactVideoPackage; 174 | 175 | 176 | ··· 177 | @Override 178 | protected List getPackages() { 179 | @SuppressWarnings("UnnecessaryLocalVariable") 180 | List packages = new PackageList(this).getPackages(); 181 | // Packages that cannot be autolinked yet can be added manually here, for example: 182 | + packages.add(new LinearGradientPackage()); 183 | + packages.add(new SvgPackage()); 184 | + packages.add(new OrientationPackage()); 185 | + packages.add(new SystemSettingPackage()); 186 | + packages.add(new ReactVideoPackage()); 187 | return packages; 188 | } 189 | ··· 190 | 191 | ``` 192 | 193 | - app/build.gradle 194 | 195 | ```diff 196 | dependencies { 197 | + implementation project(':react-native-svg') 198 | + implementation project(':react-native-linear-gradient') 199 | + implementation project(':react-native-orientation-locker') 200 | + implementation project(':react-native-system-setting') 201 | + implementation project(':react-native-video') 202 | } 203 | 204 | ``` 205 | 206 | 207 | ## RN <= 0.59 208 | 209 | 210 | ```shell 211 | react-native link react-native-linear-gradient 212 | react-native link react-native-orientation-locker 213 | react-native link react-native-svg 214 | react-native link react-native-system-setting 215 | react-native link react-native-video 216 | ``` 217 | 218 | #### Android 219 | 220 | 221 | 222 | 1. Append the following lines to `android/settings.gradle`: 223 | ``` javascript 224 | include ':react-native-rn-videoplayer' 225 | project(':react-native-rn-videoplayer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-rn-videoplayer/android') 226 | ``` 227 | 2. Insert the following lines inside the dependencies block in `android/app/build.gradle`: 228 | ``` 229 | compile project(':react-native-rn-videoplayer') 230 | ``` 231 | 232 | 3. Open up `android/app/src/main/java/[...]/MainApplication.java` 233 | 234 | - Add 235 | ```java 236 | import com.ngxu.videoplayer.RNVideoplayerPackage; 237 | 238 | new RNVideoplayerPackage() //to the list returned by the `getPackages()` method 239 | ``` 240 | 241 | 242 | 243 | 244 | ## Usage 245 | ```javascript 246 | import VideoPlayer from 'react-native-rn-videoplayer'; 247 | 248 | this.player=ref} 253 | lockControl={true}//控件锁定功能 v2.0.6增加 254 | moreSetting={() => null}//右上角更多按钮 输出null则不显示 255 | onSmallBack={()=>{this.props.navigation.goBack()}} 256 | /> 257 | 258 | ``` 259 | # api 260 | - url 视频地址 261 | - showSmallCont={bool} 小屏是否隐藏返回按钮 默认false; 262 | - changeWindows() 切换全屏或者小屏 263 | 264 | changeWindows(boolean) true 全屏, false 小屏 265 | 266 | Example: 267 | ```javascript 268 | this.player=ref}/> 269 | this.player.changeWindows(true); // 全屏 270 | ``` 271 | 272 | - storeComponent 右上角收藏按钮的图标 273 | ```javascript 274 | storeComponent={()=>} 275 | ``` 276 | - moreSetting 右上角更多按钮的图标 277 | ```javascript 278 | moreSetting={()=>} 279 | ``` 280 | 281 | - speedColor 当前播放进度条颜色 "#e54602" 282 | 283 | - dotColor 进度条上的圆点颜色 "#e54602" 284 | 285 | - dotBorderColor 进度条上的圆点被按下时的边框颜色 "rgba(255,255,255,0.3)" 286 | 287 | - bottomSpeedColor 最底部播放进度的颜色 "#e54602" 288 | 289 | - cachColor 缓冲进度条颜色 "#ffffff" 290 | 291 | - allSpeedColor 整个进度条颜色 "rgba(0,0,0,0.4) 292 | 293 | - backVideoName 返回按钮旁的文字 string 294 | 295 | - pausedTipText 已暂停的文字 string 296 | 297 | - loadingText 正在缓冲的文字 string 298 | 299 | - loadingIcon 加载的图标 loadingIcon={<>} 300 | 301 | - solText 快退中的文字 string 302 | 303 | - fastText 快进中的文字 string 304 | 305 | 306 | - setPaused 播放暂停 307 | ```javascript 308 | this.player.setPaused(true)//true暂停;false播放; 309 | 310 | this.player=ref} 312 | > 313 | 314 | ``` 315 | - reLoad 重新加载 316 | ```javascript 317 | this.player.reLoad() 318 | 319 | this.player=ref} 321 | > 322 | 323 | ``` 324 | 325 | - rePlay 重置进度为0 326 | ```javascript 327 | 328 | this.player.reLoad(false) 329 | //false 不自动播放 330 | //默认为true 自动播放 331 | ``` 332 | 333 | - onSmallBack 当视频是小窗口时 点击返回按钮的回调 可以在此添加返回上个页面的功能 func 334 | - onStore 点击右上角收藏按钮的回调 func 335 | - onMoreFun 点击右上角更多按钮的回调 func 336 | - onWindowChange 窗口改变的回调 func 337 | ```javascript 338 | 339 | {}}//e:"full"全屏 "small"小屏 341 | > 342 | 343 | ``` 344 | 345 | - continuous 是否开启全屏时的选集功能 适合连续剧 默认 false 346 | ```js 347 | continuous={true} 348 | ``` 349 | 350 | - renderAllSeenList 点击选集后显示的集数列表 351 | ```js 352 | ··· 353 | this.player=ref} 356 | renderAllSeenList={this.renderAllSeenList} 357 | /> 358 | 359 | ··· 360 | renderAllSeenList = () => ( 361 | 362 | 363 |