createViewManagers(ReactApplicationContext reactContext) {
22 | return Collections.emptyList();
23 | }
24 | }
--------------------------------------------------------------------------------
/example/.buckconfig:
--------------------------------------------------------------------------------
1 |
2 | [android]
3 | target = Google Inc.:Google APIs:23
4 |
5 | [maven_repositories]
6 | central = https://repo1.maven.org/maven2
7 |
--------------------------------------------------------------------------------
/example/.gitattributes:
--------------------------------------------------------------------------------
1 | *.pbxproj -text
2 |
--------------------------------------------------------------------------------
/example/.gitignore:
--------------------------------------------------------------------------------
1 | # OSX
2 | #
3 | .DS_Store
4 |
5 | # Xcode
6 | #
7 | build/
8 | *.pbxuser
9 | !default.pbxuser
10 | *.mode1v3
11 | !default.mode1v3
12 | *.mode2v3
13 | !default.mode2v3
14 | *.perspectivev3
15 | !default.perspectivev3
16 | xcuserdata
17 | *.xccheckout
18 | *.moved-aside
19 | DerivedData
20 | *.hmap
21 | *.ipa
22 | *.xcuserstate
23 | project.xcworkspace
24 |
25 | # Android/IntelliJ
26 | #
27 | build/
28 | .idea
29 | .gradle
30 | local.properties
31 | *.iml
32 | *.hprof
33 |
34 | # node.js
35 | #
36 | node_modules/
37 | npm-debug.log
38 | yarn-error.log
39 |
40 | # BUCK
41 | buck-out/
42 | \.buckd/
43 | *.keystore
44 | !debug.keystore
45 |
46 | # Bundle artifacts
47 | *.jsbundle
48 |
49 | # CocoaPods
50 | /ios/Pods/
51 |
52 | # Expo
53 | .expo/
54 | web-build/
55 | dist/
56 |
--------------------------------------------------------------------------------
/example/App.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | import Main from "./src/Main";
4 |
5 | export default function App() {
6 | return ;
7 | }
8 |
--------------------------------------------------------------------------------
/example/android/app/BUCK:
--------------------------------------------------------------------------------
1 | # To learn about Buck see [Docs](https://buckbuild.com/).
2 | # To run your application with Buck:
3 | # - install Buck
4 | # - `npm start` - to start the packager
5 | # - `cd android`
6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
8 | # - `buck install -r android/app` - compile, install and run application
9 | #
10 |
11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
12 |
13 | lib_deps = []
14 |
15 | create_aar_targets(glob(["libs/*.aar"]))
16 |
17 | create_jar_targets(glob(["libs/*.jar"]))
18 |
19 | android_library(
20 | name = "all-libs",
21 | exported_deps = lib_deps,
22 | )
23 |
24 | android_library(
25 | name = "app-code",
26 | srcs = glob([
27 | "src/main/java/**/*.java",
28 | ]),
29 | deps = [
30 | ":all-libs",
31 | ":build_config",
32 | ":res",
33 | ],
34 | )
35 |
36 | android_build_config(
37 | name = "build_config",
38 | package = "com.example",
39 | )
40 |
41 | android_resource(
42 | name = "res",
43 | package = "com.example",
44 | res = "src/main/res",
45 | )
46 |
47 | android_binary(
48 | name = "app",
49 | keystore = "//android/keystores:debug",
50 | manifest = "src/main/AndroidManifest.xml",
51 | package_type = "debug",
52 | deps = [
53 | ":app-code",
54 | ],
55 | )
56 |
--------------------------------------------------------------------------------
/example/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "com.android.application"
2 |
3 | import com.android.build.OutputFile
4 |
5 | /**
6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
7 | * and bundleReleaseJsAndAssets).
8 | * These basically call `react-native bundle` with the correct arguments during the Android build
9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
10 | * bundle directly from the development server. Below you can see all the possible configurations
11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the
12 | * `apply from: "../../node_modules/react-native/react.gradle"` line.
13 | *
14 | * project.ext.react = [
15 | * // the name of the generated asset file containing your JS bundle
16 | * bundleAssetName: "index.android.bundle",
17 | *
18 | * // the entry file for bundle generation. If none specified and
19 | * // "index.android.js" exists, it will be used. Otherwise "index.js" is
20 | * // default. Can be overridden with ENTRY_FILE environment variable.
21 | * entryFile: "index.android.js",
22 | *
23 | * // https://reactnative.dev/docs/performance#enable-the-ram-format
24 | * bundleCommand: "ram-bundle",
25 | *
26 | * // whether to bundle JS and assets in debug mode
27 | * bundleInDebug: false,
28 | *
29 | * // whether to bundle JS and assets in release mode
30 | * bundleInRelease: true,
31 | *
32 | * // whether to bundle JS and assets in another build variant (if configured).
33 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
34 | * // The configuration property can be in the following formats
35 | * // 'bundleIn${productFlavor}${buildType}'
36 | * // 'bundleIn${buildType}'
37 | * // bundleInFreeDebug: true,
38 | * // bundleInPaidRelease: true,
39 | * // bundleInBeta: true,
40 | *
41 | * // whether to disable dev mode in custom build variants (by default only disabled in release)
42 | * // for example: to disable dev mode in the staging build type (if configured)
43 | * devDisabledInStaging: true,
44 | * // The configuration property can be in the following formats
45 | * // 'devDisabledIn${productFlavor}${buildType}'
46 | * // 'devDisabledIn${buildType}'
47 | *
48 | * // the root of your project, i.e. where "package.json" lives
49 | * root: "../../",
50 | *
51 | * // where to put the JS bundle asset in debug mode
52 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
53 | *
54 | * // where to put the JS bundle asset in release mode
55 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release",
56 | *
57 | * // where to put drawable resources / React Native assets, e.g. the ones you use via
58 | * // require('./image.png')), in debug mode
59 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
60 | *
61 | * // where to put drawable resources / React Native assets, e.g. the ones you use via
62 | * // require('./image.png')), in release mode
63 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
64 | *
65 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means
66 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
67 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle
68 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
69 | * // for example, you might want to remove it from here.
70 | * inputExcludes: ["android/**", "ios/**"],
71 | *
72 | * // override which node gets called and with what additional arguments
73 | * nodeExecutableAndArgs: ["node"],
74 | *
75 | * // supply additional arguments to the packager
76 | * extraPackagerArgs: []
77 | * ]
78 | */
79 |
80 | project.ext.react = [
81 | enableHermes: (findProperty('expo.jsEngine') ?: "jsc") == "hermes",
82 | cliPath: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/cli.js",
83 | hermesCommand: new File(["node", "--print", "require.resolve('hermes-engine/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/%OS-BIN%/hermesc",
84 | composeSourceMapsPath: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/scripts/compose-source-maps.js",
85 | ]
86 |
87 | apply from: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../react.gradle")
88 |
89 | /**
90 | * Set this to true to create two separate APKs instead of one:
91 | * - An APK that only works on ARM devices
92 | * - An APK that only works on x86 devices
93 | * The advantage is the size of the APK is reduced by about 4MB.
94 | * Upload all the APKs to the Play Store and people will download
95 | * the correct one based on the CPU architecture of their device.
96 | */
97 | def enableSeparateBuildPerCPUArchitecture = false
98 |
99 | /**
100 | * Run Proguard to shrink the Java bytecode in release builds.
101 | */
102 | def enableProguardInReleaseBuilds = false
103 |
104 | /**
105 | * The preferred build flavor of JavaScriptCore.
106 | *
107 | * For example, to use the international variant, you can use:
108 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
109 | *
110 | * The international variant includes ICU i18n library and necessary data
111 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
112 | * give correct results when using with locales other than en-US. Note that
113 | * this variant is about 6MiB larger per architecture than default.
114 | */
115 | def jscFlavor = 'org.webkit:android-jsc:+'
116 |
117 | /**
118 | * Whether to enable the Hermes VM.
119 | *
120 | * This should be set on project.ext.react and mirrored here. If it is not set
121 | * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
122 | * and the benefits of using Hermes will therefore be sharply reduced.
123 | */
124 | def enableHermes = project.ext.react.get("enableHermes", false);
125 |
126 | android {
127 | compileSdkVersion rootProject.ext.compileSdkVersion
128 |
129 | compileOptions {
130 | sourceCompatibility JavaVersion.VERSION_1_8
131 | targetCompatibility JavaVersion.VERSION_1_8
132 | }
133 |
134 | defaultConfig {
135 | applicationId "com.example"
136 | minSdkVersion rootProject.ext.minSdkVersion
137 | targetSdkVersion rootProject.ext.targetSdkVersion
138 | versionCode 1
139 | versionName "1.0"
140 | }
141 | splits {
142 | abi {
143 | reset()
144 | enable enableSeparateBuildPerCPUArchitecture
145 | universalApk false // If true, also generate a universal APK
146 | include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
147 | }
148 | }
149 | signingConfigs {
150 | debug {
151 | storeFile file('debug.keystore')
152 | storePassword 'android'
153 | keyAlias 'androiddebugkey'
154 | keyPassword 'android'
155 | }
156 | }
157 | buildTypes {
158 | debug {
159 | signingConfig signingConfigs.debug
160 | }
161 | release {
162 | // Caution! In production, you need to generate your own keystore file.
163 | // see https://reactnative.dev/docs/signed-apk-android.
164 | signingConfig signingConfigs.debug
165 | minifyEnabled enableProguardInReleaseBuilds
166 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
167 | }
168 | }
169 |
170 | // applicationVariants are e.g. debug, release
171 | applicationVariants.all { variant ->
172 | variant.outputs.each { output ->
173 | // For each separate APK per architecture, set a unique version code as described here:
174 | // https://developer.android.com/studio/build/configure-apk-splits.html
175 | def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
176 | def abi = output.getFilter(OutputFile.ABI)
177 | if (abi != null) { // null for the universal-debug, universal-release variants
178 | output.versionCodeOverride =
179 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
180 | }
181 |
182 | }
183 | }
184 | }
185 |
186 | dependencies {
187 | implementation fileTree(dir: "libs", include: ["*.jar"])
188 | //noinspection GradleDynamicVersion
189 | implementation "com.facebook.react:react-native:+" // From node_modules
190 |
191 | def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
192 | def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true";
193 | def isWebpAnimatedEnabled = (findProperty('expo.webp.animated') ?: "") == "true";
194 |
195 | // If your app supports Android versions before Ice Cream Sandwich (API level 14)
196 | // All fresco packages should use the same version
197 | if (isGifEnabled || isWebpEnabled) {
198 | implementation 'com.facebook.fresco:fresco:2.0.0'
199 | implementation 'com.facebook.fresco:imagepipeline-okhttp3:2.0.0'
200 | }
201 |
202 | if (isGifEnabled) {
203 | // For animated gif support
204 | implementation 'com.facebook.fresco:animated-gif:2.0.0'
205 | }
206 |
207 | if (isWebpEnabled) {
208 | // For webp support
209 | implementation 'com.facebook.fresco:webpsupport:2.0.0'
210 | if (isWebpAnimatedEnabled) {
211 | // Animated webp support
212 | implementation 'com.facebook.fresco:animated-webp:2.0.0'
213 | }
214 | }
215 |
216 | implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
217 | implementation 'com.googlecode.mp4parser:isoparser:1.1.21'
218 | debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
219 | exclude group:'com.facebook.fbjni'
220 | }
221 | debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
222 | exclude group:'com.facebook.flipper'
223 | exclude group:'com.squareup.okhttp3', module:'okhttp'
224 | }
225 | debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
226 | exclude group:'com.facebook.flipper'
227 | }
228 |
229 | if (enableHermes) {
230 | debugImplementation files(new File(["node", "--print", "require.resolve('hermes-engine/package.json')"].execute(null, rootDir).text.trim(), "../android/hermes-debug.aar"))
231 | releaseImplementation files(new File(["node", "--print", "require.resolve('hermes-engine/package.json')"].execute(null, rootDir).text.trim(), "../android/hermes-release.aar"))
232 | } else {
233 | implementation jscFlavor
234 | }
235 | }
236 |
237 | // Run this once to be able to run the application with BUCK
238 | // puts all compile dependencies into folder libs for BUCK to use
239 | task copyDownloadableDepsToLibs(type: Copy) {
240 | from configurations.compile
241 | into 'libs'
242 | }
243 |
244 | apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
245 | applyNativeModulesAppBuildGradle(project)
246 |
--------------------------------------------------------------------------------
/example/android/app/build_defs.bzl:
--------------------------------------------------------------------------------
1 | """Helper definitions to glob .aar and .jar targets"""
2 |
3 | def create_aar_targets(aarfiles):
4 | for aarfile in aarfiles:
5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
6 | lib_deps.append(":" + name)
7 | android_prebuilt_aar(
8 | name = name,
9 | aar = aarfile,
10 | )
11 |
12 | def create_jar_targets(jarfiles):
13 | for jarfile in jarfiles:
14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
15 | lib_deps.append(":" + name)
16 | prebuilt_jar(
17 | name = name,
18 | binary_jar = jarfile,
19 | )
20 |
--------------------------------------------------------------------------------
/example/android/app/debug.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lklima/react-native-video-manager/7293e73f047baf7f566305dda6d9e59105ece84f/example/android/app/debug.keystore
--------------------------------------------------------------------------------
/example/android/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
--------------------------------------------------------------------------------
/example/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/android/app/src/debug/java/com/example/ReactNativeFlipper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) Facebook, Inc. and its affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the LICENSE file in the root
5 | * directory of this source tree.
6 | */
7 | package com.example;
8 |
9 | import android.content.Context;
10 | import com.facebook.flipper.android.AndroidFlipperClient;
11 | import com.facebook.flipper.android.utils.FlipperUtils;
12 | import com.facebook.flipper.core.FlipperClient;
13 | import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
14 | import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
15 | import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
16 | import com.facebook.flipper.plugins.inspector.DescriptorMapping;
17 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
18 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
19 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
20 | import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
21 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
22 | import com.facebook.react.ReactInstanceManager;
23 | import com.facebook.react.bridge.ReactContext;
24 | import com.facebook.react.modules.network.NetworkingModule;
25 | import okhttp3.OkHttpClient;
26 |
27 | public class ReactNativeFlipper {
28 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
29 | if (FlipperUtils.shouldEnableFlipper(context)) {
30 | final FlipperClient client = AndroidFlipperClient.getInstance(context);
31 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
32 | client.addPlugin(new ReactFlipperPlugin());
33 | client.addPlugin(new DatabasesFlipperPlugin(context));
34 | client.addPlugin(new SharedPreferencesFlipperPlugin(context));
35 | client.addPlugin(CrashReporterPlugin.getInstance());
36 | NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
37 | NetworkingModule.setCustomClientBuilder(
38 | new NetworkingModule.CustomClientBuilder() {
39 | @Override
40 | public void apply(OkHttpClient.Builder builder) {
41 | builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
42 | }
43 | });
44 | client.addPlugin(networkFlipperPlugin);
45 | client.start();
46 | // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
47 | // Hence we run if after all native modules have been initialized
48 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
49 | if (reactContext == null) {
50 | reactInstanceManager.addReactInstanceEventListener(
51 | new ReactInstanceManager.ReactInstanceEventListener() {
52 | @Override
53 | public void onReactContextInitialized(ReactContext reactContext) {
54 | reactInstanceManager.removeReactInstanceEventListener(this);
55 | reactContext.runOnNativeModulesQueueThread(
56 | new Runnable() {
57 | @Override
58 | public void run() {
59 | client.addPlugin(new FrescoFlipperPlugin());
60 | }
61 | });
62 | }
63 | });
64 | } else {
65 | client.addPlugin(new FrescoFlipperPlugin());
66 | }
67 | }
68 | }
69 | }
--------------------------------------------------------------------------------
/example/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/com/example/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example;
2 |
3 | import android.os.Build;
4 | import android.os.Bundle;
5 |
6 | import com.facebook.react.ReactActivity;
7 | import com.facebook.react.ReactActivityDelegate;
8 | import com.facebook.react.ReactRootView;
9 |
10 | import expo.modules.ReactActivityDelegateWrapper;
11 |
12 | public class MainActivity extends ReactActivity {
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | // Set the theme to AppTheme BEFORE onCreate to support
16 | // coloring the background, status bar, and navigation bar.
17 | // This is required for expo-splash-screen.
18 | setTheme(R.style.AppTheme);
19 | super.onCreate(null);
20 | }
21 |
22 | /**
23 | * Returns the name of the main component registered from JavaScript.
24 | * This is used to schedule rendering of the component.
25 | */
26 | @Override
27 | protected String getMainComponentName() {
28 | return "main";
29 | }
30 |
31 | @Override
32 | protected ReactActivityDelegate createReactActivityDelegate() {
33 | return new ReactActivityDelegateWrapper(this,
34 | new ReactActivityDelegate(this, getMainComponentName())
35 | );
36 | }
37 |
38 | /**
39 | * Align the back button behavior with Android S
40 | * where moving root activities to background instead of finishing activities.
41 | * @see onBackPressed
42 | */
43 | @Override
44 | public void invokeDefaultOnBackPressed() {
45 | if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
46 | if (!moveTaskToBack(false)) {
47 | // For non-root activities, use the default implementation to finish them.
48 | super.invokeDefaultOnBackPressed();
49 | }
50 | return;
51 | }
52 |
53 | // Use the default back button implementation on Android S
54 | // because it's doing more than {@link Activity#moveTaskToBack} in fact.
55 | super.invokeDefaultOnBackPressed();
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/com/example/MainApplication.java:
--------------------------------------------------------------------------------
1 | package com.example;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 | import android.content.res.Configuration;
6 | import androidx.annotation.NonNull;
7 |
8 | import com.facebook.react.PackageList;
9 | import com.facebook.react.ReactApplication;
10 | import com.facebook.react.ReactInstanceManager;
11 | import com.facebook.react.ReactNativeHost;
12 | import com.facebook.react.ReactPackage;
13 | import com.facebook.soloader.SoLoader;
14 |
15 | import expo.modules.ApplicationLifecycleDispatcher;
16 | import expo.modules.ReactNativeHostWrapper;
17 |
18 | import com.facebook.react.bridge.JSIModulePackage;
19 |
20 | import java.lang.reflect.InvocationTargetException;
21 | import java.util.List;
22 |
23 | public class MainApplication extends Application implements ReactApplication {
24 | private final ReactNativeHost mReactNativeHost = new ReactNativeHostWrapper(
25 | this,
26 | new ReactNativeHost(this) {
27 | @Override
28 | public boolean getUseDeveloperSupport() {
29 | return BuildConfig.DEBUG;
30 | }
31 |
32 | @Override
33 | protected List getPackages() {
34 | @SuppressWarnings("UnnecessaryLocalVariable")
35 | List packages = new PackageList(this).getPackages();
36 | // Packages that cannot be autolinked yet can be added manually here, for example:
37 | // packages.add(new MyReactNativePackage());
38 | // packages.add(new RNVideoManagerPackage());
39 | return packages;
40 | }
41 |
42 | @Override
43 | protected String getJSMainModuleName() {
44 | return "index";
45 | }
46 | });
47 |
48 | @Override
49 | public ReactNativeHost getReactNativeHost() {
50 | return mReactNativeHost;
51 | }
52 |
53 | @Override
54 | public void onCreate() {
55 | super.onCreate();
56 | SoLoader.init(this, /* native exopackage */ false);
57 |
58 | initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
59 | ApplicationLifecycleDispatcher.onApplicationCreate(this);
60 | }
61 |
62 | @Override
63 | public void onConfigurationChanged(@NonNull Configuration newConfig) {
64 | super.onConfigurationChanged(newConfig);
65 | ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig);
66 | }
67 |
68 | /**
69 | * Loads Flipper in React Native templates. Call this in the onCreate method with something like
70 | * initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
71 | *
72 | * @param context
73 | * @param reactInstanceManager
74 | */
75 | private static void initializeFlipper(
76 | Context context, ReactInstanceManager reactInstanceManager) {
77 | if (BuildConfig.DEBUG) {
78 | try {
79 | /*
80 | We use reflection here to pick up the class that initializes Flipper,
81 | since Flipper library is not available in release mode
82 | */
83 | Class> aClass = Class.forName("com.example.ReactNativeFlipper");
84 | aClass
85 | .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
86 | .invoke(null, context, reactInstanceManager);
87 | } catch (ClassNotFoundException e) {
88 | e.printStackTrace();
89 | } catch (NoSuchMethodException e) {
90 | e.printStackTrace();
91 | } catch (IllegalAccessException e) {
92 | e.printStackTrace();
93 | } catch (InvocationTargetException e) {
94 | e.printStackTrace();
95 | }
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/com/example/RNVideoManagerModule.java:
--------------------------------------------------------------------------------
1 |
2 | package com.example;
3 |
4 | import com.coremedia.iso.boxes.Container;
5 | import com.facebook.react.bridge.ReactApplicationContext;
6 | import com.facebook.react.bridge.ReactContextBaseJavaModule;
7 | import com.facebook.react.bridge.ReactMethod;
8 | import com.facebook.react.bridge.Callback;
9 |
10 | import android.util.Log;
11 | import com.facebook.react.bridge.ReadableArray;
12 |
13 | import com.googlecode.mp4parser.authoring.Movie;
14 | import com.googlecode.mp4parser.authoring.Track;
15 | import com.googlecode.mp4parser.authoring.container.mp4.MovieCreator;
16 | import com.googlecode.mp4parser.authoring.tracks.AppendTrack;
17 | import com.googlecode.mp4parser.authoring.builder.DefaultMp4Builder;
18 |
19 | import java.io.FileNotFoundException;
20 | import java.io.IOException;
21 | import java.io.RandomAccessFile;
22 | import java.nio.channels.FileChannel;
23 | import java.util.ArrayList;
24 | import java.util.LinkedList;
25 | import java.util.List;
26 |
27 | public class RNVideoManagerModule extends ReactContextBaseJavaModule {
28 |
29 | private final ReactApplicationContext reactContext;
30 |
31 | public RNVideoManagerModule(ReactApplicationContext reactContext) {
32 | super(reactContext);
33 | this.reactContext = reactContext;
34 | }
35 |
36 | @ReactMethod
37 | public void merge(ReadableArray videoFiles, Callback errorCallback, Callback successCallback) {
38 |
39 | List inMovies = new ArrayList();
40 |
41 | for (int i = 0; i < videoFiles.size(); i++) {
42 | String videoUrl = videoFiles.getString(i).replaceFirst("file://", "");
43 |
44 | try {
45 | inMovies.add(MovieCreator.build(videoUrl));
46 | } catch (IOException e) {
47 | errorCallback.invoke(e.getMessage());
48 | e.printStackTrace();
49 | }
50 | }
51 |
52 | List