├── .gitignore
├── .npmignore
├── Demo
├── .buckconfig
├── .flowconfig
├── .gitignore
├── .watchmanconfig
├── App.js
├── android
│ ├── app
│ │ ├── BUCK
│ │ ├── build.gradle
│ │ ├── proguard-rules.pro
│ │ └── src
│ │ │ └── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── demo
│ │ │ │ ├── MainActivity.java
│ │ │ │ └── MainApplication.java
│ │ │ └── res
│ │ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ │ └── values
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ ├── keystores
│ │ ├── BUCK
│ │ └── debug.keystore.properties
│ └── settings.gradle
├── demo.gif
├── index.android.js
├── index.ios.js
├── ios
│ ├── Demo.xcodeproj
│ │ ├── project.pbxproj
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── Demo.xcscheme
│ ├── Demo
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Base.lproj
│ │ │ └── LaunchScreen.xib
│ │ ├── Images.xcassets
│ │ │ └── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ ├── Info.plist
│ │ └── main.m
│ └── DemoTests
│ │ ├── DemoTests.m
│ │ └── Info.plist
└── package.json
├── README.md
├── android
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── yoai
│ │ └── reactnative
│ │ └── media
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── greatdroid
│ │ │ └── reactnative
│ │ │ └── media
│ │ │ ├── MediaKitPackage.java
│ │ │ └── player
│ │ │ ├── MediaPlayerController.java
│ │ │ ├── ReactMediaPlayerView.java
│ │ │ ├── ReactMediaPlayerViewManager.java
│ │ │ ├── TrackRenderersBuilder.java
│ │ │ └── trackrenderer
│ │ │ ├── DashRenderersBuilder.java
│ │ │ ├── ExtractorRenderersBuilder.java
│ │ │ ├── HlsRenderersBuilder.java
│ │ │ └── SmoothStreamingRenderersBuilder.java
│ └── res
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── yoai
│ └── reactnative
│ └── media
│ └── ExampleUnitTest.java
├── ios
├── react-native-media-kit.xcodeproj
│ └── project.pbxproj
└── react-native-media-kit
│ ├── RCTMediaPlayerManager.h
│ ├── RCTMediaPlayerManager.m
│ ├── RCTMediaPlayerView.h
│ └── RCTMediaPlayerView.m
├── library
├── Controls.js
├── MediaPlayerView.js
├── img
│ ├── media-player-pause@2x.png
│ ├── media-player-pause@3x.png
│ ├── media-player-play@2x.png
│ ├── media-player-play@3x.png
│ ├── media-player-thumb@2x.png
│ └── media-player-thumb@3x.png
└── index.js
└── package.json
/.gitignore:
--------------------------------------------------------------------------------
1 | /.idea/
2 |
3 | # OSX
4 | #
5 | .DS_Store
6 |
7 | # Xcode
8 | #
9 | build/
10 | *.pbxuser
11 | !default.pbxuser
12 | *.mode1v3
13 | !default.mode1v3
14 | *.mode2v3
15 | !default.mode2v3
16 | *.perspectivev3
17 | !default.perspectivev3
18 | xcuserdata
19 | *.xccheckout
20 | *.moved-aside
21 | DerivedData
22 | *.hmap
23 | *.ipa
24 | *.xcuserstate
25 | project.xcworkspace
26 |
27 | # Android/IJ
28 | #
29 | .idea
30 | .gradle
31 | local.properties
32 | *.log
33 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | #npmignore
2 | demo/
3 | Demo/
4 |
5 | /.idea/
6 |
7 | # OSX
8 | #
9 | .DS_Store
10 |
11 | # Xcode
12 | #
13 | build/
14 | *.pbxuser
15 | !default.pbxuser
16 | *.mode1v3
17 | !default.mode1v3
18 | *.mode2v3
19 | !default.mode2v3
20 | *.perspectivev3
21 | !default.perspectivev3
22 | xcuserdata
23 | *.xccheckout
24 | *.moved-aside
25 | DerivedData
26 | *.hmap
27 | *.ipa
28 | *.xcuserstate
29 | project.xcworkspace
30 |
31 | # Android/IJ
32 | #
33 | .idea
34 | .gradle
35 | local.properties
36 | *.log
37 |
--------------------------------------------------------------------------------
/Demo/.buckconfig:
--------------------------------------------------------------------------------
1 |
2 | [android]
3 | target = Google Inc.:Google APIs:23
4 |
5 | [maven_repositories]
6 | central = https://repo1.maven.org/maven2
7 |
--------------------------------------------------------------------------------
/Demo/.flowconfig:
--------------------------------------------------------------------------------
1 | [ignore]
2 |
3 | # We fork some components by platform.
4 | .*/*.android.js
5 |
6 | # Ignore templates with `@flow` in header
7 | .*/local-cli/generator.*
8 |
9 | # Ignore malformed json
10 | .*/node_modules/y18n/test/.*\.json
11 |
12 | [include]
13 |
14 | [libs]
15 | node_modules/react-native/Libraries/react-native/react-native-interface.js
16 | node_modules/react-native/flow
17 | flow/
18 |
19 | [options]
20 | module.system=haste
21 |
22 | esproposal.class_static_fields=enable
23 | esproposal.class_instance_fields=enable
24 |
25 | experimental.strict_type_args=true
26 |
27 | munge_underscores=true
28 |
29 | module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
30 | module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
31 |
32 | suppress_type=$FlowIssue
33 | suppress_type=$FlowFixMe
34 | suppress_type=$FixMe
35 |
36 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-7]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
37 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-7]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
38 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
39 |
40 | [version]
41 | ^0.27.0
42 |
--------------------------------------------------------------------------------
/Demo/.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/IJ
26 | #
27 | *.iml
28 | .idea
29 | .gradle
30 | local.properties
31 |
32 | # node.js
33 | #
34 | node_modules/
35 | npm-debug.log
36 |
37 | # BUCK
38 | buck-out/
39 | \.buckd/
40 | android/app/libs
41 | android/keystores/debug.keystore
42 |
--------------------------------------------------------------------------------
/Demo/.watchmanconfig:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/Demo/App.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | import React, { Component } from 'react';
4 | import {
5 | Text,
6 | View,
7 | Dimensions,
8 | ScrollView,
9 | TouchableOpacity
10 | } from 'react-native';
11 |
12 | const {width, height} = Dimensions.get('window');
13 |
14 | import {Video} from 'react-native-media-kit';
15 |
16 | const HTTP = [
17 | 'http://v.yoai.com/femme_tampon_tutorial.mp4'
18 | ];
19 |
20 | const HLS = [
21 | 'https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8',
22 | 'http://cdn3.viblast.com/streams/hls/airshow/playlist.m3u8',
23 | 'http://sample.vodobox.net/skate_phantom_flex_4k/skate_phantom_flex_4k.m3u8',
24 | 'http://content.jwplatform.com/manifests/vM7nH0Kl.m3u8',
25 | 'http://vevoplaylist-live.hls.adaptive.level3.net/vevo/ch3/appleman.m3u8',
26 | 'http://playertest.longtailvideo.com/adaptive/captions/playlist.m3u8',
27 | 'http://playertest.longtailvideo.com/adaptive/oceans_aes/oceans_aes.m3u8'
28 | ];
29 |
30 |
31 | export default class App extends Component {
32 |
33 | state = {
34 | muted: false,
35 | width: width,
36 | height: width / (16/9),
37 | controls: true
38 | };
39 |
40 | render() {
41 | return (
42 |
44 |
53 |
54 |
56 | {
58 | this.setState({
59 | muted: !this.state.muted
60 | })
61 | }}
62 | style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
63 | toggle muted
64 |
65 |
66 | {
68 | this.setState({
69 | width: 160,
70 | height: 90,
71 | controls: false
72 | })
73 | }}
74 | style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
75 | change layout
76 |
77 |
78 |
79 | );
80 | }
81 | }
--------------------------------------------------------------------------------
/Demo/android/app/BUCK:
--------------------------------------------------------------------------------
1 | import re
2 |
3 | # To learn about Buck see [Docs](https://buckbuild.com/).
4 | # To run your application with Buck:
5 | # - install Buck
6 | # - `npm start` - to start the packager
7 | # - `cd android`
8 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US`
9 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
10 | # - `buck install -r android/app` - compile, install and run application
11 | #
12 |
13 | lib_deps = []
14 | for jarfile in glob(['libs/*.jar']):
15 | name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile)
16 | lib_deps.append(':' + name)
17 | prebuilt_jar(
18 | name = name,
19 | binary_jar = jarfile,
20 | )
21 |
22 | for aarfile in glob(['libs/*.aar']):
23 | name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile)
24 | lib_deps.append(':' + name)
25 | android_prebuilt_aar(
26 | name = name,
27 | aar = aarfile,
28 | )
29 |
30 | android_library(
31 | name = 'all-libs',
32 | exported_deps = lib_deps
33 | )
34 |
35 | android_library(
36 | name = 'app-code',
37 | srcs = glob([
38 | 'src/main/java/**/*.java',
39 | ]),
40 | deps = [
41 | ':all-libs',
42 | ':build_config',
43 | ':res',
44 | ],
45 | )
46 |
47 | android_build_config(
48 | name = 'build_config',
49 | package = 'com.demo',
50 | )
51 |
52 | android_resource(
53 | name = 'res',
54 | res = 'src/main/res',
55 | package = 'com.demo',
56 | )
57 |
58 | android_binary(
59 | name = 'app',
60 | package_type = 'debug',
61 | manifest = 'src/main/AndroidManifest.xml',
62 | keystore = '//android/keystores:debug',
63 | deps = [
64 | ':app-code',
65 | ],
66 | )
67 |
--------------------------------------------------------------------------------
/Demo/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
19 | * entryFile: "index.android.js",
20 | *
21 | * // whether to bundle JS and assets in debug mode
22 | * bundleInDebug: false,
23 | *
24 | * // whether to bundle JS and assets in release mode
25 | * bundleInRelease: true,
26 | *
27 | * // whether to bundle JS and assets in another build variant (if configured).
28 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
29 | * // The configuration property can be in the following formats
30 | * // 'bundleIn${productFlavor}${buildType}'
31 | * // 'bundleIn${buildType}'
32 | * // bundleInFreeDebug: true,
33 | * // bundleInPaidRelease: true,
34 | * // bundleInBeta: true,
35 | *
36 | * // the root of your project, i.e. where "package.json" lives
37 | * root: "../../",
38 | *
39 | * // where to put the JS bundle asset in debug mode
40 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
41 | *
42 | * // where to put the JS bundle asset in release mode
43 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release",
44 | *
45 | * // where to put drawable resources / React Native assets, e.g. the ones you use via
46 | * // require('./image.png')), in debug mode
47 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
48 | *
49 | * // where to put drawable resources / React Native assets, e.g. the ones you use via
50 | * // require('./image.png')), in release mode
51 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
52 | *
53 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means
54 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
55 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle
56 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
57 | * // for example, you might want to remove it from here.
58 | * inputExcludes: ["android/**", "ios/**"],
59 | *
60 | * // override which node gets called and with what additional arguments
61 | * nodeExecutableAndArgs: ["node"]
62 | *
63 | * // supply additional arguments to the packager
64 | * extraPackagerArgs: []
65 | * ]
66 | */
67 |
68 | apply from: "../../node_modules/react-native/react.gradle"
69 |
70 | /**
71 | * Set this to true to create two separate APKs instead of one:
72 | * - An APK that only works on ARM devices
73 | * - An APK that only works on x86 devices
74 | * The advantage is the size of the APK is reduced by about 4MB.
75 | * Upload all the APKs to the Play Store and people will download
76 | * the correct one based on the CPU architecture of their device.
77 | */
78 | def enableSeparateBuildPerCPUArchitecture = false
79 |
80 | /**
81 | * Run Proguard to shrink the Java bytecode in release builds.
82 | */
83 | def enableProguardInReleaseBuilds = false
84 |
85 | android {
86 | compileSdkVersion 23
87 | buildToolsVersion "23.0.1"
88 |
89 | defaultConfig {
90 | applicationId "com.demo"
91 | minSdkVersion 16
92 | targetSdkVersion 22
93 | versionCode 1
94 | versionName "1.0"
95 | ndk {
96 | abiFilters "armeabi-v7a", "x86"
97 | }
98 | }
99 | splits {
100 | abi {
101 | reset()
102 | enable enableSeparateBuildPerCPUArchitecture
103 | universalApk false // If true, also generate a universal APK
104 | include "armeabi-v7a", "x86"
105 | }
106 | }
107 | buildTypes {
108 | release {
109 | minifyEnabled enableProguardInReleaseBuilds
110 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
111 | }
112 | }
113 | // applicationVariants are e.g. debug, release
114 | applicationVariants.all { variant ->
115 | variant.outputs.each { output ->
116 | // For each separate APK per architecture, set a unique version code as described here:
117 | // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
118 | def versionCodes = ["armeabi-v7a":1, "x86":2]
119 | def abi = output.getFilter(OutputFile.ABI)
120 | if (abi != null) { // null for the universal-debug, universal-release variants
121 | output.versionCodeOverride =
122 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
123 | }
124 | }
125 | }
126 | }
127 |
128 | dependencies {
129 | compile fileTree(dir: "libs", include: ["*.jar"])
130 | compile "com.android.support:appcompat-v7:23.0.1"
131 | compile "com.facebook.react:react-native:+" // From node_modules
132 | compile project(':react-native-media-kit')
133 | }
134 |
135 | // Run this once to be able to run the application with BUCK
136 | // puts all compile dependencies into folder libs for BUCK to use
137 | task copyDownloadableDepsToLibs(type: Copy) {
138 | from configurations.compile
139 | into 'libs'
140 | }
141 |
--------------------------------------------------------------------------------
/Demo/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 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Disabling obfuscation is useful if you collect stack traces from production crashes
20 | # (unless you are using a system that supports de-obfuscate the stack traces).
21 | -dontobfuscate
22 |
23 | # React Native
24 |
25 | # Keep our interfaces so they can be used by other ProGuard rules.
26 | # See http://sourceforge.net/p/proguard/bugs/466/
27 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip
28 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters
29 | -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip
30 |
31 | # Do not strip any method/class that is annotated with @DoNotStrip
32 | -keep @com.facebook.proguard.annotations.DoNotStrip class *
33 | -keep @com.facebook.common.internal.DoNotStrip class *
34 | -keepclassmembers class * {
35 | @com.facebook.proguard.annotations.DoNotStrip *;
36 | @com.facebook.common.internal.DoNotStrip *;
37 | }
38 |
39 | -keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * {
40 | void set*(***);
41 | *** get*();
42 | }
43 |
44 | -keep class * extends com.facebook.react.bridge.JavaScriptModule { *; }
45 | -keep class * extends com.facebook.react.bridge.NativeModule { *; }
46 | -keepclassmembers,includedescriptorclasses class * { native ; }
47 | -keepclassmembers class * { @com.facebook.react.uimanager.UIProp ; }
48 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp ; }
49 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup ; }
50 |
51 | -dontwarn com.facebook.react.**
52 |
53 | # okhttp
54 |
55 | -keepattributes Signature
56 | -keepattributes *Annotation*
57 | -keep class okhttp3.** { *; }
58 | -keep interface okhttp3.** { *; }
59 | -dontwarn okhttp3.**
60 |
61 | # okio
62 |
63 | -keep class sun.misc.Unsafe { *; }
64 | -dontwarn java.nio.file.*
65 | -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
66 | -dontwarn okio.**
67 |
--------------------------------------------------------------------------------
/Demo/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
12 |
13 |
19 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/Demo/android/app/src/main/java/com/demo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.demo;
2 |
3 | import com.facebook.react.ReactActivity;
4 |
5 | public class MainActivity extends ReactActivity {
6 |
7 | /**
8 | * Returns the name of the main component registered from JavaScript.
9 | * This is used to schedule rendering of the component.
10 | */
11 | @Override
12 | protected String getMainComponentName() {
13 | return "Demo";
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Demo/android/app/src/main/java/com/demo/MainApplication.java:
--------------------------------------------------------------------------------
1 | package com.demo;
2 |
3 | import android.app.Application;
4 | import android.util.Log;
5 |
6 | import com.facebook.react.ReactApplication;
7 | import com.facebook.react.ReactInstanceManager;
8 | import com.facebook.react.ReactNativeHost;
9 | import com.facebook.react.ReactPackage;
10 | import com.facebook.react.shell.MainReactPackage;
11 |
12 | import java.util.Arrays;
13 | import java.util.List;
14 |
15 | import com.greatdroid.reactnative.media.MediaKitPackage;
16 |
17 | public class MainApplication extends Application implements ReactApplication {
18 |
19 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
20 | @Override
21 | protected boolean getUseDeveloperSupport() {
22 | return BuildConfig.DEBUG;
23 | }
24 |
25 | @Override
26 | protected List getPackages() {
27 | return Arrays.asList(
28 | new MainReactPackage(),
29 | new MediaKitPackage()
30 | );
31 | }
32 | };
33 |
34 | @Override
35 | public ReactNativeHost getReactNativeHost() {
36 | return mReactNativeHost;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Demo/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ldn0x7dc/react-native-media-kit/76b2fa6259a2c1bc1fad3de551afca595cfcb369/Demo/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Demo/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ldn0x7dc/react-native-media-kit/76b2fa6259a2c1bc1fad3de551afca595cfcb369/Demo/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Demo/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ldn0x7dc/react-native-media-kit/76b2fa6259a2c1bc1fad3de551afca595cfcb369/Demo/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Demo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ldn0x7dc/react-native-media-kit/76b2fa6259a2c1bc1fad3de551afca595cfcb369/Demo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Demo/android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Demo
3 |
4 |
--------------------------------------------------------------------------------
/Demo/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Demo/android/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.3.1'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | mavenLocal()
18 | jcenter()
19 | maven {
20 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
21 | url "$rootDir/../node_modules/react-native/android"
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Demo/android/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | android.useDeprecatedNdk=true
21 |
--------------------------------------------------------------------------------
/Demo/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ldn0x7dc/react-native-media-kit/76b2fa6259a2c1bc1fad3de551afca595cfcb369/Demo/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/Demo/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | zipStoreBase=GRADLE_USER_HOME
4 | zipStorePath=wrapper/dists
5 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
6 |
--------------------------------------------------------------------------------
/Demo/android/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/Demo/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/Demo/android/keystores/BUCK:
--------------------------------------------------------------------------------
1 | keystore(
2 | name = 'debug',
3 | store = 'debug.keystore',
4 | properties = 'debug.keystore.properties',
5 | visibility = [
6 | 'PUBLIC',
7 | ],
8 | )
9 |
--------------------------------------------------------------------------------
/Demo/android/keystores/debug.keystore.properties:
--------------------------------------------------------------------------------
1 | key.store=debug.keystore
2 | key.alias=androiddebugkey
3 | key.store.password=android
4 | key.alias.password=android
5 |
--------------------------------------------------------------------------------
/Demo/android/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'Demo'
2 |
3 | include ':app'
4 |
5 | include ':react-native-media-kit'
6 | project(':react-native-media-kit').projectDir = new File('../node_modules/react-native-media-kit/android')
--------------------------------------------------------------------------------
/Demo/demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ldn0x7dc/react-native-media-kit/76b2fa6259a2c1bc1fad3de551afca595cfcb369/Demo/demo.gif
--------------------------------------------------------------------------------
/Demo/index.android.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Sample React Native App
3 | * https://github.com/facebook/react-native
4 | * @flow
5 | */
6 |
7 | import React, { Component } from 'react';
8 | import {
9 | AppRegistry,
10 | StyleSheet,
11 | Text,
12 | View
13 | } from 'react-native';
14 |
15 | import App from './App';
16 |
17 | class Demo extends Component {
18 | render() {
19 | return (
20 |
21 | );
22 | }
23 | }
24 |
25 | AppRegistry.registerComponent('Demo', () => Demo);
26 |
--------------------------------------------------------------------------------
/Demo/index.ios.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Sample React Native App
3 | * https://github.com/facebook/react-native
4 | * @flow
5 | */
6 |
7 | import React, { Component } from 'react';
8 | import {
9 | AppRegistry,
10 | StyleSheet,
11 | Text,
12 | View
13 | } from 'react-native';
14 |
15 | import App from './App';
16 |
17 | class Demo extends Component {
18 | render() {
19 | return (
20 |
21 | );
22 | }
23 | }
24 |
25 | AppRegistry.registerComponent('Demo', () => Demo);
26 |
--------------------------------------------------------------------------------
/Demo/ios/Demo.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
11 | 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
12 | 00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */; };
13 | 00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */; };
14 | 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */; };
15 | 00E356F31AD99517003FC87E /* DemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* DemoTests.m */; };
16 | 133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 78C398B91ACF4ADC00677621 /* libRCTLinking.a */; };
17 | 139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */; };
18 | 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */; };
19 | 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };
20 | 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; };
21 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
22 | 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
23 | 140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
24 | 146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
25 | 5F5493631D40F4C800E267B3 /* libreact-native-media-kit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F5493611D40F4BD00E267B3 /* libreact-native-media-kit.a */; };
26 | 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
27 | /* End PBXBuildFile section */
28 |
29 | /* Begin PBXContainerItemProxy section */
30 | 00C302AB1ABCB8CE00DB3ED1 /* PBXContainerItemProxy */ = {
31 | isa = PBXContainerItemProxy;
32 | containerPortal = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */;
33 | proxyType = 2;
34 | remoteGlobalIDString = 134814201AA4EA6300B7C361;
35 | remoteInfo = RCTActionSheet;
36 | };
37 | 00C302B91ABCB90400DB3ED1 /* PBXContainerItemProxy */ = {
38 | isa = PBXContainerItemProxy;
39 | containerPortal = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */;
40 | proxyType = 2;
41 | remoteGlobalIDString = 134814201AA4EA6300B7C361;
42 | remoteInfo = RCTGeolocation;
43 | };
44 | 00C302BF1ABCB91800DB3ED1 /* PBXContainerItemProxy */ = {
45 | isa = PBXContainerItemProxy;
46 | containerPortal = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */;
47 | proxyType = 2;
48 | remoteGlobalIDString = 58B5115D1A9E6B3D00147676;
49 | remoteInfo = RCTImage;
50 | };
51 | 00C302DB1ABCB9D200DB3ED1 /* PBXContainerItemProxy */ = {
52 | isa = PBXContainerItemProxy;
53 | containerPortal = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */;
54 | proxyType = 2;
55 | remoteGlobalIDString = 58B511DB1A9E6C8500147676;
56 | remoteInfo = RCTNetwork;
57 | };
58 | 00C302E31ABCB9EE00DB3ED1 /* PBXContainerItemProxy */ = {
59 | isa = PBXContainerItemProxy;
60 | containerPortal = 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */;
61 | proxyType = 2;
62 | remoteGlobalIDString = 832C81801AAF6DEF007FA2F7;
63 | remoteInfo = RCTVibration;
64 | };
65 | 00E356F41AD99517003FC87E /* PBXContainerItemProxy */ = {
66 | isa = PBXContainerItemProxy;
67 | containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */;
68 | proxyType = 1;
69 | remoteGlobalIDString = 13B07F861A680F5B00A75B9A;
70 | remoteInfo = Demo;
71 | };
72 | 139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */ = {
73 | isa = PBXContainerItemProxy;
74 | containerPortal = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */;
75 | proxyType = 2;
76 | remoteGlobalIDString = 134814201AA4EA6300B7C361;
77 | remoteInfo = RCTSettings;
78 | };
79 | 139FDEF31B06529B00C62182 /* PBXContainerItemProxy */ = {
80 | isa = PBXContainerItemProxy;
81 | containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */;
82 | proxyType = 2;
83 | remoteGlobalIDString = 3C86DF461ADF2C930047B81A;
84 | remoteInfo = RCTWebSocket;
85 | };
86 | 146834031AC3E56700842450 /* PBXContainerItemProxy */ = {
87 | isa = PBXContainerItemProxy;
88 | containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
89 | proxyType = 2;
90 | remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192;
91 | remoteInfo = React;
92 | };
93 | 5F5493601D40F4BD00E267B3 /* PBXContainerItemProxy */ = {
94 | isa = PBXContainerItemProxy;
95 | containerPortal = 5F5493531D40F4BD00E267B3 /* react-native-media-kit.xcodeproj */;
96 | proxyType = 2;
97 | remoteGlobalIDString = 5FDB0B6A1CBB7ACA00EDD727;
98 | remoteInfo = "react-native-media-kit";
99 | };
100 | 78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */ = {
101 | isa = PBXContainerItemProxy;
102 | containerPortal = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */;
103 | proxyType = 2;
104 | remoteGlobalIDString = 134814201AA4EA6300B7C361;
105 | remoteInfo = RCTLinking;
106 | };
107 | 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */ = {
108 | isa = PBXContainerItemProxy;
109 | containerPortal = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */;
110 | proxyType = 2;
111 | remoteGlobalIDString = 58B5119B1A9E6C1200147676;
112 | remoteInfo = RCTText;
113 | };
114 | /* End PBXContainerItemProxy section */
115 |
116 | /* Begin PBXFileReference section */
117 | 008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = main.jsbundle; sourceTree = ""; };
118 | 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = "../node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj"; sourceTree = ""; };
119 | 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTGeolocation.xcodeproj; path = "../node_modules/react-native/Libraries/Geolocation/RCTGeolocation.xcodeproj"; sourceTree = ""; };
120 | 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = "../node_modules/react-native/Libraries/Image/RCTImage.xcodeproj"; sourceTree = ""; };
121 | 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = "../node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj"; sourceTree = ""; };
122 | 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = "../node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj"; sourceTree = ""; };
123 | 00E356EE1AD99517003FC87E /* DemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
124 | 00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
125 | 00E356F21AD99517003FC87E /* DemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DemoTests.m; sourceTree = ""; };
126 | 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = "../node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj"; sourceTree = ""; };
127 | 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocket.xcodeproj; path = "../node_modules/react-native/Libraries/WebSocket/RCTWebSocket.xcodeproj"; sourceTree = ""; };
128 | 13B07F961A680F5B00A75B9A /* Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Demo.app; sourceTree = BUILT_PRODUCTS_DIR; };
129 | 13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = Demo/AppDelegate.h; sourceTree = ""; };
130 | 13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = Demo/AppDelegate.m; sourceTree = ""; };
131 | 13B07FB21A68108700A75B9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; };
132 | 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = Demo/Images.xcassets; sourceTree = ""; };
133 | 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Demo/Info.plist; sourceTree = ""; };
134 | 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = Demo/main.m; sourceTree = ""; };
135 | 146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = ""; };
136 | 5F5493531D40F4BD00E267B3 /* react-native-media-kit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "react-native-media-kit.xcodeproj"; path = "../node_modules/react-native-media-kit/ios/react-native-media-kit.xcodeproj"; sourceTree = ""; };
137 | 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = ""; };
138 | 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = ""; };
139 | /* End PBXFileReference section */
140 |
141 | /* Begin PBXFrameworksBuildPhase section */
142 | 00E356EB1AD99517003FC87E /* Frameworks */ = {
143 | isa = PBXFrameworksBuildPhase;
144 | buildActionMask = 2147483647;
145 | files = (
146 | 140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */,
147 | );
148 | runOnlyForDeploymentPostprocessing = 0;
149 | };
150 | 13B07F8C1A680F5B00A75B9A /* Frameworks */ = {
151 | isa = PBXFrameworksBuildPhase;
152 | buildActionMask = 2147483647;
153 | files = (
154 | 5F5493631D40F4C800E267B3 /* libreact-native-media-kit.a in Frameworks */,
155 | 146834051AC3E58100842450 /* libReact.a in Frameworks */,
156 | 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */,
157 | 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */,
158 | 00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */,
159 | 133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */,
160 | 00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */,
161 | 139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */,
162 | 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */,
163 | 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,
164 | 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,
165 | );
166 | runOnlyForDeploymentPostprocessing = 0;
167 | };
168 | /* End PBXFrameworksBuildPhase section */
169 |
170 | /* Begin PBXGroup section */
171 | 00C302A81ABCB8CE00DB3ED1 /* Products */ = {
172 | isa = PBXGroup;
173 | children = (
174 | 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */,
175 | );
176 | name = Products;
177 | sourceTree = "";
178 | };
179 | 00C302B61ABCB90400DB3ED1 /* Products */ = {
180 | isa = PBXGroup;
181 | children = (
182 | 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */,
183 | );
184 | name = Products;
185 | sourceTree = "";
186 | };
187 | 00C302BC1ABCB91800DB3ED1 /* Products */ = {
188 | isa = PBXGroup;
189 | children = (
190 | 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */,
191 | );
192 | name = Products;
193 | sourceTree = "";
194 | };
195 | 00C302D41ABCB9D200DB3ED1 /* Products */ = {
196 | isa = PBXGroup;
197 | children = (
198 | 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */,
199 | );
200 | name = Products;
201 | sourceTree = "";
202 | };
203 | 00C302E01ABCB9EE00DB3ED1 /* Products */ = {
204 | isa = PBXGroup;
205 | children = (
206 | 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */,
207 | );
208 | name = Products;
209 | sourceTree = "";
210 | };
211 | 00E356EF1AD99517003FC87E /* DemoTests */ = {
212 | isa = PBXGroup;
213 | children = (
214 | 00E356F21AD99517003FC87E /* DemoTests.m */,
215 | 00E356F01AD99517003FC87E /* Supporting Files */,
216 | );
217 | path = DemoTests;
218 | sourceTree = "";
219 | };
220 | 00E356F01AD99517003FC87E /* Supporting Files */ = {
221 | isa = PBXGroup;
222 | children = (
223 | 00E356F11AD99517003FC87E /* Info.plist */,
224 | );
225 | name = "Supporting Files";
226 | sourceTree = "";
227 | };
228 | 139105B71AF99BAD00B5F7CC /* Products */ = {
229 | isa = PBXGroup;
230 | children = (
231 | 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */,
232 | );
233 | name = Products;
234 | sourceTree = "";
235 | };
236 | 139FDEE71B06529A00C62182 /* Products */ = {
237 | isa = PBXGroup;
238 | children = (
239 | 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */,
240 | );
241 | name = Products;
242 | sourceTree = "";
243 | };
244 | 13B07FAE1A68108700A75B9A /* Demo */ = {
245 | isa = PBXGroup;
246 | children = (
247 | 008F07F21AC5B25A0029DE68 /* main.jsbundle */,
248 | 13B07FAF1A68108700A75B9A /* AppDelegate.h */,
249 | 13B07FB01A68108700A75B9A /* AppDelegate.m */,
250 | 13B07FB51A68108700A75B9A /* Images.xcassets */,
251 | 13B07FB61A68108700A75B9A /* Info.plist */,
252 | 13B07FB11A68108700A75B9A /* LaunchScreen.xib */,
253 | 13B07FB71A68108700A75B9A /* main.m */,
254 | );
255 | name = Demo;
256 | sourceTree = "";
257 | };
258 | 146834001AC3E56700842450 /* Products */ = {
259 | isa = PBXGroup;
260 | children = (
261 | 146834041AC3E56700842450 /* libReact.a */,
262 | );
263 | name = Products;
264 | sourceTree = "";
265 | };
266 | 5F5493541D40F4BD00E267B3 /* Products */ = {
267 | isa = PBXGroup;
268 | children = (
269 | 5F5493611D40F4BD00E267B3 /* libreact-native-media-kit.a */,
270 | );
271 | name = Products;
272 | sourceTree = "";
273 | };
274 | 78C398B11ACF4ADC00677621 /* Products */ = {
275 | isa = PBXGroup;
276 | children = (
277 | 78C398B91ACF4ADC00677621 /* libRCTLinking.a */,
278 | );
279 | name = Products;
280 | sourceTree = "";
281 | };
282 | 832341AE1AAA6A7D00B99B32 /* Libraries */ = {
283 | isa = PBXGroup;
284 | children = (
285 | 5F5493531D40F4BD00E267B3 /* react-native-media-kit.xcodeproj */,
286 | 146833FF1AC3E56700842450 /* React.xcodeproj */,
287 | 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */,
288 | 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */,
289 | 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */,
290 | 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */,
291 | 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */,
292 | 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */,
293 | 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */,
294 | 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */,
295 | 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,
296 | );
297 | name = Libraries;
298 | sourceTree = "";
299 | };
300 | 832341B11AAA6A8300B99B32 /* Products */ = {
301 | isa = PBXGroup;
302 | children = (
303 | 832341B51AAA6A8300B99B32 /* libRCTText.a */,
304 | );
305 | name = Products;
306 | sourceTree = "";
307 | };
308 | 83CBB9F61A601CBA00E9B192 = {
309 | isa = PBXGroup;
310 | children = (
311 | 13B07FAE1A68108700A75B9A /* Demo */,
312 | 832341AE1AAA6A7D00B99B32 /* Libraries */,
313 | 00E356EF1AD99517003FC87E /* DemoTests */,
314 | 83CBBA001A601CBA00E9B192 /* Products */,
315 | );
316 | indentWidth = 2;
317 | sourceTree = "";
318 | tabWidth = 2;
319 | };
320 | 83CBBA001A601CBA00E9B192 /* Products */ = {
321 | isa = PBXGroup;
322 | children = (
323 | 13B07F961A680F5B00A75B9A /* Demo.app */,
324 | 00E356EE1AD99517003FC87E /* DemoTests.xctest */,
325 | );
326 | name = Products;
327 | sourceTree = "";
328 | };
329 | /* End PBXGroup section */
330 |
331 | /* Begin PBXNativeTarget section */
332 | 00E356ED1AD99517003FC87E /* DemoTests */ = {
333 | isa = PBXNativeTarget;
334 | buildConfigurationList = 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "DemoTests" */;
335 | buildPhases = (
336 | 00E356EA1AD99517003FC87E /* Sources */,
337 | 00E356EB1AD99517003FC87E /* Frameworks */,
338 | 00E356EC1AD99517003FC87E /* Resources */,
339 | );
340 | buildRules = (
341 | );
342 | dependencies = (
343 | 00E356F51AD99517003FC87E /* PBXTargetDependency */,
344 | );
345 | name = DemoTests;
346 | productName = DemoTests;
347 | productReference = 00E356EE1AD99517003FC87E /* DemoTests.xctest */;
348 | productType = "com.apple.product-type.bundle.unit-test";
349 | };
350 | 13B07F861A680F5B00A75B9A /* Demo */ = {
351 | isa = PBXNativeTarget;
352 | buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "Demo" */;
353 | buildPhases = (
354 | 13B07F871A680F5B00A75B9A /* Sources */,
355 | 13B07F8C1A680F5B00A75B9A /* Frameworks */,
356 | 13B07F8E1A680F5B00A75B9A /* Resources */,
357 | 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
358 | );
359 | buildRules = (
360 | );
361 | dependencies = (
362 | );
363 | name = Demo;
364 | productName = "Hello World";
365 | productReference = 13B07F961A680F5B00A75B9A /* Demo.app */;
366 | productType = "com.apple.product-type.application";
367 | };
368 | /* End PBXNativeTarget section */
369 |
370 | /* Begin PBXProject section */
371 | 83CBB9F71A601CBA00E9B192 /* Project object */ = {
372 | isa = PBXProject;
373 | attributes = {
374 | LastUpgradeCheck = 0610;
375 | ORGANIZATIONNAME = Facebook;
376 | TargetAttributes = {
377 | 00E356ED1AD99517003FC87E = {
378 | CreatedOnToolsVersion = 6.2;
379 | TestTargetID = 13B07F861A680F5B00A75B9A;
380 | };
381 | };
382 | };
383 | buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "Demo" */;
384 | compatibilityVersion = "Xcode 3.2";
385 | developmentRegion = English;
386 | hasScannedForEncodings = 0;
387 | knownRegions = (
388 | en,
389 | Base,
390 | );
391 | mainGroup = 83CBB9F61A601CBA00E9B192;
392 | productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */;
393 | projectDirPath = "";
394 | projectReferences = (
395 | {
396 | ProductGroup = 00C302A81ABCB8CE00DB3ED1 /* Products */;
397 | ProjectRef = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */;
398 | },
399 | {
400 | ProductGroup = 00C302B61ABCB90400DB3ED1 /* Products */;
401 | ProjectRef = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */;
402 | },
403 | {
404 | ProductGroup = 00C302BC1ABCB91800DB3ED1 /* Products */;
405 | ProjectRef = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */;
406 | },
407 | {
408 | ProductGroup = 78C398B11ACF4ADC00677621 /* Products */;
409 | ProjectRef = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */;
410 | },
411 | {
412 | ProductGroup = 00C302D41ABCB9D200DB3ED1 /* Products */;
413 | ProjectRef = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */;
414 | },
415 | {
416 | ProductGroup = 139105B71AF99BAD00B5F7CC /* Products */;
417 | ProjectRef = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */;
418 | },
419 | {
420 | ProductGroup = 832341B11AAA6A8300B99B32 /* Products */;
421 | ProjectRef = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */;
422 | },
423 | {
424 | ProductGroup = 00C302E01ABCB9EE00DB3ED1 /* Products */;
425 | ProjectRef = 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */;
426 | },
427 | {
428 | ProductGroup = 139FDEE71B06529A00C62182 /* Products */;
429 | ProjectRef = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */;
430 | },
431 | {
432 | ProductGroup = 5F5493541D40F4BD00E267B3 /* Products */;
433 | ProjectRef = 5F5493531D40F4BD00E267B3 /* react-native-media-kit.xcodeproj */;
434 | },
435 | {
436 | ProductGroup = 146834001AC3E56700842450 /* Products */;
437 | ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */;
438 | },
439 | );
440 | projectRoot = "";
441 | targets = (
442 | 13B07F861A680F5B00A75B9A /* Demo */,
443 | 00E356ED1AD99517003FC87E /* DemoTests */,
444 | );
445 | };
446 | /* End PBXProject section */
447 |
448 | /* Begin PBXReferenceProxy section */
449 | 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */ = {
450 | isa = PBXReferenceProxy;
451 | fileType = archive.ar;
452 | path = libRCTActionSheet.a;
453 | remoteRef = 00C302AB1ABCB8CE00DB3ED1 /* PBXContainerItemProxy */;
454 | sourceTree = BUILT_PRODUCTS_DIR;
455 | };
456 | 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */ = {
457 | isa = PBXReferenceProxy;
458 | fileType = archive.ar;
459 | path = libRCTGeolocation.a;
460 | remoteRef = 00C302B91ABCB90400DB3ED1 /* PBXContainerItemProxy */;
461 | sourceTree = BUILT_PRODUCTS_DIR;
462 | };
463 | 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */ = {
464 | isa = PBXReferenceProxy;
465 | fileType = archive.ar;
466 | path = libRCTImage.a;
467 | remoteRef = 00C302BF1ABCB91800DB3ED1 /* PBXContainerItemProxy */;
468 | sourceTree = BUILT_PRODUCTS_DIR;
469 | };
470 | 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */ = {
471 | isa = PBXReferenceProxy;
472 | fileType = archive.ar;
473 | path = libRCTNetwork.a;
474 | remoteRef = 00C302DB1ABCB9D200DB3ED1 /* PBXContainerItemProxy */;
475 | sourceTree = BUILT_PRODUCTS_DIR;
476 | };
477 | 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */ = {
478 | isa = PBXReferenceProxy;
479 | fileType = archive.ar;
480 | path = libRCTVibration.a;
481 | remoteRef = 00C302E31ABCB9EE00DB3ED1 /* PBXContainerItemProxy */;
482 | sourceTree = BUILT_PRODUCTS_DIR;
483 | };
484 | 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */ = {
485 | isa = PBXReferenceProxy;
486 | fileType = archive.ar;
487 | path = libRCTSettings.a;
488 | remoteRef = 139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */;
489 | sourceTree = BUILT_PRODUCTS_DIR;
490 | };
491 | 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */ = {
492 | isa = PBXReferenceProxy;
493 | fileType = archive.ar;
494 | path = libRCTWebSocket.a;
495 | remoteRef = 139FDEF31B06529B00C62182 /* PBXContainerItemProxy */;
496 | sourceTree = BUILT_PRODUCTS_DIR;
497 | };
498 | 146834041AC3E56700842450 /* libReact.a */ = {
499 | isa = PBXReferenceProxy;
500 | fileType = archive.ar;
501 | path = libReact.a;
502 | remoteRef = 146834031AC3E56700842450 /* PBXContainerItemProxy */;
503 | sourceTree = BUILT_PRODUCTS_DIR;
504 | };
505 | 5F5493611D40F4BD00E267B3 /* libreact-native-media-kit.a */ = {
506 | isa = PBXReferenceProxy;
507 | fileType = archive.ar;
508 | path = "libreact-native-media-kit.a";
509 | remoteRef = 5F5493601D40F4BD00E267B3 /* PBXContainerItemProxy */;
510 | sourceTree = BUILT_PRODUCTS_DIR;
511 | };
512 | 78C398B91ACF4ADC00677621 /* libRCTLinking.a */ = {
513 | isa = PBXReferenceProxy;
514 | fileType = archive.ar;
515 | path = libRCTLinking.a;
516 | remoteRef = 78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */;
517 | sourceTree = BUILT_PRODUCTS_DIR;
518 | };
519 | 832341B51AAA6A8300B99B32 /* libRCTText.a */ = {
520 | isa = PBXReferenceProxy;
521 | fileType = archive.ar;
522 | path = libRCTText.a;
523 | remoteRef = 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */;
524 | sourceTree = BUILT_PRODUCTS_DIR;
525 | };
526 | /* End PBXReferenceProxy section */
527 |
528 | /* Begin PBXResourcesBuildPhase section */
529 | 00E356EC1AD99517003FC87E /* Resources */ = {
530 | isa = PBXResourcesBuildPhase;
531 | buildActionMask = 2147483647;
532 | files = (
533 | );
534 | runOnlyForDeploymentPostprocessing = 0;
535 | };
536 | 13B07F8E1A680F5B00A75B9A /* Resources */ = {
537 | isa = PBXResourcesBuildPhase;
538 | buildActionMask = 2147483647;
539 | files = (
540 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
541 | 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */,
542 | );
543 | runOnlyForDeploymentPostprocessing = 0;
544 | };
545 | /* End PBXResourcesBuildPhase section */
546 |
547 | /* Begin PBXShellScriptBuildPhase section */
548 | 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = {
549 | isa = PBXShellScriptBuildPhase;
550 | buildActionMask = 2147483647;
551 | files = (
552 | );
553 | inputPaths = (
554 | );
555 | name = "Bundle React Native code and images";
556 | outputPaths = (
557 | );
558 | runOnlyForDeploymentPostprocessing = 0;
559 | shellPath = /bin/sh;
560 | shellScript = "export NODE_BINARY=node\n../node_modules/react-native/packager/react-native-xcode.sh";
561 | };
562 | /* End PBXShellScriptBuildPhase section */
563 |
564 | /* Begin PBXSourcesBuildPhase section */
565 | 00E356EA1AD99517003FC87E /* Sources */ = {
566 | isa = PBXSourcesBuildPhase;
567 | buildActionMask = 2147483647;
568 | files = (
569 | 00E356F31AD99517003FC87E /* DemoTests.m in Sources */,
570 | );
571 | runOnlyForDeploymentPostprocessing = 0;
572 | };
573 | 13B07F871A680F5B00A75B9A /* Sources */ = {
574 | isa = PBXSourcesBuildPhase;
575 | buildActionMask = 2147483647;
576 | files = (
577 | 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */,
578 | 13B07FC11A68108700A75B9A /* main.m in Sources */,
579 | );
580 | runOnlyForDeploymentPostprocessing = 0;
581 | };
582 | /* End PBXSourcesBuildPhase section */
583 |
584 | /* Begin PBXTargetDependency section */
585 | 00E356F51AD99517003FC87E /* PBXTargetDependency */ = {
586 | isa = PBXTargetDependency;
587 | target = 13B07F861A680F5B00A75B9A /* Demo */;
588 | targetProxy = 00E356F41AD99517003FC87E /* PBXContainerItemProxy */;
589 | };
590 | /* End PBXTargetDependency section */
591 |
592 | /* Begin PBXVariantGroup section */
593 | 13B07FB11A68108700A75B9A /* LaunchScreen.xib */ = {
594 | isa = PBXVariantGroup;
595 | children = (
596 | 13B07FB21A68108700A75B9A /* Base */,
597 | );
598 | name = LaunchScreen.xib;
599 | path = Demo;
600 | sourceTree = "";
601 | };
602 | /* End PBXVariantGroup section */
603 |
604 | /* Begin XCBuildConfiguration section */
605 | 00E356F61AD99517003FC87E /* Debug */ = {
606 | isa = XCBuildConfiguration;
607 | buildSettings = {
608 | BUNDLE_LOADER = "$(TEST_HOST)";
609 | GCC_PREPROCESSOR_DEFINITIONS = (
610 | "DEBUG=1",
611 | "$(inherited)",
612 | );
613 | INFOPLIST_FILE = DemoTests/Info.plist;
614 | IPHONEOS_DEPLOYMENT_TARGET = 8.2;
615 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
616 | PRODUCT_NAME = "$(TARGET_NAME)";
617 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Demo.app/Demo";
618 | };
619 | name = Debug;
620 | };
621 | 00E356F71AD99517003FC87E /* Release */ = {
622 | isa = XCBuildConfiguration;
623 | buildSettings = {
624 | BUNDLE_LOADER = "$(TEST_HOST)";
625 | COPY_PHASE_STRIP = NO;
626 | INFOPLIST_FILE = DemoTests/Info.plist;
627 | IPHONEOS_DEPLOYMENT_TARGET = 8.2;
628 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
629 | PRODUCT_NAME = "$(TARGET_NAME)";
630 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Demo.app/Demo";
631 | };
632 | name = Release;
633 | };
634 | 13B07F941A680F5B00A75B9A /* Debug */ = {
635 | isa = XCBuildConfiguration;
636 | buildSettings = {
637 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
638 | DEAD_CODE_STRIPPING = NO;
639 | HEADER_SEARCH_PATHS = (
640 | "$(inherited)",
641 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
642 | "$(SRCROOT)/../node_modules/react-native/React/**",
643 | );
644 | INFOPLIST_FILE = Demo/Info.plist;
645 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
646 | OTHER_LDFLAGS = (
647 | "$(inherited)",
648 | "-ObjC",
649 | "-lc++",
650 | );
651 | PRODUCT_NAME = Demo;
652 | };
653 | name = Debug;
654 | };
655 | 13B07F951A680F5B00A75B9A /* Release */ = {
656 | isa = XCBuildConfiguration;
657 | buildSettings = {
658 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
659 | HEADER_SEARCH_PATHS = (
660 | "$(inherited)",
661 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
662 | "$(SRCROOT)/../node_modules/react-native/React/**",
663 | );
664 | INFOPLIST_FILE = Demo/Info.plist;
665 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
666 | OTHER_LDFLAGS = (
667 | "$(inherited)",
668 | "-ObjC",
669 | "-lc++",
670 | );
671 | PRODUCT_NAME = Demo;
672 | };
673 | name = Release;
674 | };
675 | 83CBBA201A601CBA00E9B192 /* Debug */ = {
676 | isa = XCBuildConfiguration;
677 | buildSettings = {
678 | ALWAYS_SEARCH_USER_PATHS = NO;
679 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
680 | CLANG_CXX_LIBRARY = "libc++";
681 | CLANG_ENABLE_MODULES = YES;
682 | CLANG_ENABLE_OBJC_ARC = YES;
683 | CLANG_WARN_BOOL_CONVERSION = YES;
684 | CLANG_WARN_CONSTANT_CONVERSION = YES;
685 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
686 | CLANG_WARN_EMPTY_BODY = YES;
687 | CLANG_WARN_ENUM_CONVERSION = YES;
688 | CLANG_WARN_INT_CONVERSION = YES;
689 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
690 | CLANG_WARN_UNREACHABLE_CODE = YES;
691 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
692 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
693 | COPY_PHASE_STRIP = NO;
694 | ENABLE_STRICT_OBJC_MSGSEND = YES;
695 | GCC_C_LANGUAGE_STANDARD = gnu99;
696 | GCC_DYNAMIC_NO_PIC = NO;
697 | GCC_OPTIMIZATION_LEVEL = 0;
698 | GCC_PREPROCESSOR_DEFINITIONS = (
699 | "DEBUG=1",
700 | "$(inherited)",
701 | );
702 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
703 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
704 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
705 | GCC_WARN_UNDECLARED_SELECTOR = YES;
706 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
707 | GCC_WARN_UNUSED_FUNCTION = YES;
708 | GCC_WARN_UNUSED_VARIABLE = YES;
709 | HEADER_SEARCH_PATHS = (
710 | "$(inherited)",
711 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
712 | "$(SRCROOT)/../node_modules/react-native/React/**",
713 | );
714 | IPHONEOS_DEPLOYMENT_TARGET = 7.0;
715 | MTL_ENABLE_DEBUG_INFO = YES;
716 | ONLY_ACTIVE_ARCH = YES;
717 | SDKROOT = iphoneos;
718 | };
719 | name = Debug;
720 | };
721 | 83CBBA211A601CBA00E9B192 /* Release */ = {
722 | isa = XCBuildConfiguration;
723 | buildSettings = {
724 | ALWAYS_SEARCH_USER_PATHS = NO;
725 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
726 | CLANG_CXX_LIBRARY = "libc++";
727 | CLANG_ENABLE_MODULES = YES;
728 | CLANG_ENABLE_OBJC_ARC = YES;
729 | CLANG_WARN_BOOL_CONVERSION = YES;
730 | CLANG_WARN_CONSTANT_CONVERSION = YES;
731 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
732 | CLANG_WARN_EMPTY_BODY = YES;
733 | CLANG_WARN_ENUM_CONVERSION = YES;
734 | CLANG_WARN_INT_CONVERSION = YES;
735 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
736 | CLANG_WARN_UNREACHABLE_CODE = YES;
737 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
738 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
739 | COPY_PHASE_STRIP = YES;
740 | ENABLE_NS_ASSERTIONS = NO;
741 | ENABLE_STRICT_OBJC_MSGSEND = YES;
742 | GCC_C_LANGUAGE_STANDARD = gnu99;
743 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
744 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
745 | GCC_WARN_UNDECLARED_SELECTOR = YES;
746 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
747 | GCC_WARN_UNUSED_FUNCTION = YES;
748 | GCC_WARN_UNUSED_VARIABLE = YES;
749 | HEADER_SEARCH_PATHS = (
750 | "$(inherited)",
751 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
752 | "$(SRCROOT)/../node_modules/react-native/React/**",
753 | );
754 | IPHONEOS_DEPLOYMENT_TARGET = 7.0;
755 | MTL_ENABLE_DEBUG_INFO = NO;
756 | SDKROOT = iphoneos;
757 | VALIDATE_PRODUCT = YES;
758 | };
759 | name = Release;
760 | };
761 | /* End XCBuildConfiguration section */
762 |
763 | /* Begin XCConfigurationList section */
764 | 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "DemoTests" */ = {
765 | isa = XCConfigurationList;
766 | buildConfigurations = (
767 | 00E356F61AD99517003FC87E /* Debug */,
768 | 00E356F71AD99517003FC87E /* Release */,
769 | );
770 | defaultConfigurationIsVisible = 0;
771 | defaultConfigurationName = Release;
772 | };
773 | 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "Demo" */ = {
774 | isa = XCConfigurationList;
775 | buildConfigurations = (
776 | 13B07F941A680F5B00A75B9A /* Debug */,
777 | 13B07F951A680F5B00A75B9A /* Release */,
778 | );
779 | defaultConfigurationIsVisible = 0;
780 | defaultConfigurationName = Release;
781 | };
782 | 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "Demo" */ = {
783 | isa = XCConfigurationList;
784 | buildConfigurations = (
785 | 83CBBA201A601CBA00E9B192 /* Debug */,
786 | 83CBBA211A601CBA00E9B192 /* Release */,
787 | );
788 | defaultConfigurationIsVisible = 0;
789 | defaultConfigurationName = Release;
790 | };
791 | /* End XCConfigurationList section */
792 | };
793 | rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */;
794 | }
795 |
--------------------------------------------------------------------------------
/Demo/ios/Demo.xcodeproj/xcshareddata/xcschemes/Demo.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
29 |
35 |
36 |
37 |
38 |
39 |
44 |
45 |
47 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
65 |
66 |
75 |
77 |
83 |
84 |
85 |
86 |
87 |
88 |
94 |
96 |
102 |
103 |
104 |
105 |
107 |
108 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/Demo/ios/Demo/AppDelegate.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 |
12 | @interface AppDelegate : UIResponder
13 |
14 | @property (nonatomic, strong) UIWindow *window;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/Demo/ios/Demo/AppDelegate.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import "AppDelegate.h"
11 |
12 | #import "RCTBundleURLProvider.h"
13 | #import "RCTRootView.h"
14 |
15 | @implementation AppDelegate
16 |
17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
18 | {
19 | NSURL *jsCodeLocation;
20 |
21 | [[RCTBundleURLProvider sharedSettings] setDefaults];
22 | jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
23 |
24 | RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
25 | moduleName:@"Demo"
26 | initialProperties:nil
27 | launchOptions:launchOptions];
28 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
29 |
30 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
31 | UIViewController *rootViewController = [UIViewController new];
32 | rootViewController.view = rootView;
33 | self.window.rootViewController = rootViewController;
34 | [self.window makeKeyAndVisible];
35 | return YES;
36 | }
37 |
38 | @end
39 |
--------------------------------------------------------------------------------
/Demo/ios/Demo/Base.lproj/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
21 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/Demo/ios/Demo/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/Demo/ios/Demo/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UIViewControllerBasedStatusBarAppearance
38 |
39 | NSLocationWhenInUseUsageDescription
40 |
41 | NSAppTransportSecurity
42 |
43 | NSAllowsArbitraryLoads
44 |
45 | NSExceptionDomains
46 |
47 | localhost
48 |
49 | NSTemporaryExceptionAllowsInsecureHTTPLoads
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/Demo/ios/Demo/main.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 |
12 | #import "AppDelegate.h"
13 |
14 | int main(int argc, char * argv[]) {
15 | @autoreleasepool {
16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Demo/ios/DemoTests/DemoTests.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | #import
11 | #import
12 |
13 | #import "RCTLog.h"
14 | #import "RCTRootView.h"
15 |
16 | #define TIMEOUT_SECONDS 600
17 | #define TEXT_TO_LOOK_FOR @"Welcome to React Native!"
18 |
19 | @interface DemoTests : XCTestCase
20 |
21 | @end
22 |
23 | @implementation DemoTests
24 |
25 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test
26 | {
27 | if (test(view)) {
28 | return YES;
29 | }
30 | for (UIView *subview in [view subviews]) {
31 | if ([self findSubviewInView:subview matching:test]) {
32 | return YES;
33 | }
34 | }
35 | return NO;
36 | }
37 |
38 | - (void)testRendersWelcomeScreen
39 | {
40 | UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
41 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
42 | BOOL foundElement = NO;
43 |
44 | __block NSString *redboxError = nil;
45 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
46 | if (level >= RCTLogLevelError) {
47 | redboxError = message;
48 | }
49 | });
50 |
51 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
52 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
53 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
54 |
55 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) {
56 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) {
57 | return YES;
58 | }
59 | return NO;
60 | }];
61 | }
62 |
63 | RCTSetLogFunction(RCTDefaultLogFunction);
64 |
65 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
66 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
67 | }
68 |
69 |
70 | @end
71 |
--------------------------------------------------------------------------------
/Demo/ios/DemoTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Demo/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Demo",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "start": "node_modules/react-native/packager/packager.sh"
7 | },
8 | "dependencies": {
9 | "react": "15.2.1",
10 | "react-native": "^0.29.2",
11 | "react-native-media-kit": "0.0.14"
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # react-native-media-kit
2 |
3 | Video(and audio) component for react-native apps, supporting both iOS and Android, with API similar to HTML video.
4 |
5 | A default set of controls is provided to play/pause, seek and to display current playback and buffer progress.
6 |
7 | Runs on react-native 0.28+ (The limit exists due to [ActivityIndicator](https://facebook.github.io/react-native/docs/activityindicator.html) comes after 0.28).
8 |
9 | Supported media types:
10 |
11 | * iOS: Should be same as those supported by [AVPlayer](https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVPlayer_Class/)
12 |
13 |
14 | * Android: Shold be same as those supported by [ExoPlayer](https://github.com/google/ExoPlayer)
15 |
16 | .
17 |
18 | ## Install
19 |
20 | `npm install --save react-native-media-kit@latest `
21 |
22 | #### iOS
23 |
24 | For now, just drag ***react-native-media-kit.xcodeproj*** into your Xcode project and link the **libreact-native-media-kit.a** library.
25 |
26 | #### Android
27 |
28 | **android/settings.gradle**
29 |
30 | ```
31 | include ':react-native-media-kit'
32 | project(':react-native-media-kit').projectDir = new File('../node_modules/react-native-media-kit/android')
33 | ```
34 |
35 | **android/app/build.gradle**
36 |
37 | ```
38 | dependencies {
39 | ...
40 | compile project(':react-native-media-kit')
41 | }
42 | ```
43 |
44 | **MainActivity.java (or MainApplication on rn 0.29+)**
45 |
46 | ```
47 | import com.greatdroid.reactnative.media.MediaKitPackage;
48 | ...
49 | protected List getPackages() {
50 | return Arrays.asList(
51 | new MainReactPackage(),
52 | new MediaKitPackage()
53 | );
54 | }
55 | ```
56 |
57 |
58 |
59 | ## Documentation
60 |
61 | ```
62 | import {Video} from 'react-native-media-kit';
63 | ...
64 | render() {
65 | return (
66 |
76 | );
77 | }
78 |
79 | ```
80 |
81 | ### API
82 |
83 | The API is designed to mimics html [``](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video). (*For now, the Video and Audio component are identical*)
84 |
85 | ##### Properties
86 |
87 | | key | value | iOS | Android |
88 | | -------------------- | ---------------------------------------- | ---- | ------- |
89 | | src | the URL of the video | OK | OK |
90 | | autoplay | true to automatically begins to play. Default is false. | OK | OK |
91 | | preload | can be 'none', 'auto'. Default is 'none'. | OK | OK |
92 | | loop | true to automatically seek back to the start upon reaching the end of the video. Default is 'false'. | OK | OK |
93 | | controls | true to show controls to allow user to control video playback, including seeking, and pause/resume playback. Default is true. | OK | OK |
94 | | poster | an image URL indicating a poster frame to show until the user plays. | OK | OK |
95 | | muted | true to silence the audio. Default is false. | OK | OK |
96 | | onPlayerPaused | | OK | OK |
97 | | onPlayerPlaying | | OK | OK |
98 | | onPlayerFinished | | OK | OK |
99 | | onPlayerBuffering | | OK | OK |
100 | | onPlayerBufferOK | | OK | OK |
101 | | onPlayerProgress | | OK | OK |
102 | | onPlayerBufferChange | | OK | OK |
103 |
104 | - ***pause***
105 | - ***play***
106 | - ***stop***
107 | - ***seekTo***
108 |
109 |
110 | For details about the usage of above APIs, check `library/MediaPlayerView.js`.
111 |
112 |
113 |
114 | ## TODO
115 |
116 | * background play
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 16
9 | targetSdkVersion 23
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile fileTree(dir: 'libs', include: ['*.jar'])
23 | testCompile 'junit:junit:4.12'
24 | compile 'com.android.support:appcompat-v7:23.0.1'
25 | compile 'com.google.android.exoplayer:exoplayer:r1.5.6'
26 | compile "com.facebook.react:react-native:+"
27 | }
28 |
--------------------------------------------------------------------------------
/android/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 /Users/ldn/Dev/Android/android-sdk-macosx/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 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/android/src/androidTest/java/com/yoai/reactnative/media/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.yoai.reactnative.media;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/android/src/main/java/com/greatdroid/reactnative/media/MediaKitPackage.java:
--------------------------------------------------------------------------------
1 | package com.greatdroid.reactnative.media;
2 |
3 | import com.facebook.react.ReactPackage;
4 | import com.facebook.react.bridge.JavaScriptModule;
5 | import com.facebook.react.bridge.NativeModule;
6 | import com.facebook.react.bridge.ReactApplicationContext;
7 | import com.facebook.react.uimanager.ViewManager;
8 | import com.greatdroid.reactnative.media.player.ReactMediaPlayerViewManager;
9 |
10 | import java.util.Arrays;
11 | import java.util.Collections;
12 | import java.util.List;
13 |
14 | public class MediaKitPackage implements ReactPackage {
15 |
16 | @Override
17 | public List createNativeModules(ReactApplicationContext reactContext) {
18 | return Collections.emptyList();
19 | }
20 |
21 |
22 | @Override
23 | public List> createJSModules() {
24 | return Collections.emptyList();
25 | }
26 |
27 | @Override
28 | public List createViewManagers(ReactApplicationContext reactContext) {
29 | return Arrays.asList(new ReactMediaPlayerViewManager());
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/android/src/main/java/com/greatdroid/reactnative/media/player/MediaPlayerController.java:
--------------------------------------------------------------------------------
1 | package com.greatdroid.reactnative.media.player;
2 |
3 | import android.content.Context;
4 | import android.graphics.SurfaceTexture;
5 | import android.media.MediaCodec;
6 | import android.media.MediaDrm;
7 | import android.net.Uri;
8 | import android.os.Handler;
9 | import android.os.Looper;
10 | import android.util.Log;
11 | import android.view.Surface;
12 | import android.view.TextureView;
13 | import android.view.View;
14 | import android.view.ViewGroup;
15 | import android.widget.FrameLayout;
16 |
17 | import com.google.android.exoplayer.AspectRatioFrameLayout;
18 | import com.google.android.exoplayer.DummyTrackRenderer;
19 | import com.google.android.exoplayer.ExoPlaybackException;
20 | import com.google.android.exoplayer.ExoPlayer;
21 | import com.google.android.exoplayer.MediaCodecAudioTrackRenderer;
22 | import com.google.android.exoplayer.MediaCodecTrackRenderer;
23 | import com.google.android.exoplayer.MediaCodecVideoTrackRenderer;
24 | import com.google.android.exoplayer.TrackRenderer;
25 | import com.google.android.exoplayer.audio.AudioTrack;
26 | import com.google.android.exoplayer.drm.MediaDrmCallback;
27 | import com.google.android.exoplayer.metadata.MetadataTrackRenderer;
28 | import com.google.android.exoplayer.metadata.id3.Id3Frame;
29 | import com.google.android.exoplayer.text.Cue;
30 | import com.google.android.exoplayer.text.TextRenderer;
31 | import com.google.android.exoplayer.upstream.BandwidthMeter;
32 | import com.google.android.exoplayer.util.Util;
33 | import com.greatdroid.reactnative.media.player.trackrenderer.DashRenderersBuilder;
34 | import com.greatdroid.reactnative.media.player.trackrenderer.ExtractorRenderersBuilder;
35 | import com.greatdroid.reactnative.media.player.trackrenderer.HlsRenderersBuilder;
36 | import com.greatdroid.reactnative.media.player.trackrenderer.SmoothStreamingRenderersBuilder;
37 |
38 | import java.util.LinkedList;
39 | import java.util.List;
40 | import java.util.UUID;
41 |
42 | public class MediaPlayerController {
43 | private static final String TAG = "MediaPlayerController";
44 |
45 | private final Context context;
46 | private final ExoPlayer exoPlayer;
47 | private final Handler mainHandler;
48 |
49 | private String uri;
50 |
51 | private final InternalEventListener internalEventListener = new InternalEventListener();
52 | private final List eventListeners = new LinkedList<>();
53 |
54 | private TrackRenderersBuilder trackRenderersBuilder;
55 | private TrackRenderer videoTrackRenderer;
56 | private TrackRenderer audioTrackRenderer;
57 |
58 | private final AspectRatioFrameLayout aspectRatioFrameLayout;
59 | private TextureView textureView;
60 | private SurfaceTexture surfaceTexture;
61 |
62 | private boolean ended = false;
63 | private boolean loop = false;
64 | private boolean muted = false;
65 |
66 |
67 | public MediaPlayerController(Context context) {
68 | this.context = context;
69 | this.exoPlayer = ExoPlayer.Factory.newInstance(TrackRenderersBuilder.TRACK_RENDER_COUNT, 1000, 1000);
70 | this.exoPlayer.addListener(internalEventListener);
71 | this.exoPlayer.setPlayWhenReady(false);
72 | this.mainHandler = new Handler(Looper.getMainLooper());
73 |
74 |
75 | this.aspectRatioFrameLayout = new AspectRatioFrameLayout(context);
76 | this.textureView = new TextureView(aspectRatioFrameLayout.getContext());
77 | this.textureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {
78 | @Override
79 | public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
80 | Log.d(TAG, "onSurfaceTextureAvailable...w=" + width + ", h=" + height + ", surface=" + surface);
81 | if(surfaceTexture != null) {
82 | Log.d(TAG, "onSurfaceTextureAvailable...reuse old surfaceTexture");
83 | textureView.setSurfaceTexture(surfaceTexture);
84 | return;
85 | }
86 | setSurfaceTexture(surface);
87 | }
88 |
89 | @Override
90 | public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
91 | Log.d(TAG, "onSurfaceTextureSizeChanged...w=" + width + ", h=" + height);
92 | }
93 |
94 | @Override
95 | public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
96 | Log.d(TAG, "onSurfaceTextureDestroyed...");
97 | return false;
98 | }
99 |
100 | @Override
101 | public void onSurfaceTextureUpdated(SurfaceTexture surface) {
102 | }
103 | });
104 | this.aspectRatioFrameLayout.addView(textureView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
105 | }
106 |
107 | public void setContentUri(String uri) {
108 | if(uri != null && uri.equals(this.uri))
109 | return;
110 | this.uri = uri;
111 | resetPlayerForReuse();
112 | }
113 |
114 | public void setMuted(boolean muted) {
115 | this.muted = muted;
116 | if(audioTrackRenderer != null) {
117 | if(muted) {
118 | exoPlayer.sendMessage(audioTrackRenderer, MediaCodecAudioTrackRenderer.MSG_SET_VOLUME, 0f);
119 | } else {
120 | exoPlayer.sendMessage(audioTrackRenderer, MediaCodecAudioTrackRenderer.MSG_SET_VOLUME, 1f);
121 | }
122 | }
123 | }
124 |
125 | public void prepareToPlay() {
126 | if(trackRenderersBuilder == null && this.uri != null) {
127 | renderTracks(this.uri);
128 | }
129 | }
130 |
131 | private void resetPlayerForReuse() {
132 | this.exoPlayer.stop();
133 | this.exoPlayer.seekTo(0);
134 | if (this.trackRenderersBuilder != null) {
135 | this.trackRenderersBuilder.cancel();
136 | this.trackRenderersBuilder = null;
137 | }
138 | }
139 |
140 | private void renderTracks(String uri) {
141 | this.trackRenderersBuilder = createTrackRenderersBuilder(context, uri);
142 | this.trackRenderersBuilder.build(new TrackRenderersBuilder.Callback() {
143 | @Override
144 | public void onFinish(TrackRenderer[] trackRenderers) {
145 | Log.d(TAG, "renderTracks...track renderers built");
146 | for (int i = 0; i < TrackRenderersBuilder.TRACK_RENDER_COUNT; i++) {
147 | if (trackRenderers[i] == null) {
148 | // Convert a null renderer to a dummy renderer.
149 | trackRenderers[i] = new DummyTrackRenderer();
150 | }
151 | }
152 | videoTrackRenderer = trackRenderers[TrackRenderersBuilder.TRACK_VIDEO_INDEX];
153 | audioTrackRenderer = trackRenderers[TrackRenderersBuilder.TRACK_AUDIO_INDEX];
154 | exoPlayer.prepare(trackRenderers);
155 |
156 | if (surfaceTexture != null) {
157 | setSurface(new Surface(surfaceTexture));
158 | }
159 |
160 | if (muted) {
161 | setMuted(true);
162 | }
163 | }
164 |
165 | @Override
166 | public void onError(Exception e) {
167 | Log.e(TAG, "renderTracks...failed to build track renderers", e);
168 | notifyError(e);
169 | }
170 | });
171 | }
172 |
173 | private TrackRenderersBuilder createTrackRenderersBuilder(Context context, String uriString) {
174 | final Uri uri = Uri.parse(uriString);
175 | final int contentType = Util.inferContentType(uri.getLastPathSegment());
176 | final String userAgent = Util.getUserAgent(context, "react-native-media-kit");
177 |
178 | switch (contentType) {
179 | case Util.TYPE_DASH:
180 | return new DashRenderersBuilder(context, userAgent, uriString, mainHandler, mediaDrmCallback, internalEventListener, internalEventListener, internalEventListener, bandwidthMeterListener, exoPlayer.getPlaybackLooper());
181 | case Util.TYPE_HLS:
182 | return new HlsRenderersBuilder(context, userAgent, uriString, mainHandler, internalEventListener, internalEventListener, internalEventListener, internalEventListener, bandwidthMeterListener);
183 | case Util.TYPE_SS:
184 | return new SmoothStreamingRenderersBuilder(context, userAgent, uriString, mainHandler, mediaDrmCallback, internalEventListener, internalEventListener, internalEventListener, bandwidthMeterListener, exoPlayer.getPlaybackLooper());
185 | case Util.TYPE_OTHER:
186 | return new ExtractorRenderersBuilder(context, userAgent, uri, mainHandler, internalEventListener, internalEventListener, internalEventListener, bandwidthMeterListener);
187 | default:
188 | throw new IllegalStateException("Unsupported content type: " + contentType);
189 | }
190 | }
191 |
192 | public void setLoop(boolean loop) {
193 | this.loop = loop;
194 | }
195 |
196 | public void setPlayWhenReady(boolean playWhenReady) {
197 | exoPlayer.setPlayWhenReady(playWhenReady);
198 | }
199 |
200 | public boolean getPlayWhenReady() {
201 | return exoPlayer.getPlayWhenReady();
202 | }
203 |
204 | public void play() {
205 | Log.d(TAG, "play...");
206 | exoPlayer.setPlayWhenReady(true);
207 | if (ended) {
208 | seekTo(0);
209 | }
210 |
211 | if(trackRenderersBuilder == null) {
212 | prepareToPlay();
213 | }
214 | }
215 |
216 | public void pause() {
217 | Log.d(TAG, "pause...");
218 | exoPlayer.setPlayWhenReady(false);
219 | }
220 |
221 | public void seekTo(long positionMs) {
222 | Log.d(TAG, "seekTo..." + positionMs);
223 | exoPlayer.seekTo(positionMs);
224 | }
225 |
226 | public void stop() {
227 | Log.d(TAG, "stop...");
228 | exoPlayer.stop();
229 | }
230 |
231 | public long getCurrentPosition() {
232 | return exoPlayer.getCurrentPosition();
233 | }
234 |
235 | public long getDuration() {
236 | return exoPlayer.getDuration();
237 | }
238 |
239 | public long getBufferedPosition() {
240 | return exoPlayer.getBufferedPosition();
241 | }
242 |
243 | public void release() {
244 | if (trackRenderersBuilder != null) {
245 | trackRenderersBuilder.cancel();
246 | trackRenderersBuilder = null;
247 | }
248 | if (surfaceTexture != null) {
249 | surfaceTexture.release();
250 | surfaceTexture = null;
251 | }
252 | exoPlayer.release();
253 | }
254 |
255 | private void setSurface(Surface surface) {
256 | if (videoTrackRenderer != null) {
257 | if (surface == null) {
258 | exoPlayer.blockingSendMessage(videoTrackRenderer, MediaCodecVideoTrackRenderer.MSG_SET_SURFACE, null);
259 | } else {
260 | exoPlayer.sendMessage(videoTrackRenderer, MediaCodecVideoTrackRenderer.MSG_SET_SURFACE, surface);
261 | }
262 | } else {
263 | Log.w(TAG, "setSurface...video track not ready");
264 | }
265 | }
266 |
267 | public void setSurfaceTexture(SurfaceTexture surfaceTexture) {
268 | this.surfaceTexture = surfaceTexture;
269 | setSurface(surfaceTexture == null ? null : new Surface(surfaceTexture));
270 | }
271 |
272 | public final View getView() {
273 | return aspectRatioFrameLayout;
274 | }
275 |
276 | public void addEventListener(EventListener listener) {
277 | synchronized (eventListeners) {
278 | eventListeners.add(listener);
279 | }
280 | }
281 |
282 | public void removeEventListener(EventListener listener) {
283 | synchronized (eventListeners) {
284 | while (eventListeners.contains(listener)) {
285 | eventListeners.remove(listener);
286 | }
287 | }
288 | }
289 |
290 |
291 |
292 |
293 | private class InternalEventListener implements MediaCodecVideoTrackRenderer.EventListener, MediaCodecAudioTrackRenderer.EventListener, TextRenderer, ExoPlayer.Listener, MetadataTrackRenderer.MetadataRenderer> {
294 |
295 | @Override
296 | public void onAudioTrackInitializationError(AudioTrack.InitializationException e) {
297 |
298 | }
299 |
300 | @Override
301 | public void onAudioTrackWriteError(AudioTrack.WriteException e) {
302 | notifyError(e);
303 | }
304 |
305 | @Override
306 | public void onAudioTrackUnderrun(int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs) {
307 |
308 | }
309 |
310 | @Override
311 | public void onDroppedFrames(int count, long elapsed) {
312 | Log.d(TAG, "onDroppedFrames...count=" + count + ", elapsed=" + elapsed);
313 | }
314 |
315 | @Override
316 | public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {
317 | notifyVideoSizeChanged(width, height, unappliedRotationDegrees, pixelWidthHeightRatio);
318 | }
319 |
320 | @Override
321 | public void onDrawnToSurface(Surface surface) {
322 | Log.i(TAG, "onDrawnToSurface...");
323 |
324 | }
325 |
326 | @Override
327 | public void onDecoderInitializationError(MediaCodecTrackRenderer.DecoderInitializationException e) {
328 | notifyError(e);
329 | }
330 |
331 | @Override
332 | public void onCryptoError(MediaCodec.CryptoException e) {
333 | notifyError(e);
334 | }
335 |
336 | @Override
337 | public void onDecoderInitialized(String decoderName, long elapsedRealtimeMs, long initializationDurationMs) {
338 |
339 | }
340 |
341 | @Override
342 | public void onCues(List cues) {
343 | notifyCues(cues);
344 | }
345 |
346 | @Override
347 | public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
348 | notifyPlayerStateChanged(playWhenReady, playbackState);
349 | }
350 |
351 | @Override
352 | public void onPlayWhenReadyCommitted() {
353 |
354 | }
355 |
356 | @Override
357 | public void onPlayerError(ExoPlaybackException error) {
358 | notifyError(error);
359 | }
360 |
361 | @Override
362 | public void onMetadata(List metadata) {
363 |
364 | }
365 | }
366 |
367 | private void notifyError(Exception e) {
368 | synchronized (eventListeners) {
369 | for (EventListener listener : eventListeners) {
370 | listener.onError(e);
371 | }
372 | }
373 | }
374 |
375 | private void notifyVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {
376 | Log.d(TAG, "videoSize...w=" + width + ", h=" + height);
377 |
378 | aspectRatioFrameLayout.setAspectRatio(height == 0 ? 0 : (width * pixelWidthHeightRatio) / height);
379 |
380 | synchronized (eventListeners) {
381 | for (EventListener listener : eventListeners) {
382 | listener.onVideoSizeChanged(width, height, unappliedRotationDegrees, pixelWidthHeightRatio);
383 | }
384 | }
385 | }
386 |
387 | private void notifyPlayerStateChanged(boolean playWhenReady, int playbackState) {
388 | if (playbackState == ExoPlayer.STATE_ENDED) {
389 | ended = true;
390 | if(loop) {
391 | exoPlayer.seekTo(0);
392 | }
393 | } else {
394 | ended = false;
395 | }
396 | synchronized (eventListeners) {
397 | for (EventListener listener : eventListeners) {
398 | listener.onPlayerStateChanged(playWhenReady, playbackState);
399 | }
400 | }
401 | }
402 |
403 | private void notifyCues(List cues) {
404 | synchronized (eventListeners) {
405 | for (EventListener listener : eventListeners) {
406 | listener.onCues(cues);
407 | }
408 | }
409 | }
410 |
411 |
412 | public interface EventListener {
413 | void onError(Exception e);
414 |
415 | /**
416 | * Invoked each time there's a change in the size of the video being rendered.
417 | *
418 | * @param width The video width in pixels.
419 | * @param height The video height in pixels.
420 | * @param unappliedRotationDegrees For videos that require a rotation, this is the clockwise
421 | * rotation in degrees that the application should apply for the video for it to be rendered
422 | * in the correct orientation. This value will always be zero on API levels 21 and above,
423 | * since the renderer will apply all necessary rotations internally. On earlier API levels
424 | * this is not possible. Applications that use {@link TextureView} can apply the rotation by
425 | * calling {@link TextureView#setTransform}. Applications that do not expect to encounter
426 | * rotated videos can safely ignore this parameter.
427 | * @param pixelWidthHeightRatio The width to height ratio of each pixel. For the normal case
428 | * of square pixels this will be equal to 1.0. Different values are indicative of anamorphic
429 | * content.
430 | */
431 | void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio);
432 |
433 | void onPlayerStateChanged(boolean playWhenReady, int playbackState);
434 |
435 | /**
436 | * Invoked each time there is a change in the {@link Cue}s to be rendered.
437 | *
438 | * @param cues The {@link Cue}s to be rendered, or an empty list if no cues are to be rendered.
439 | */
440 | void onCues(List cues);
441 |
442 | /**
443 | * Invoked each time there is a metadata associated with current playback time.
444 | *
445 | * @param metadata
446 | */
447 | void onMetadata(List metadata);
448 | }
449 |
450 | public static class BaseEventListener implements EventListener {
451 |
452 | @Override
453 | public void onError(Exception e) {
454 |
455 | }
456 |
457 | @Override
458 | public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {
459 |
460 | }
461 |
462 | @Override
463 | public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
464 |
465 | }
466 |
467 | @Override
468 | public void onCues(List cues) {
469 |
470 | }
471 |
472 | @Override
473 | public void onMetadata(List metadata) {
474 |
475 | }
476 | }
477 |
478 | private final MediaDrmCallback mediaDrmCallback = new MediaDrmCallback() {
479 | @Override
480 | public byte[] executeProvisionRequest(UUID uuid, MediaDrm.ProvisionRequest request) throws Exception {
481 | return new byte[0];
482 | }
483 |
484 | @Override
485 | public byte[] executeKeyRequest(UUID uuid, MediaDrm.KeyRequest request) throws Exception {
486 | return new byte[0];
487 | }
488 | };
489 |
490 | private final BandwidthMeter.EventListener bandwidthMeterListener = new BandwidthMeter.EventListener() {
491 | @Override
492 | public void onBandwidthSample(int elapsedMs, long bytes, long bitrate) {
493 | Log.d(TAG, "onBandwidthSample...elapsedMs=" + elapsedMs + ", bitrate=" + bitrate);
494 | }
495 | };
496 | }
497 |
--------------------------------------------------------------------------------
/android/src/main/java/com/greatdroid/reactnative/media/player/ReactMediaPlayerView.java:
--------------------------------------------------------------------------------
1 | package com.greatdroid.reactnative.media.player;
2 |
3 | import android.content.Context;
4 | import android.util.Log;
5 | import android.view.Gravity;
6 | import android.view.ViewGroup;
7 | import android.widget.FrameLayout;
8 |
9 | import com.facebook.react.bridge.LifecycleEventListener;
10 | import com.facebook.react.bridge.ReactContext;
11 | import com.google.android.exoplayer.ExoPlayer;
12 |
13 | public class ReactMediaPlayerView extends FrameLayout implements LifecycleEventListener {
14 | private static final String TAG = "ReactMediaPlayerView";
15 |
16 | private final Runnable measureAndLayout = new Runnable() {
17 | @Override
18 | public void run() {
19 | Log.d(TAG, "measure...w=" + getWidth() + ", h=" + getHeight());
20 | measure(
21 | MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.EXACTLY),
22 | MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.EXACTLY));
23 |
24 | Log.d(TAG, "layout...l=" + getLeft() + ", t=" + getTop() + ", r=" + getRight() + ", b=" + getBottom());
25 | layout(getLeft(), getTop(), getRight(), getBottom());
26 | }
27 | };
28 |
29 | private MediaPlayerControllerOwner mediaPlayerControllerOwner;
30 | private MediaPlayerController mediaPlayerController;
31 |
32 | private String uri;
33 | private boolean loop;
34 | private boolean autoplay;
35 | private boolean muted;
36 | private String preload;
37 |
38 | private boolean playWhenReadySnapshot;
39 | private long playPositionSnapshot = 0;
40 |
41 | private MediaPlayerListener mediaPlayerListener;
42 |
43 | private final MediaPlayerController.BaseEventListener l = new MediaPlayerController.BaseEventListener() {
44 |
45 | @Override
46 | public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {
47 | measureAndLayout.run();
48 | }
49 |
50 | @Override
51 | public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
52 | Log.d(TAG, "onPlayerStateChanged...playWhenReady=" + playWhenReady + ", state=" + descPlaybackState(playbackState));
53 | if (mediaPlayerListener != null) {
54 | switch (playbackState) {
55 | case ExoPlayer.STATE_BUFFERING:
56 | if (!playWhenReady) {
57 | mediaPlayerListener.onPlayerPaused();
58 | }
59 | case ExoPlayer.STATE_PREPARING:
60 | mediaPlayerListener.onPlayerBuffering();
61 | break;
62 | case ExoPlayer.STATE_ENDED:
63 | notifyProgress();
64 | mediaPlayerListener.onPlayerFinished();
65 | break;
66 | case ExoPlayer.STATE_IDLE:
67 | break;
68 | case ExoPlayer.STATE_READY:
69 | mediaPlayerListener.onPlayerBufferReady();
70 | if (playWhenReady) {
71 | mediaPlayerListener.onPlayerPlaying();
72 | } else {
73 | mediaPlayerListener.onPlayerPaused();
74 | }
75 | break;
76 | default:
77 | break;
78 | }
79 | }
80 |
81 | if (playbackState == ExoPlayer.STATE_READY) {
82 | notifyProgress();
83 | }
84 | if (playbackState == ExoPlayer.STATE_READY && mediaPlayerController != null && mediaPlayerController.getPlayWhenReady()) {
85 | startProgressTimer();
86 | } else {
87 | stopProgressTimer();
88 | }
89 | }
90 | };
91 |
92 | public ReactMediaPlayerView(final Context context) {
93 | super(context);
94 |
95 | mediaPlayerControllerOwner = new MediaPlayerControllerOwner() {
96 |
97 | @Override
98 | public void onOwnershipChanged(MediaPlayerControllerOwner owner, MediaPlayerController controller) {
99 | if (owner == mediaPlayerControllerOwner) {
100 | Log.d(TAG, "onOwnershipChanged...add view");
101 | controller.addEventListener(l);
102 | mediaPlayerController = controller;
103 | addView(controller.getView(), new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER));
104 | updateProps(controller);
105 | if(playPositionSnapshot > 0) {
106 | controller.seekTo(playPositionSnapshot);
107 | }
108 | } else {
109 | Log.d(TAG, "onOwnershipChanged...remove view");
110 | if(mediaPlayerController != null) {
111 | playPositionSnapshot = mediaPlayerController.getCurrentPosition();
112 | mediaPlayerController.removeEventListener(l);
113 | mediaPlayerController.setSurfaceTexture(null);
114 | mediaPlayerController.setContentUri(null);
115 | removeView(mediaPlayerController.getView());
116 | }
117 |
118 | stopProgressTimer();
119 | if (mediaPlayerListener != null) {
120 | mediaPlayerListener.onPlayerFinished();
121 | }
122 | mediaPlayerController = null;
123 | }
124 | }
125 | };
126 | }
127 |
128 | public MediaPlayerController getMediaPlayerController() {
129 | return mediaPlayerControllerOwner.requestOwnership(getContext());
130 | }
131 |
132 | //for debug info
133 | private String descPlaybackState(int state) {
134 | switch (state) {
135 | case ExoPlayer.STATE_BUFFERING:
136 | return "buffering";
137 | case ExoPlayer.STATE_PREPARING:
138 | return "preparing";
139 | case ExoPlayer.STATE_ENDED:
140 | return "ended";
141 | case ExoPlayer.STATE_IDLE:
142 | return "idle";
143 | case ExoPlayer.STATE_READY:
144 | return "ready";
145 | default:
146 | return "unknown";
147 | }
148 | }
149 |
150 | public void setUri(String uri) {
151 | this.uri = uri;
152 | updateProps(mediaPlayerController);
153 | }
154 |
155 | public void setLoop(boolean loop) {
156 | this.loop = loop;
157 | updateProps(mediaPlayerController);
158 | }
159 |
160 | public void setPreload(String preload) {
161 | this.preload = preload;
162 | updateProps(mediaPlayerController);
163 | }
164 |
165 | public void setAutoplay(boolean autoplay) {
166 | this.autoplay = autoplay;
167 | updateProps(mediaPlayerController);
168 | }
169 |
170 | public void setMuted(boolean muted) {
171 | this.muted = muted;
172 | updateProps(mediaPlayerController);
173 | }
174 |
175 | private void updateProps(MediaPlayerController playerController) {
176 | if (playerController != null) {
177 | playerController.setContentUri(uri);
178 | if (autoplay) {
179 | playerController.play();
180 | } else {
181 | if (preload != null && preload.equals("auto")) {
182 | playerController.prepareToPlay();
183 | }
184 | }
185 | playerController.setLoop(loop);
186 | playerController.setMuted(muted);
187 | }
188 | }
189 |
190 | @Override
191 | protected void onAttachedToWindow() {
192 | Log.d(TAG, "onAttachedToWindow...");
193 | super.onAttachedToWindow();
194 | if (getContext() instanceof ReactContext) {
195 | ((ReactContext) getContext()).addLifecycleEventListener(this);
196 | }
197 |
198 | if(autoplay || "auto".equals(preload)) {
199 | mediaPlayerControllerOwner.requestOwnership(getContext());
200 | }
201 | }
202 |
203 | @Override
204 | protected void onDetachedFromWindow() {
205 | Log.d(TAG, "onDetachedFromWindow...");
206 | super.onDetachedFromWindow();
207 | if (getContext() instanceof ReactContext) {
208 | ((ReactContext) getContext()).removeLifecycleEventListener(this);
209 | }
210 | mediaPlayerControllerOwner.abandonOwnership();
211 | }
212 |
213 | @Override
214 | public void onHostResume() {
215 | Log.d(TAG, "onHostResume...");
216 | if (playWhenReadySnapshot) {
217 | if(mediaPlayerController != null) {
218 | mediaPlayerController.play();
219 | }
220 | }
221 | }
222 |
223 | @Override
224 | public void onHostPause() {
225 | Log.d(TAG, "onHostPause...");
226 | if(mediaPlayerController != null) {
227 | playWhenReadySnapshot = mediaPlayerController.getPlayWhenReady();
228 | mediaPlayerController.pause();
229 | }
230 | }
231 |
232 | @Override
233 | public void onHostDestroy() {
234 | Log.d(TAG, "onHostDestroy...");
235 | mediaPlayerControllerOwner.abandonOwnership();
236 | }
237 |
238 | private void notifyProgress() {
239 | if (mediaPlayerController != null) {
240 | long current = mediaPlayerController.getCurrentPosition();
241 | long total = mediaPlayerController.getDuration();
242 | long buffered = mediaPlayerController.getBufferedPosition();
243 | if (mediaPlayerListener != null) {
244 | mediaPlayerListener.onPlayerProgress(current, total, buffered);
245 | }
246 | }
247 | }
248 |
249 | private Runnable onProgress = new Runnable() {
250 | @Override
251 | public void run() {
252 | notifyProgress();
253 | postDelayed(onProgress, 500);
254 | }
255 | };
256 |
257 | private void startProgressTimer() {
258 | post(onProgress);
259 | }
260 |
261 | private void stopProgressTimer() {
262 | removeCallbacks(onProgress);
263 | }
264 |
265 | public interface MediaPlayerListener {
266 |
267 | void onPlayerPlaying();
268 |
269 | void onPlayerPaused();
270 |
271 | void onPlayerFinished();
272 |
273 | void onPlayerBuffering();
274 |
275 | void onPlayerBufferReady();
276 |
277 | void onPlayerProgress(long current, long total, long buffered);
278 | }
279 |
280 | public void setMediaPlayerListener(MediaPlayerListener listener) {
281 | this.mediaPlayerListener = listener;
282 | }
283 |
284 | private static abstract class MediaPlayerControllerOwner {
285 | private static MediaPlayerController mediaPlayerController;
286 | private static MediaPlayerControllerOwner activeOwner;
287 |
288 | public MediaPlayerControllerOwner() {
289 | }
290 |
291 | public final void abandonOwnership() {
292 | if(activeOwner == this) {
293 | onOwnershipChanged(null, null);
294 | activeOwner = null;
295 | if(mediaPlayerController != null) {
296 | mediaPlayerController.release();
297 | mediaPlayerController = null;
298 | }
299 | }
300 | }
301 |
302 | public abstract void onOwnershipChanged(MediaPlayerControllerOwner owner, MediaPlayerController controller);
303 |
304 |
305 | public MediaPlayerController requestOwnership(Context context) {
306 | if (mediaPlayerController == null) {
307 | mediaPlayerController = new MediaPlayerController(context);
308 | }
309 |
310 | if (activeOwner != this) {
311 | if (activeOwner != null) {
312 | activeOwner.onOwnershipChanged(this, mediaPlayerController);
313 | }
314 | activeOwner = this;
315 | this.onOwnershipChanged(this, mediaPlayerController);
316 | }
317 |
318 | return mediaPlayerController;
319 | }
320 | }
321 | }
322 |
--------------------------------------------------------------------------------
/android/src/main/java/com/greatdroid/reactnative/media/player/ReactMediaPlayerViewManager.java:
--------------------------------------------------------------------------------
1 | package com.greatdroid.reactnative.media.player;
2 |
3 | import android.os.SystemClock;
4 | import android.support.annotation.Nullable;
5 | import android.util.Log;
6 |
7 | import com.facebook.react.bridge.ReadableArray;
8 | import com.facebook.react.bridge.WritableArray;
9 | import com.facebook.react.bridge.WritableMap;
10 | import com.facebook.react.bridge.WritableNativeArray;
11 | import com.facebook.react.bridge.WritableNativeMap;
12 | import com.facebook.react.common.MapBuilder;
13 | import com.facebook.react.uimanager.SimpleViewManager;
14 | import com.facebook.react.uimanager.ThemedReactContext;
15 | import com.facebook.react.uimanager.UIManagerModule;
16 | import com.facebook.react.uimanager.annotations.ReactProp;
17 | import com.facebook.react.uimanager.events.Event;
18 | import com.facebook.react.uimanager.events.RCTEventEmitter;
19 |
20 | import java.util.Map;
21 |
22 | public class ReactMediaPlayerViewManager extends SimpleViewManager {
23 | private static final String TAG = "MediaPlayerViewManager";
24 |
25 | public static final String REACT_CLASS = "RCTMediaPlayerView";
26 |
27 | public static final String EVENT_ON_PLAYER_PLAYING = "onPlayerPlaying";
28 | public static final String EVENT_ON_PLAYER_PAUSED = "onPlayerPaused";
29 | public static final String EVENT_ON_PLAYER_PROGRESS = "onPlayerProgress";
30 | public static final String EVENT_ON_PLAYER_BUFFER_CHANGE = "onPlayerBufferChange";
31 | public static final String EVENT_ON_PLAYER_BUFFERING = "onPlayerBuffering";
32 | public static final String EVENT_ON_PLAYER_BUFFER_OK = "onPlayerBufferOK";
33 | public static final String EVENT_ON_PLAYER_FINISHED = "onPlayerFinished";
34 |
35 | public static final int CMD_PLAY = 1;
36 | public static final int CMD_PAUSE = 2;
37 | public static final int CMD_SEEK_TO = 3;
38 | public static final int CMD_STOP = 4;
39 |
40 |
41 | @Override
42 | public String getName() {
43 | return REACT_CLASS;
44 | }
45 |
46 | @Override
47 | protected ReactMediaPlayerView createViewInstance(ThemedReactContext reactContext) {
48 | return new ReactMediaPlayerView(reactContext);
49 | }
50 |
51 | @ReactProp(name = "src")
52 | public void setSrc(ReactMediaPlayerView view, @Nullable String uri) {
53 | Log.d(TAG, "setSrc...src=" + uri);
54 | view.setUri(uri);
55 | }
56 |
57 | @ReactProp(name = "preload")
58 | public void setPreload(ReactMediaPlayerView view, @Nullable String preload) {
59 | Log.d(TAG, "setPreload...preload=" + preload);
60 | view.setPreload(preload);
61 | }
62 |
63 | @ReactProp(name = "autoplay", defaultBoolean = false)
64 | public void setAutoplay(ReactMediaPlayerView view, boolean autoplay) {
65 | Log.d(TAG, "setAutoplay...autoplay=" + autoplay);
66 | view.setAutoplay(autoplay);
67 | }
68 |
69 | @ReactProp(name = "loop", defaultBoolean = false)
70 | public void setLoop(ReactMediaPlayerView view, boolean loop) {
71 | Log.d(TAG, "setLoop...loop=" + loop);
72 | view.setLoop(loop);
73 | }
74 |
75 | @ReactProp(name = "muted", defaultBoolean = false)
76 | public void setMuted(ReactMediaPlayerView view, boolean muted) {
77 | Log.d(TAG, "setMuted...muted=" + muted);
78 | view.setMuted(muted);
79 |
80 | }
81 |
82 | ////////////////////////////////
83 |
84 | @Override
85 | protected void addEventEmitters(final ThemedReactContext reactContext, final ReactMediaPlayerView view) {
86 | super.addEventEmitters(reactContext, view);
87 |
88 | view.setMediaPlayerListener(new ReactMediaPlayerView.MediaPlayerListener() {
89 |
90 | private long buffered = -1;
91 |
92 | @Override
93 | public void onPlayerPlaying() {
94 | reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher()
95 | .dispatchEvent(new Event(view.getId(), SystemClock.uptimeMillis()) {
96 | @Override
97 | public String getEventName() {
98 | return EVENT_ON_PLAYER_PLAYING;
99 | }
100 |
101 | @Override
102 | public void dispatch(RCTEventEmitter rctEventEmitter) {
103 | rctEventEmitter.receiveEvent(getViewTag(), getEventName(), null);
104 | }
105 | });
106 | }
107 |
108 | @Override
109 | public void onPlayerPaused() {
110 | reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher()
111 | .dispatchEvent(new Event(view.getId(), SystemClock.uptimeMillis()) {
112 | @Override
113 | public String getEventName() {
114 | return EVENT_ON_PLAYER_PAUSED;
115 | }
116 |
117 | @Override
118 | public void dispatch(RCTEventEmitter rctEventEmitter) {
119 | rctEventEmitter.receiveEvent(getViewTag(), getEventName(), null);
120 | }
121 | });
122 | }
123 |
124 | @Override
125 | public void onPlayerFinished() {
126 | reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher()
127 | .dispatchEvent(new Event(view.getId(), SystemClock.uptimeMillis()) {
128 | @Override
129 | public String getEventName() {
130 | return EVENT_ON_PLAYER_FINISHED;
131 | }
132 |
133 | @Override
134 | public void dispatch(RCTEventEmitter rctEventEmitter) {
135 | rctEventEmitter.receiveEvent(getViewTag(), getEventName(), null);
136 | }
137 | });
138 | }
139 |
140 | @Override
141 | public void onPlayerBuffering() {
142 | reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher()
143 | .dispatchEvent(new Event(view.getId(), SystemClock.uptimeMillis()) {
144 | @Override
145 | public String getEventName() {
146 | return EVENT_ON_PLAYER_BUFFERING;
147 | }
148 |
149 | @Override
150 | public void dispatch(RCTEventEmitter rctEventEmitter) {
151 | rctEventEmitter.receiveEvent(getViewTag(), getEventName(), null);
152 | }
153 | });
154 | }
155 |
156 | @Override
157 | public void onPlayerBufferReady() {
158 | reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher()
159 | .dispatchEvent(new Event(view.getId(), SystemClock.uptimeMillis()) {
160 | @Override
161 | public String getEventName() {
162 | return EVENT_ON_PLAYER_BUFFER_OK;
163 | }
164 |
165 | @Override
166 | public void dispatch(RCTEventEmitter rctEventEmitter) {
167 | rctEventEmitter.receiveEvent(getViewTag(), getEventName(), null);
168 | }
169 | });
170 | }
171 |
172 | @Override
173 | public void onPlayerProgress(final long current, final long total, final long buffered) {
174 | reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher()
175 | .dispatchEvent(new Event(view.getId(), SystemClock.uptimeMillis()) {
176 | @Override
177 | public String getEventName() {
178 | return EVENT_ON_PLAYER_PROGRESS;
179 | }
180 |
181 | @Override
182 | public void dispatch(RCTEventEmitter rctEventEmitter) {
183 | WritableMap map = new WritableNativeMap();
184 | map.putInt("current", (int) current);
185 | map.putInt("total", (int) total);
186 | rctEventEmitter.receiveEvent(getViewTag(), getEventName(), map);
187 | }
188 | });
189 |
190 | if (buffered > 0 && this.buffered != buffered) {
191 | this.buffered = buffered;
192 | reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher()
193 | .dispatchEvent(new Event(view.getId(), SystemClock.uptimeMillis()) {
194 | @Override
195 | public String getEventName() {
196 | return EVENT_ON_PLAYER_BUFFER_CHANGE;
197 | }
198 |
199 | @Override
200 | public void dispatch(RCTEventEmitter rctEventEmitter) {
201 | WritableArray array = new WritableNativeArray();
202 | WritableMap map = new WritableNativeMap();
203 | map.putInt("start", 0);
204 | map.putInt("duration", (int) buffered);
205 | array.pushMap(map);
206 |
207 | map = new WritableNativeMap();
208 | map.putArray("ranges", array);
209 | rctEventEmitter.receiveEvent(getViewTag(), getEventName(), map);
210 | }
211 | });
212 | }
213 | }
214 | });
215 | }
216 |
217 | @javax.annotation.Nullable
218 | @Override
219 | public Map getExportedCustomDirectEventTypeConstants() {
220 | return MapBuilder.builder()
221 | .put(EVENT_ON_PLAYER_PLAYING, MapBuilder.of("registrationName", EVENT_ON_PLAYER_PLAYING))
222 | .put(EVENT_ON_PLAYER_PAUSED, MapBuilder.of("registrationName", EVENT_ON_PLAYER_PAUSED))
223 | .put(EVENT_ON_PLAYER_PROGRESS, MapBuilder.of("registrationName", EVENT_ON_PLAYER_PROGRESS))
224 | .put(EVENT_ON_PLAYER_BUFFERING, MapBuilder.of("registrationName", EVENT_ON_PLAYER_BUFFERING))
225 | .put(EVENT_ON_PLAYER_BUFFER_OK, MapBuilder.of("registrationName", EVENT_ON_PLAYER_BUFFER_OK))
226 | .put(EVENT_ON_PLAYER_BUFFER_CHANGE, MapBuilder.of("registrationName", EVENT_ON_PLAYER_BUFFER_CHANGE))
227 | .put(EVENT_ON_PLAYER_FINISHED, MapBuilder.of("registrationName", EVENT_ON_PLAYER_FINISHED))
228 | .build();
229 | }
230 |
231 | @Override
232 | public Map getCommandsMap() {
233 | return MapBuilder.of(
234 | "play", CMD_PLAY,
235 | "pause", CMD_PAUSE,
236 | "seekTo", CMD_SEEK_TO,
237 | "stop", CMD_STOP);
238 | }
239 |
240 | @Override
241 | public void receiveCommand(ReactMediaPlayerView root, int commandId, @Nullable ReadableArray args) {
242 | super.receiveCommand(root, commandId, args);
243 | switch (commandId) {
244 | case CMD_PLAY:
245 | root.getMediaPlayerController().play();
246 | break;
247 | case CMD_PAUSE:
248 | root.getMediaPlayerController().pause();
249 | break;
250 | case CMD_SEEK_TO:
251 | root.getMediaPlayerController().seekTo((long) args.getDouble(0));
252 | break;
253 | case CMD_STOP:
254 | root.getMediaPlayerController().stop();
255 | break;
256 | default:
257 | break;
258 | }
259 | }
260 | }
261 |
--------------------------------------------------------------------------------
/android/src/main/java/com/greatdroid/reactnative/media/player/TrackRenderersBuilder.java:
--------------------------------------------------------------------------------
1 | package com.greatdroid.reactnative.media.player;
2 |
3 | import com.google.android.exoplayer.TrackRenderer;
4 |
5 | public interface TrackRenderersBuilder {
6 |
7 | int TRACK_RENDER_COUNT = 4;
8 |
9 | int TRACK_VIDEO_INDEX = 0;
10 | int TRACK_AUDIO_INDEX = 1;
11 | int TRACK_TEXT_INDEX = 2;
12 | int TRACK_METADATA_INDEX = 3;
13 |
14 | void build(Callback callback);
15 |
16 | void cancel();
17 |
18 | interface Callback {
19 | void onFinish(TrackRenderer[] trackRenderers);
20 |
21 | void onError(Exception e);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/android/src/main/java/com/greatdroid/reactnative/media/player/trackrenderer/DashRenderersBuilder.java:
--------------------------------------------------------------------------------
1 | package com.greatdroid.reactnative.media.player.trackrenderer;
2 |
3 | import android.content.Context;
4 | import android.media.AudioManager;
5 | import android.media.MediaCodec;
6 | import android.os.Build;
7 | import android.os.Handler;
8 | import android.os.Looper;
9 | import android.util.Log;
10 |
11 | import com.google.android.exoplayer.DefaultLoadControl;
12 | import com.google.android.exoplayer.LoadControl;
13 | import com.google.android.exoplayer.MediaCodecAudioTrackRenderer;
14 | import com.google.android.exoplayer.MediaCodecSelector;
15 | import com.google.android.exoplayer.MediaCodecVideoTrackRenderer;
16 | import com.google.android.exoplayer.TrackRenderer;
17 | import com.google.android.exoplayer.audio.AudioCapabilities;
18 | import com.google.android.exoplayer.chunk.ChunkSampleSource;
19 | import com.google.android.exoplayer.chunk.ChunkSource;
20 | import com.google.android.exoplayer.chunk.FormatEvaluator;
21 | import com.google.android.exoplayer.dash.DashChunkSource;
22 | import com.google.android.exoplayer.dash.DefaultDashTrackSelector;
23 | import com.google.android.exoplayer.dash.mpd.AdaptationSet;
24 | import com.google.android.exoplayer.dash.mpd.MediaPresentationDescription;
25 | import com.google.android.exoplayer.dash.mpd.MediaPresentationDescriptionParser;
26 | import com.google.android.exoplayer.dash.mpd.Period;
27 | import com.google.android.exoplayer.dash.mpd.UtcTimingElement;
28 | import com.google.android.exoplayer.dash.mpd.UtcTimingElementResolver;
29 | import com.google.android.exoplayer.drm.MediaDrmCallback;
30 | import com.google.android.exoplayer.drm.StreamingDrmSessionManager;
31 | import com.google.android.exoplayer.drm.UnsupportedDrmException;
32 | import com.google.android.exoplayer.text.TextRenderer;
33 | import com.google.android.exoplayer.text.TextTrackRenderer;
34 | import com.google.android.exoplayer.upstream.BandwidthMeter;
35 | import com.google.android.exoplayer.upstream.DataSource;
36 | import com.google.android.exoplayer.upstream.DefaultAllocator;
37 | import com.google.android.exoplayer.upstream.DefaultBandwidthMeter;
38 | import com.google.android.exoplayer.upstream.DefaultUriDataSource;
39 | import com.google.android.exoplayer.upstream.UriDataSource;
40 | import com.google.android.exoplayer.util.ManifestFetcher;
41 | import com.greatdroid.reactnative.media.player.TrackRenderersBuilder;
42 |
43 | import java.io.IOException;
44 |
45 | public class DashRenderersBuilder implements TrackRenderersBuilder, UtcTimingElementResolver.UtcTimingCallback, ManifestFetcher.ManifestCallback {
46 | private static final String TAG = "DashRenderersBuilder";
47 |
48 | private static final int BUFFER_SEGMENT_SIZE = 64 * 1024;
49 | private static final int VIDEO_BUFFER_SEGMENTS = 200;
50 | private static final int AUDIO_BUFFER_SEGMENTS = 54;
51 | private static final int TEXT_BUFFER_SEGMENTS = 2;
52 | private static final int LIVE_EDGE_LATENCY_MS = 30000;
53 |
54 | private static final int SECURITY_LEVEL_UNKNOWN = -1;
55 | private static final int SECURITY_LEVEL_1 = 1;
56 | private static final int SECURITY_LEVEL_3 = 3;
57 |
58 | private final Context context;
59 | private final String userAgent;
60 | private final String url;
61 | private final Handler eventHandler;
62 | private final MediaDrmCallback drmCallback;
63 | private final MediaCodecVideoTrackRenderer.EventListener videoTrackListener;
64 | private final MediaCodecAudioTrackRenderer.EventListener audioTrackListener;
65 | private final TextRenderer textRenderer;
66 | private final BandwidthMeter.EventListener bandwidthMeterListener;
67 | private final Looper playbackLooper;
68 |
69 | private volatile boolean cancelled = false;
70 |
71 | private Callback callback;
72 | private UriDataSource uriDataSource;
73 | ManifestFetcher manifestFetcher;
74 | private MediaPresentationDescription mpd;
75 | private long elapsedRealtimeOffset;
76 |
77 | public DashRenderersBuilder(Context context, String userAgent, String url, Handler eventHandler, MediaDrmCallback drmCallback, MediaCodecVideoTrackRenderer.EventListener videoTrackListener, MediaCodecAudioTrackRenderer.EventListener audioTrackListener, TextRenderer textRenderer, BandwidthMeter.EventListener bandwidthMeterListener, Looper playbackLooper) {
78 | this.context = context;
79 | this.userAgent = userAgent;
80 | this.url = url;
81 | this.eventHandler = eventHandler;
82 | this.drmCallback = drmCallback;
83 | this.videoTrackListener = videoTrackListener;
84 | this.audioTrackListener = audioTrackListener;
85 | this.textRenderer = textRenderer;
86 | this.bandwidthMeterListener = bandwidthMeterListener;
87 | this.playbackLooper = playbackLooper;
88 | }
89 |
90 |
91 | @Override
92 | public void build(Callback callback) {
93 | this.callback = callback;
94 | this.uriDataSource = new DefaultUriDataSource(context, userAgent);
95 | this.manifestFetcher = new ManifestFetcher<>(url, uriDataSource, new MediaPresentationDescriptionParser());
96 | this.manifestFetcher.singleLoad(eventHandler.getLooper(), this);
97 | }
98 |
99 | @Override
100 | public void cancel() {
101 | cancelled = true;
102 | }
103 |
104 |
105 | @Override
106 | public void onTimestampResolved(UtcTimingElement utcTiming, long elapsedRealtimeOffset) {
107 | if (cancelled) {
108 | return;
109 | }
110 | this.elapsedRealtimeOffset = elapsedRealtimeOffset;
111 | build();
112 | }
113 |
114 | @Override
115 | public void onTimestampError(UtcTimingElement utcTiming, IOException e) {
116 | if (cancelled) {
117 | return;
118 | }
119 | Log.e(TAG, "onTimestampError...failed to resolve UtcTiming", e);
120 |
121 | // Be optimistic and continue in the hope that the device clock is correct.
122 | build();
123 | }
124 |
125 |
126 | @Override
127 | public void onSingleManifest(MediaPresentationDescription manifest) {
128 | if (cancelled) {
129 | return;
130 | }
131 | mpd = manifest;
132 | if (mpd.dynamic && mpd.utcTiming != null) {
133 | UtcTimingElementResolver.resolveTimingElement(uriDataSource, mpd.utcTiming, manifestFetcher.getManifestLoadCompleteTimestamp(), this);
134 | } else {
135 | build();
136 | }
137 | }
138 |
139 | @Override
140 | public void onSingleManifestError(final IOException e) {
141 | if (cancelled) {
142 | return;
143 | }
144 | eventHandler.post(new Runnable() {
145 | @Override
146 | public void run() {
147 | callback.onError(e);
148 | }
149 | });
150 | }
151 |
152 | private void build() {
153 | Period period = mpd.getPeriod(0);
154 | LoadControl loadControl = new DefaultLoadControl(new DefaultAllocator(BUFFER_SEGMENT_SIZE));
155 | DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(eventHandler, bandwidthMeterListener);
156 |
157 | boolean hasContentProtection = false;
158 | for (int i = 0; i < period.adaptationSets.size(); i++) {
159 | AdaptationSet adaptationSet = period.adaptationSets.get(i);
160 | if (adaptationSet.type != AdaptationSet.TYPE_UNKNOWN) {
161 | hasContentProtection |= adaptationSet.hasContentProtection();
162 | }
163 | }
164 |
165 | // Check drm support if necessary.
166 | boolean filterHdContent = false;
167 | StreamingDrmSessionManager drmSessionManager = null;
168 | if (hasContentProtection) {
169 | if (Build.VERSION.SDK_INT < 18) {
170 | callback.onError(new UnsupportedDrmException(UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME));
171 | return;
172 | }
173 | try {
174 | drmSessionManager = StreamingDrmSessionManager.newWidevineInstance(playbackLooper, drmCallback, null, eventHandler, new StreamingDrmSessionManager.EventListener() {
175 | @Override
176 | public void onDrmKeysLoaded() {
177 |
178 | }
179 |
180 | @Override
181 | public void onDrmSessionManagerError(Exception e) {
182 | if (cancelled) {
183 | return;
184 | }
185 | callback.onError(e);
186 | }
187 | });
188 | filterHdContent = getWidevineSecurityLevel(drmSessionManager) != SECURITY_LEVEL_1;
189 | } catch (final UnsupportedDrmException e) {
190 | if (!cancelled) {
191 | callback.onError(e);
192 | }
193 | return;
194 | }
195 | }
196 |
197 | // Build the video renderer.
198 | DataSource videoDataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
199 | ChunkSource videoChunkSource = new DashChunkSource(manifestFetcher,
200 | DefaultDashTrackSelector.newVideoInstance(context, true, filterHdContent),
201 | videoDataSource, new FormatEvaluator.AdaptiveEvaluator(bandwidthMeter), LIVE_EDGE_LATENCY_MS,
202 | elapsedRealtimeOffset, eventHandler, null, TRACK_VIDEO_INDEX);
203 | ChunkSampleSource videoSampleSource = new ChunkSampleSource(videoChunkSource, loadControl,
204 | VIDEO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, eventHandler, null,
205 | TRACK_VIDEO_INDEX);
206 | TrackRenderer videoTrackRenderer = new MediaCodecVideoTrackRenderer(context, videoSampleSource,
207 | MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000,
208 | drmSessionManager, true, eventHandler, videoTrackListener, 50);
209 |
210 | // Build the audio renderer.
211 | DataSource audioDataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
212 | ChunkSource audioChunkSource = new DashChunkSource(manifestFetcher,
213 | DefaultDashTrackSelector.newAudioInstance(), audioDataSource, null, LIVE_EDGE_LATENCY_MS,
214 | elapsedRealtimeOffset, eventHandler, null, TRACK_AUDIO_INDEX);
215 | ChunkSampleSource audioSampleSource = new ChunkSampleSource(audioChunkSource, loadControl,
216 | AUDIO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, eventHandler, null,
217 | TRACK_AUDIO_INDEX);
218 | TrackRenderer audioTrackRenderer = new MediaCodecAudioTrackRenderer(audioSampleSource,
219 | MediaCodecSelector.DEFAULT, drmSessionManager, true, eventHandler, audioTrackListener,
220 | AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);
221 |
222 | // Build the text renderer.
223 | DataSource textDataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
224 | ChunkSource textChunkSource = new DashChunkSource(manifestFetcher,
225 | DefaultDashTrackSelector.newTextInstance(), textDataSource, null, LIVE_EDGE_LATENCY_MS,
226 | elapsedRealtimeOffset, eventHandler, null, TRACK_TEXT_INDEX);
227 | ChunkSampleSource textSampleSource = new ChunkSampleSource(textChunkSource, loadControl,
228 | TEXT_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, eventHandler, null,
229 | TRACK_TEXT_INDEX);
230 | TrackRenderer textTrackRenderer = new TextTrackRenderer(textSampleSource, textRenderer,
231 | eventHandler.getLooper());
232 |
233 | final TrackRenderer[] trackRenderers = new TrackRenderer[TRACK_RENDER_COUNT];
234 | trackRenderers[TRACK_VIDEO_INDEX] = videoTrackRenderer;
235 | trackRenderers[TRACK_AUDIO_INDEX] = audioTrackRenderer;
236 | trackRenderers[TRACK_TEXT_INDEX] = textTrackRenderer;
237 | eventHandler.post(new Runnable() {
238 | @Override
239 | public void run() {
240 | callback.onFinish(trackRenderers);
241 | }
242 | });
243 | }
244 |
245 | private static int getWidevineSecurityLevel(StreamingDrmSessionManager sessionManager) {
246 | String securityLevelProperty = sessionManager.getPropertyString("securityLevel");
247 | return securityLevelProperty.equals("L1") ? SECURITY_LEVEL_1 : securityLevelProperty
248 | .equals("L3") ? SECURITY_LEVEL_3 : SECURITY_LEVEL_UNKNOWN;
249 | }
250 | }
251 |
--------------------------------------------------------------------------------
/android/src/main/java/com/greatdroid/reactnative/media/player/trackrenderer/ExtractorRenderersBuilder.java:
--------------------------------------------------------------------------------
1 | package com.greatdroid.reactnative.media.player.trackrenderer;
2 |
3 | import android.content.Context;
4 | import android.media.AudioManager;
5 | import android.media.MediaCodec;
6 | import android.net.Uri;
7 | import android.os.Handler;
8 |
9 | import com.google.android.exoplayer.MediaCodecAudioTrackRenderer;
10 | import com.google.android.exoplayer.MediaCodecSelector;
11 | import com.google.android.exoplayer.MediaCodecVideoTrackRenderer;
12 | import com.google.android.exoplayer.TrackRenderer;
13 | import com.google.android.exoplayer.audio.AudioCapabilities;
14 | import com.google.android.exoplayer.extractor.ExtractorSampleSource;
15 | import com.google.android.exoplayer.text.TextRenderer;
16 | import com.google.android.exoplayer.text.TextTrackRenderer;
17 | import com.google.android.exoplayer.upstream.Allocator;
18 | import com.google.android.exoplayer.upstream.BandwidthMeter;
19 | import com.google.android.exoplayer.upstream.DataSource;
20 | import com.google.android.exoplayer.upstream.DefaultAllocator;
21 | import com.google.android.exoplayer.upstream.DefaultBandwidthMeter;
22 | import com.google.android.exoplayer.upstream.DefaultUriDataSource;
23 | import com.greatdroid.reactnative.media.player.TrackRenderersBuilder;
24 |
25 | public class ExtractorRenderersBuilder implements TrackRenderersBuilder {
26 |
27 | private static final int BUFFER_SEGMENT_SIZE = 64 * 1024;
28 | private static final int BUFFER_SEGMENT_COUNT = 256;
29 |
30 | private final Context context;
31 | private final String userAgent;
32 | private final Uri uri;
33 | private final Handler eventHandler;
34 | private final MediaCodecVideoTrackRenderer.EventListener videoTrackListener;
35 | private final MediaCodecAudioTrackRenderer.EventListener audioTrackListener;
36 | private final TextRenderer textRenderer;
37 | private final BandwidthMeter.EventListener bandwidthMeterListener;
38 |
39 | public ExtractorRenderersBuilder(Context context, String userAgent, Uri uri, Handler eventHandler, MediaCodecVideoTrackRenderer.EventListener videoTrackListener, MediaCodecAudioTrackRenderer.EventListener audioTrackListener, TextRenderer textRenderer, BandwidthMeter.EventListener bandwidthMeterListener) {
40 | this.context = context;
41 | this.userAgent = userAgent;
42 | this.uri = uri;
43 | this.eventHandler = eventHandler;
44 | this.videoTrackListener = videoTrackListener;
45 | this.audioTrackListener = audioTrackListener;
46 | this.textRenderer = textRenderer;
47 | this.bandwidthMeterListener = bandwidthMeterListener;
48 | }
49 |
50 | @Override
51 | public void build(final Callback callback) {
52 | Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
53 | DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(eventHandler, bandwidthMeterListener);
54 | DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
55 | ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator,
56 | BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);
57 |
58 | MediaCodecVideoTrackRenderer videoTrackRenderer = new MediaCodecVideoTrackRenderer(context,
59 | sampleSource, MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000,
60 | eventHandler, videoTrackListener, 50);
61 | MediaCodecAudioTrackRenderer audioTrackRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
62 | MediaCodecSelector.DEFAULT, null, true, eventHandler, audioTrackListener,
63 | AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);
64 | TextTrackRenderer textTrackRenderer = new TextTrackRenderer(sampleSource, textRenderer,
65 | eventHandler.getLooper());
66 |
67 | final TrackRenderer[] trackRenderers = new TrackRenderer[TRACK_RENDER_COUNT];
68 | trackRenderers[TRACK_VIDEO_INDEX] = videoTrackRenderer;
69 | trackRenderers[TRACK_AUDIO_INDEX] = audioTrackRenderer;
70 | trackRenderers[TRACK_TEXT_INDEX] = textTrackRenderer;
71 | eventHandler.post(new Runnable() {
72 | @Override
73 | public void run() {
74 | callback.onFinish(trackRenderers);
75 | }
76 | });
77 | }
78 |
79 | @Override
80 | public void cancel() {
81 | //do nothing
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/android/src/main/java/com/greatdroid/reactnative/media/player/trackrenderer/HlsRenderersBuilder.java:
--------------------------------------------------------------------------------
1 | package com.greatdroid.reactnative.media.player.trackrenderer;
2 |
3 | import android.content.Context;
4 | import android.media.AudioManager;
5 | import android.media.MediaCodec;
6 | import android.os.Handler;
7 |
8 | import com.google.android.exoplayer.DefaultLoadControl;
9 | import com.google.android.exoplayer.LoadControl;
10 | import com.google.android.exoplayer.MediaCodecAudioTrackRenderer;
11 | import com.google.android.exoplayer.MediaCodecSelector;
12 | import com.google.android.exoplayer.MediaCodecVideoTrackRenderer;
13 | import com.google.android.exoplayer.TrackRenderer;
14 | import com.google.android.exoplayer.audio.AudioCapabilities;
15 | import com.google.android.exoplayer.hls.DefaultHlsTrackSelector;
16 | import com.google.android.exoplayer.hls.HlsChunkSource;
17 | import com.google.android.exoplayer.hls.HlsMasterPlaylist;
18 | import com.google.android.exoplayer.hls.HlsPlaylist;
19 | import com.google.android.exoplayer.hls.HlsPlaylistParser;
20 | import com.google.android.exoplayer.hls.HlsSampleSource;
21 | import com.google.android.exoplayer.hls.PtsTimestampAdjusterProvider;
22 | import com.google.android.exoplayer.metadata.MetadataTrackRenderer;
23 | import com.google.android.exoplayer.metadata.id3.Id3Frame;
24 | import com.google.android.exoplayer.metadata.id3.Id3Parser;
25 | import com.google.android.exoplayer.text.TextRenderer;
26 | import com.google.android.exoplayer.text.TextTrackRenderer;
27 | import com.google.android.exoplayer.text.eia608.Eia608TrackRenderer;
28 | import com.google.android.exoplayer.upstream.BandwidthMeter;
29 | import com.google.android.exoplayer.upstream.DataSource;
30 | import com.google.android.exoplayer.upstream.DefaultAllocator;
31 | import com.google.android.exoplayer.upstream.DefaultBandwidthMeter;
32 | import com.google.android.exoplayer.upstream.DefaultUriDataSource;
33 | import com.google.android.exoplayer.util.ManifestFetcher;
34 | import com.greatdroid.reactnative.media.player.TrackRenderersBuilder;
35 |
36 | import java.io.IOException;
37 | import java.util.List;
38 |
39 | public class HlsRenderersBuilder implements TrackRenderersBuilder, ManifestFetcher.ManifestCallback {
40 |
41 | private static final int BUFFER_SEGMENT_SIZE = 64 * 1024;
42 | private static final int MAIN_BUFFER_SEGMENTS = 256;
43 | private static final int TEXT_BUFFER_SEGMENTS = 2;
44 |
45 | private final Context context;
46 | private final String userAgent;
47 | private final String url;
48 | private final Handler eventHandler;
49 | private final MediaCodecVideoTrackRenderer.EventListener videoTrackListener;
50 | private final MediaCodecAudioTrackRenderer.EventListener audioTrackListener;
51 | private final TextRenderer textRenderer;
52 | private final MetadataTrackRenderer.MetadataRenderer> metadataRenderer;
53 | private final BandwidthMeter.EventListener bandwidthMeterListener;
54 |
55 | private Callback callback;
56 | private ManifestFetcher manifestFetcher;
57 |
58 | private volatile boolean cancelled = false;
59 |
60 | public HlsRenderersBuilder(Context context, String userAgent, String url, Handler eventHandler, MediaCodecVideoTrackRenderer.EventListener videoTrackListener, MediaCodecAudioTrackRenderer.EventListener audioTrackListener, TextRenderer textRenderer, MetadataTrackRenderer.MetadataRenderer> metadataRenderer, BandwidthMeter.EventListener bandwidthMeterListener) {
61 | this.context = context;
62 | this.userAgent = userAgent;
63 | this.url = url;
64 | this.eventHandler = eventHandler;
65 | this.videoTrackListener = videoTrackListener;
66 | this.audioTrackListener = audioTrackListener;
67 | this.textRenderer = textRenderer;
68 | this.metadataRenderer = metadataRenderer;
69 | this.bandwidthMeterListener = bandwidthMeterListener;
70 | }
71 |
72 | @Override
73 | public void build(Callback callback) {
74 | this.callback = callback;
75 | HlsPlaylistParser hlsPlaylistParser = new HlsPlaylistParser();
76 | manifestFetcher = new ManifestFetcher(url, new DefaultUriDataSource(context, userAgent), hlsPlaylistParser);
77 | manifestFetcher.singleLoad(eventHandler.getLooper(), this);
78 | }
79 |
80 | @Override
81 | public void cancel() {
82 | cancelled = true;
83 | }
84 |
85 | @Override
86 | public void onSingleManifest(HlsPlaylist manifest) {
87 | if(cancelled) {
88 | return;
89 | }
90 |
91 | LoadControl loadControl = new DefaultLoadControl(new DefaultAllocator(BUFFER_SEGMENT_SIZE));
92 | DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
93 | PtsTimestampAdjusterProvider timestampAdjusterProvider = new PtsTimestampAdjusterProvider();
94 |
95 | DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
96 | HlsChunkSource chunkSource = new HlsChunkSource(true, dataSource, url,
97 | manifest, DefaultHlsTrackSelector.newDefaultInstance(context), bandwidthMeter,
98 | timestampAdjusterProvider, HlsChunkSource.ADAPTIVE_MODE_SPLICE);
99 | HlsSampleSource sampleSource = new HlsSampleSource(chunkSource, loadControl,
100 | MAIN_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, eventHandler, null, TRACK_VIDEO_INDEX);
101 |
102 | MediaCodecVideoTrackRenderer videoTrackRenderer = new MediaCodecVideoTrackRenderer(context,
103 | sampleSource, MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT,
104 | 5000, eventHandler, videoTrackListener, 50);
105 |
106 | MediaCodecAudioTrackRenderer audioTrackRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
107 | MediaCodecSelector.DEFAULT, null, true, eventHandler, audioTrackListener,
108 | AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);
109 |
110 | MetadataTrackRenderer> metadataTrackRenderer = new MetadataTrackRenderer<>(
111 | sampleSource, new Id3Parser(), metadataRenderer, eventHandler.getLooper());
112 |
113 | // Build the text renderer, preferring Webvtt where available.
114 | boolean preferWebvtt = false;
115 | if (manifest instanceof HlsMasterPlaylist) {
116 | preferWebvtt = !((HlsMasterPlaylist) manifest).subtitles.isEmpty();
117 | }
118 | TrackRenderer textTrackRenderer;
119 | if (preferWebvtt) {
120 | DataSource textDataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
121 | HlsChunkSource textChunkSource = new HlsChunkSource(false, textDataSource,
122 | url, manifest, DefaultHlsTrackSelector.newVttInstance(), bandwidthMeter,
123 | timestampAdjusterProvider, HlsChunkSource.ADAPTIVE_MODE_SPLICE);
124 | HlsSampleSource textSampleSource = new HlsSampleSource(textChunkSource, loadControl,
125 | TEXT_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, eventHandler, null, TRACK_TEXT_INDEX);
126 | textTrackRenderer = new TextTrackRenderer(textSampleSource, textRenderer, eventHandler.getLooper());
127 | } else {
128 | textTrackRenderer = new Eia608TrackRenderer(sampleSource, textRenderer, eventHandler.getLooper());
129 | }
130 |
131 | final TrackRenderer[] trackRenderers = new TrackRenderer[TRACK_RENDER_COUNT];
132 | trackRenderers[TRACK_VIDEO_INDEX] = videoTrackRenderer;
133 | trackRenderers[TRACK_AUDIO_INDEX] = audioTrackRenderer;
134 | trackRenderers[TRACK_TEXT_INDEX] = textTrackRenderer;
135 | trackRenderers[TRACK_METADATA_INDEX] = metadataTrackRenderer;
136 | eventHandler.post(new Runnable() {
137 | @Override
138 | public void run() {
139 | callback.onFinish(trackRenderers);
140 | }
141 | });
142 | }
143 |
144 | @Override
145 | public void onSingleManifestError(final IOException e) {
146 | if(cancelled) {
147 | return;
148 | }
149 | eventHandler.post(new Runnable() {
150 | @Override
151 | public void run() {
152 | callback.onError(e);
153 | }
154 | });
155 | }
156 | }
157 |
--------------------------------------------------------------------------------
/android/src/main/java/com/greatdroid/reactnative/media/player/trackrenderer/SmoothStreamingRenderersBuilder.java:
--------------------------------------------------------------------------------
1 | package com.greatdroid.reactnative.media.player.trackrenderer;
2 |
3 | import android.content.Context;
4 | import android.media.AudioManager;
5 | import android.media.MediaCodec;
6 | import android.os.Handler;
7 | import android.os.Looper;
8 |
9 | import com.google.android.exoplayer.DefaultLoadControl;
10 | import com.google.android.exoplayer.LoadControl;
11 | import com.google.android.exoplayer.MediaCodecAudioTrackRenderer;
12 | import com.google.android.exoplayer.MediaCodecSelector;
13 | import com.google.android.exoplayer.MediaCodecVideoTrackRenderer;
14 | import com.google.android.exoplayer.TrackRenderer;
15 | import com.google.android.exoplayer.audio.AudioCapabilities;
16 | import com.google.android.exoplayer.chunk.ChunkSampleSource;
17 | import com.google.android.exoplayer.chunk.ChunkSource;
18 | import com.google.android.exoplayer.chunk.FormatEvaluator;
19 | import com.google.android.exoplayer.drm.DrmSessionManager;
20 | import com.google.android.exoplayer.drm.MediaDrmCallback;
21 | import com.google.android.exoplayer.drm.StreamingDrmSessionManager;
22 | import com.google.android.exoplayer.drm.UnsupportedDrmException;
23 | import com.google.android.exoplayer.smoothstreaming.DefaultSmoothStreamingTrackSelector;
24 | import com.google.android.exoplayer.smoothstreaming.SmoothStreamingChunkSource;
25 | import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest;
26 | import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifestParser;
27 | import com.google.android.exoplayer.text.TextRenderer;
28 | import com.google.android.exoplayer.text.TextTrackRenderer;
29 | import com.google.android.exoplayer.upstream.BandwidthMeter;
30 | import com.google.android.exoplayer.upstream.DataSource;
31 | import com.google.android.exoplayer.upstream.DefaultAllocator;
32 | import com.google.android.exoplayer.upstream.DefaultBandwidthMeter;
33 | import com.google.android.exoplayer.upstream.DefaultHttpDataSource;
34 | import com.google.android.exoplayer.upstream.DefaultUriDataSource;
35 | import com.google.android.exoplayer.util.ManifestFetcher;
36 | import com.google.android.exoplayer.util.Util;
37 | import com.greatdroid.reactnative.media.player.TrackRenderersBuilder;
38 |
39 | import java.io.IOException;
40 |
41 | public class SmoothStreamingRenderersBuilder implements TrackRenderersBuilder, ManifestFetcher.ManifestCallback {
42 |
43 | private static final int BUFFER_SEGMENT_SIZE = 64 * 1024;
44 | private static final int VIDEO_BUFFER_SEGMENTS = 200;
45 | private static final int AUDIO_BUFFER_SEGMENTS = 54;
46 | private static final int TEXT_BUFFER_SEGMENTS = 2;
47 | private static final int LIVE_EDGE_LATENCY_MS = 30000;
48 |
49 | private final Context context;
50 | private final String userAgent;
51 | private final String url;
52 | private final Handler eventHandler;
53 | private final MediaDrmCallback drmCallback;
54 | private final MediaCodecVideoTrackRenderer.EventListener videoTrackListener;
55 | private final MediaCodecAudioTrackRenderer.EventListener audioTrackListener;
56 | private final TextRenderer textRenderer;
57 | private final BandwidthMeter.EventListener bandwidthMeterListener;
58 | private final Looper playbackLooper;
59 |
60 | private Callback callback;
61 | private ManifestFetcher manifestFetcher;
62 |
63 | private volatile boolean cancelled = false;
64 |
65 | public SmoothStreamingRenderersBuilder(Context context, String userAgent, String url, Handler eventHandler, MediaDrmCallback drmCallback, MediaCodecVideoTrackRenderer.EventListener videoTrackListener, MediaCodecAudioTrackRenderer.EventListener audioTrackListener, TextRenderer textRenderer, BandwidthMeter.EventListener bandwidthMeterListener, Looper playbackLooper) {
66 | this.context = context;
67 | this.userAgent = userAgent;
68 | this.eventHandler = eventHandler;
69 | this.videoTrackListener = videoTrackListener;
70 | this.audioTrackListener = audioTrackListener;
71 | this.textRenderer = textRenderer;
72 | this.bandwidthMeterListener = bandwidthMeterListener;
73 | this.playbackLooper = playbackLooper;
74 | this.manifestFetcher = manifestFetcher;
75 | this.url = Util.toLowerInvariant(url).endsWith("/manifest") ? url : url + "/Manifest";
76 | this.drmCallback = drmCallback;
77 | }
78 |
79 | @Override
80 | public void build(Callback callback) {
81 | this.callback = callback;
82 | SmoothStreamingManifestParser parser = new SmoothStreamingManifestParser();
83 | manifestFetcher = new ManifestFetcher<>(url, new DefaultHttpDataSource(userAgent, null),
84 | parser);
85 | manifestFetcher.singleLoad(eventHandler.getLooper(), this);
86 | }
87 |
88 | @Override
89 | public void cancel() {
90 | cancelled = true;
91 | }
92 |
93 | @Override
94 | public void onSingleManifest(SmoothStreamingManifest manifest) {
95 | if (cancelled) {
96 | return;
97 | }
98 |
99 | LoadControl loadControl = new DefaultLoadControl(new DefaultAllocator(BUFFER_SEGMENT_SIZE));
100 | DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(eventHandler, bandwidthMeterListener);
101 |
102 | // Check drm support if necessary.
103 | DrmSessionManager drmSessionManager = null;
104 | if (manifest.protectionElement != null) {
105 | if (Util.SDK_INT < 18) {
106 | callback.onError(new UnsupportedDrmException(UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME));
107 | return;
108 | }
109 | try {
110 | drmSessionManager = new StreamingDrmSessionManager(manifest.protectionElement.uuid,
111 | playbackLooper, drmCallback, null, eventHandler, new StreamingDrmSessionManager.EventListener() {
112 | @Override
113 | public void onDrmKeysLoaded() {
114 | }
115 |
116 | @Override
117 | public void onDrmSessionManagerError(final Exception e) {
118 | if (cancelled) {
119 | return;
120 | }
121 | callback.onError(e);
122 | }
123 | });
124 | } catch (UnsupportedDrmException e) {
125 | if (!cancelled) {
126 | callback.onError(e);
127 | }
128 | return;
129 | }
130 | }
131 |
132 | // Build the video renderer.
133 | DataSource videoDataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
134 | ChunkSource videoChunkSource = new SmoothStreamingChunkSource(manifestFetcher,
135 | DefaultSmoothStreamingTrackSelector.newVideoInstance(context, true, false),
136 | videoDataSource, new FormatEvaluator.AdaptiveEvaluator(bandwidthMeter), LIVE_EDGE_LATENCY_MS);
137 | ChunkSampleSource videoSampleSource = new ChunkSampleSource(videoChunkSource, loadControl,
138 | VIDEO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, eventHandler, null,
139 | TRACK_VIDEO_INDEX);
140 | TrackRenderer videoTrackRenderer = new MediaCodecVideoTrackRenderer(context, videoSampleSource,
141 | MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000,
142 | drmSessionManager, true, eventHandler, videoTrackListener, 50);
143 |
144 | // Build the audio renderer.
145 | DataSource audioDataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
146 | ChunkSource audioChunkSource = new SmoothStreamingChunkSource(manifestFetcher,
147 | DefaultSmoothStreamingTrackSelector.newAudioInstance(),
148 | audioDataSource, null, LIVE_EDGE_LATENCY_MS);
149 | ChunkSampleSource audioSampleSource = new ChunkSampleSource(audioChunkSource, loadControl,
150 | AUDIO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, eventHandler, null,
151 | TRACK_AUDIO_INDEX);
152 | TrackRenderer audioTrackRenderer = new MediaCodecAudioTrackRenderer(audioSampleSource,
153 | MediaCodecSelector.DEFAULT, drmSessionManager, true, eventHandler, audioTrackListener,
154 | AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);
155 |
156 | // Build the text renderer.
157 | DataSource textDataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
158 | ChunkSource textChunkSource = new SmoothStreamingChunkSource(manifestFetcher,
159 | DefaultSmoothStreamingTrackSelector.newTextInstance(),
160 | textDataSource, null, LIVE_EDGE_LATENCY_MS);
161 | ChunkSampleSource textSampleSource = new ChunkSampleSource(textChunkSource, loadControl,
162 | TEXT_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, eventHandler, null,
163 | TRACK_TEXT_INDEX);
164 | TrackRenderer textTrackRenderer = new TextTrackRenderer(textSampleSource, textRenderer,
165 | eventHandler.getLooper());
166 |
167 | final TrackRenderer[] trackRenderers = new TrackRenderer[TRACK_RENDER_COUNT];
168 | trackRenderers[TRACK_VIDEO_INDEX] = videoTrackRenderer;
169 | trackRenderers[TRACK_AUDIO_INDEX] = audioTrackRenderer;
170 | trackRenderers[TRACK_TEXT_INDEX] = textTrackRenderer;
171 | eventHandler.post(new Runnable() {
172 | @Override
173 | public void run() {
174 | callback.onFinish(trackRenderers);
175 | }
176 | });
177 | }
178 |
179 | @Override
180 | public void onSingleManifestError(final IOException e) {
181 | if (cancelled) {
182 | return;
183 | }
184 |
185 | eventHandler.post(new Runnable() {
186 | @Override
187 | public void run() {
188 | callback.onError(e);
189 | }
190 | });
191 | }
192 | }
193 |
--------------------------------------------------------------------------------
/android/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | react-native-media-kit
3 |
4 |
--------------------------------------------------------------------------------
/android/src/test/java/com/yoai/reactnative/media/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.yoai.reactnative.media;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/ios/react-native-media-kit.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 5FDB0B7A1CBB7B1900EDD727 /* RCTMediaPlayerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FDB0B771CBB7B1900EDD727 /* RCTMediaPlayerManager.m */; };
11 | 5FDB0B7B1CBB7B1900EDD727 /* RCTMediaPlayerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FDB0B791CBB7B1900EDD727 /* RCTMediaPlayerView.m */; };
12 | /* End PBXBuildFile section */
13 |
14 | /* Begin PBXCopyFilesBuildPhase section */
15 | 5FDB0B681CBB7ACA00EDD727 /* CopyFiles */ = {
16 | isa = PBXCopyFilesBuildPhase;
17 | buildActionMask = 2147483647;
18 | dstPath = "include/$(PRODUCT_NAME)";
19 | dstSubfolderSpec = 16;
20 | files = (
21 | );
22 | runOnlyForDeploymentPostprocessing = 0;
23 | };
24 | /* End PBXCopyFilesBuildPhase section */
25 |
26 | /* Begin PBXFileReference section */
27 | 5FDB0B6A1CBB7ACA00EDD727 /* libreact-native-media-kit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libreact-native-media-kit.a"; sourceTree = BUILT_PRODUCTS_DIR; };
28 | 5FDB0B761CBB7B1900EDD727 /* RCTMediaPlayerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTMediaPlayerManager.h; sourceTree = ""; };
29 | 5FDB0B771CBB7B1900EDD727 /* RCTMediaPlayerManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTMediaPlayerManager.m; sourceTree = ""; };
30 | 5FDB0B781CBB7B1900EDD727 /* RCTMediaPlayerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTMediaPlayerView.h; sourceTree = ""; };
31 | 5FDB0B791CBB7B1900EDD727 /* RCTMediaPlayerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTMediaPlayerView.m; sourceTree = ""; };
32 | /* End PBXFileReference section */
33 |
34 | /* Begin PBXFrameworksBuildPhase section */
35 | 5FDB0B671CBB7ACA00EDD727 /* Frameworks */ = {
36 | isa = PBXFrameworksBuildPhase;
37 | buildActionMask = 2147483647;
38 | files = (
39 | );
40 | runOnlyForDeploymentPostprocessing = 0;
41 | };
42 | /* End PBXFrameworksBuildPhase section */
43 |
44 | /* Begin PBXGroup section */
45 | 5FDB0B611CBB7ACA00EDD727 = {
46 | isa = PBXGroup;
47 | children = (
48 | 5FDB0B6C1CBB7ACA00EDD727 /* react-native-media-kit */,
49 | 5FDB0B6B1CBB7ACA00EDD727 /* Products */,
50 | );
51 | sourceTree = "";
52 | };
53 | 5FDB0B6B1CBB7ACA00EDD727 /* Products */ = {
54 | isa = PBXGroup;
55 | children = (
56 | 5FDB0B6A1CBB7ACA00EDD727 /* libreact-native-media-kit.a */,
57 | );
58 | name = Products;
59 | sourceTree = "";
60 | };
61 | 5FDB0B6C1CBB7ACA00EDD727 /* react-native-media-kit */ = {
62 | isa = PBXGroup;
63 | children = (
64 | 5FDB0B761CBB7B1900EDD727 /* RCTMediaPlayerManager.h */,
65 | 5FDB0B771CBB7B1900EDD727 /* RCTMediaPlayerManager.m */,
66 | 5FDB0B781CBB7B1900EDD727 /* RCTMediaPlayerView.h */,
67 | 5FDB0B791CBB7B1900EDD727 /* RCTMediaPlayerView.m */,
68 | );
69 | path = "react-native-media-kit";
70 | sourceTree = "";
71 | };
72 | /* End PBXGroup section */
73 |
74 | /* Begin PBXNativeTarget section */
75 | 5FDB0B691CBB7ACA00EDD727 /* react-native-media-kit */ = {
76 | isa = PBXNativeTarget;
77 | buildConfigurationList = 5FDB0B731CBB7ACA00EDD727 /* Build configuration list for PBXNativeTarget "react-native-media-kit" */;
78 | buildPhases = (
79 | 5FDB0B661CBB7ACA00EDD727 /* Sources */,
80 | 5FDB0B671CBB7ACA00EDD727 /* Frameworks */,
81 | 5FDB0B681CBB7ACA00EDD727 /* CopyFiles */,
82 | );
83 | buildRules = (
84 | );
85 | dependencies = (
86 | );
87 | name = "react-native-media-kit";
88 | productName = "react-native-media-kit";
89 | productReference = 5FDB0B6A1CBB7ACA00EDD727 /* libreact-native-media-kit.a */;
90 | productType = "com.apple.product-type.library.static";
91 | };
92 | /* End PBXNativeTarget section */
93 |
94 | /* Begin PBXProject section */
95 | 5FDB0B621CBB7ACA00EDD727 /* Project object */ = {
96 | isa = PBXProject;
97 | attributes = {
98 | LastUpgradeCheck = 0730;
99 | ORGANIZATIONNAME = YOAI;
100 | TargetAttributes = {
101 | 5FDB0B691CBB7ACA00EDD727 = {
102 | CreatedOnToolsVersion = 7.3;
103 | DevelopmentTeam = TTVS7J5UUP;
104 | };
105 | };
106 | };
107 | buildConfigurationList = 5FDB0B651CBB7ACA00EDD727 /* Build configuration list for PBXProject "react-native-media-kit" */;
108 | compatibilityVersion = "Xcode 3.2";
109 | developmentRegion = English;
110 | hasScannedForEncodings = 0;
111 | knownRegions = (
112 | en,
113 | );
114 | mainGroup = 5FDB0B611CBB7ACA00EDD727;
115 | productRefGroup = 5FDB0B6B1CBB7ACA00EDD727 /* Products */;
116 | projectDirPath = "";
117 | projectRoot = "";
118 | targets = (
119 | 5FDB0B691CBB7ACA00EDD727 /* react-native-media-kit */,
120 | );
121 | };
122 | /* End PBXProject section */
123 |
124 | /* Begin PBXSourcesBuildPhase section */
125 | 5FDB0B661CBB7ACA00EDD727 /* Sources */ = {
126 | isa = PBXSourcesBuildPhase;
127 | buildActionMask = 2147483647;
128 | files = (
129 | 5FDB0B7B1CBB7B1900EDD727 /* RCTMediaPlayerView.m in Sources */,
130 | 5FDB0B7A1CBB7B1900EDD727 /* RCTMediaPlayerManager.m in Sources */,
131 | );
132 | runOnlyForDeploymentPostprocessing = 0;
133 | };
134 | /* End PBXSourcesBuildPhase section */
135 |
136 | /* Begin XCBuildConfiguration section */
137 | 5FDB0B711CBB7ACA00EDD727 /* Debug */ = {
138 | isa = XCBuildConfiguration;
139 | buildSettings = {
140 | ALWAYS_SEARCH_USER_PATHS = NO;
141 | CLANG_ANALYZER_NONNULL = YES;
142 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
143 | CLANG_CXX_LIBRARY = "libc++";
144 | CLANG_ENABLE_MODULES = YES;
145 | CLANG_ENABLE_OBJC_ARC = YES;
146 | CLANG_WARN_BOOL_CONVERSION = YES;
147 | CLANG_WARN_CONSTANT_CONVERSION = YES;
148 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
149 | CLANG_WARN_EMPTY_BODY = YES;
150 | CLANG_WARN_ENUM_CONVERSION = YES;
151 | CLANG_WARN_INT_CONVERSION = YES;
152 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
153 | CLANG_WARN_UNREACHABLE_CODE = YES;
154 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
155 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
156 | COPY_PHASE_STRIP = NO;
157 | DEBUG_INFORMATION_FORMAT = dwarf;
158 | ENABLE_STRICT_OBJC_MSGSEND = YES;
159 | ENABLE_TESTABILITY = YES;
160 | GCC_C_LANGUAGE_STANDARD = gnu99;
161 | GCC_DYNAMIC_NO_PIC = NO;
162 | GCC_NO_COMMON_BLOCKS = YES;
163 | GCC_OPTIMIZATION_LEVEL = 0;
164 | GCC_PREPROCESSOR_DEFINITIONS = (
165 | "DEBUG=1",
166 | "$(inherited)",
167 | );
168 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
169 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
170 | GCC_WARN_UNDECLARED_SELECTOR = YES;
171 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
172 | GCC_WARN_UNUSED_FUNCTION = YES;
173 | GCC_WARN_UNUSED_VARIABLE = YES;
174 | IPHONEOS_DEPLOYMENT_TARGET = 9.3;
175 | MTL_ENABLE_DEBUG_INFO = YES;
176 | ONLY_ACTIVE_ARCH = YES;
177 | SDKROOT = iphoneos;
178 | };
179 | name = Debug;
180 | };
181 | 5FDB0B721CBB7ACA00EDD727 /* Release */ = {
182 | isa = XCBuildConfiguration;
183 | buildSettings = {
184 | ALWAYS_SEARCH_USER_PATHS = NO;
185 | CLANG_ANALYZER_NONNULL = YES;
186 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
187 | CLANG_CXX_LIBRARY = "libc++";
188 | CLANG_ENABLE_MODULES = YES;
189 | CLANG_ENABLE_OBJC_ARC = YES;
190 | CLANG_WARN_BOOL_CONVERSION = YES;
191 | CLANG_WARN_CONSTANT_CONVERSION = YES;
192 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
193 | CLANG_WARN_EMPTY_BODY = YES;
194 | CLANG_WARN_ENUM_CONVERSION = YES;
195 | CLANG_WARN_INT_CONVERSION = YES;
196 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
197 | CLANG_WARN_UNREACHABLE_CODE = YES;
198 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
199 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
200 | COPY_PHASE_STRIP = NO;
201 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
202 | ENABLE_NS_ASSERTIONS = NO;
203 | ENABLE_STRICT_OBJC_MSGSEND = YES;
204 | GCC_C_LANGUAGE_STANDARD = gnu99;
205 | GCC_NO_COMMON_BLOCKS = YES;
206 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
207 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
208 | GCC_WARN_UNDECLARED_SELECTOR = YES;
209 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
210 | GCC_WARN_UNUSED_FUNCTION = YES;
211 | GCC_WARN_UNUSED_VARIABLE = YES;
212 | IPHONEOS_DEPLOYMENT_TARGET = 9.3;
213 | MTL_ENABLE_DEBUG_INFO = NO;
214 | SDKROOT = iphoneos;
215 | VALIDATE_PRODUCT = YES;
216 | };
217 | name = Release;
218 | };
219 | 5FDB0B741CBB7ACA00EDD727 /* Debug */ = {
220 | isa = XCBuildConfiguration;
221 | buildSettings = {
222 | HEADER_SEARCH_PATHS = "$(SRCROOT)/../../react-native/React/**";
223 | OTHER_LDFLAGS = "-ObjC";
224 | PRODUCT_NAME = "$(TARGET_NAME)";
225 | SKIP_INSTALL = YES;
226 | };
227 | name = Debug;
228 | };
229 | 5FDB0B751CBB7ACA00EDD727 /* Release */ = {
230 | isa = XCBuildConfiguration;
231 | buildSettings = {
232 | HEADER_SEARCH_PATHS = "$(SRCROOT)/../../react-native/React/**";
233 | OTHER_LDFLAGS = "-ObjC";
234 | PRODUCT_NAME = "$(TARGET_NAME)";
235 | SKIP_INSTALL = YES;
236 | };
237 | name = Release;
238 | };
239 | /* End XCBuildConfiguration section */
240 |
241 | /* Begin XCConfigurationList section */
242 | 5FDB0B651CBB7ACA00EDD727 /* Build configuration list for PBXProject "react-native-media-kit" */ = {
243 | isa = XCConfigurationList;
244 | buildConfigurations = (
245 | 5FDB0B711CBB7ACA00EDD727 /* Debug */,
246 | 5FDB0B721CBB7ACA00EDD727 /* Release */,
247 | );
248 | defaultConfigurationIsVisible = 0;
249 | defaultConfigurationName = Release;
250 | };
251 | 5FDB0B731CBB7ACA00EDD727 /* Build configuration list for PBXNativeTarget "react-native-media-kit" */ = {
252 | isa = XCConfigurationList;
253 | buildConfigurations = (
254 | 5FDB0B741CBB7ACA00EDD727 /* Debug */,
255 | 5FDB0B751CBB7ACA00EDD727 /* Release */,
256 | );
257 | defaultConfigurationIsVisible = 0;
258 | defaultConfigurationName = Release;
259 | };
260 | /* End XCConfigurationList section */
261 | };
262 | rootObject = 5FDB0B621CBB7ACA00EDD727 /* Project object */;
263 | }
264 |
--------------------------------------------------------------------------------
/ios/react-native-media-kit/RCTMediaPlayerManager.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | @interface RCTMediaPlayerManager : RCTViewManager
4 |
5 | @end
6 |
--------------------------------------------------------------------------------
/ios/react-native-media-kit/RCTMediaPlayerManager.m:
--------------------------------------------------------------------------------
1 | #import "RCTMediaPlayerManager.h"
2 | #import "RCTMediaPlayerView.h"
3 | #import "RCTUIManager.h"
4 |
5 | @implementation RCTMediaPlayerManager
6 |
7 | RCT_EXPORT_MODULE(RCTMediaPlayerView)
8 |
9 | - (UIView *) view {
10 | return [[RCTMediaPlayerView alloc] init];
11 | }
12 |
13 | RCT_EXPORT_VIEW_PROPERTY(autoplay, BOOL)
14 | RCT_EXPORT_VIEW_PROPERTY(src, NSString*)
15 | RCT_EXPORT_VIEW_PROPERTY(preload, NSString*)
16 | RCT_EXPORT_VIEW_PROPERTY(loop, BOOL)
17 | RCT_EXPORT_VIEW_PROPERTY(muted, BOOL)
18 |
19 |
20 | RCT_EXPORT_VIEW_PROPERTY(onPlayerPaused, RCTBubblingEventBlock)
21 | RCT_EXPORT_VIEW_PROPERTY(onPlayerPlaying, RCTBubblingEventBlock)
22 | RCT_EXPORT_VIEW_PROPERTY(onPlayerFinished, RCTBubblingEventBlock)
23 | RCT_EXPORT_VIEW_PROPERTY(onPlayerBuffering, RCTBubblingEventBlock)
24 | RCT_EXPORT_VIEW_PROPERTY(onPlayerBufferOK, RCTBubblingEventBlock)
25 | RCT_EXPORT_VIEW_PROPERTY(onPlayerProgress, RCTBubblingEventBlock)
26 | RCT_EXPORT_VIEW_PROPERTY(onPlayerBufferChange, RCTBubblingEventBlock)
27 |
28 |
29 | - (NSDictionary *)constantsToExport {
30 | return [super constantsToExport];
31 | }
32 |
33 | RCT_EXPORT_METHOD(pause:(nonnull NSNumber *)reactTag) {
34 | [self executeBlock:^(RCTMediaPlayerView *view) {
35 | [view pause];
36 | } withTag:reactTag];
37 | }
38 |
39 | RCT_EXPORT_METHOD(stop:(nonnull NSNumber *)reactTag) {
40 | [self executeBlock:^(RCTMediaPlayerView *view) {
41 | [view stop];
42 | } withTag:reactTag];
43 | }
44 |
45 | RCT_EXPORT_METHOD(play:(nonnull NSNumber *)reactTag) {
46 | [self executeBlock:^(RCTMediaPlayerView *view) {
47 | [view play];
48 | } withTag:reactTag];
49 | }
50 |
51 | RCT_EXPORT_METHOD(seekTo:(nonnull NSNumber *)reactTag :(double)timeMs) {
52 | [self executeBlock:^(RCTMediaPlayerView *view) {
53 | [view seekTo:timeMs];
54 | } withTag:reactTag];
55 | }
56 |
57 |
58 | typedef void (^RCTMediaPlayerViewManagerBlock)(RCTMediaPlayerView *view);
59 |
60 | - (void)executeBlock:(RCTMediaPlayerViewManagerBlock)block withTag:(nonnull NSNumber *)reactTag {
61 | [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary *viewRegistry) {
62 | RCTMediaPlayerView *view = viewRegistry[reactTag];
63 | if (![view isKindOfClass:[RCTMediaPlayerView class]]) {
64 | RCTLogError(@"Invalid view returned from registry, expecting RCTMediaPlayerView, got: %@", view);
65 | } else {
66 | block(view);
67 | }
68 | }];
69 | }
70 |
71 | @end
72 |
--------------------------------------------------------------------------------
/ios/react-native-media-kit/RCTMediaPlayerView.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "RCTComponent.h"
3 |
4 |
5 | @interface RCTMediaPlayerView : UIView
6 |
7 |
8 | @property (nonatomic, strong) RCTDirectEventBlock onPlayerPlaying;
9 | @property (nonatomic, strong) RCTDirectEventBlock onPlayerPaused;
10 | @property (nonatomic, strong) RCTDirectEventBlock onPlayerProgress;
11 | @property (nonatomic, strong) RCTDirectEventBlock onPlayerBuffering;
12 | @property (nonatomic, strong) RCTDirectEventBlock onPlayerBufferOK;
13 | @property (nonatomic, strong) RCTDirectEventBlock onPlayerFinished;
14 | @property (nonatomic, strong) RCTDirectEventBlock onPlayerBufferChange;
15 |
16 | @property (nonatomic) BOOL autoplay;
17 | @property (nonatomic) NSString* src;
18 | @property (nonatomic) NSString* preload; //could be "none", "metadata", "auto"
19 | @property (nonatomic) BOOL loop;
20 | @property (nonatomic) BOOL muted;
21 |
22 |
23 | - (void)pause;
24 | - (void)play;
25 | - (void)stop;
26 | - (void)seekTo: (NSTimeInterval)timeInSec;
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/ios/react-native-media-kit/RCTMediaPlayerView.m:
--------------------------------------------------------------------------------
1 | #import "RCTMediaPlayerView.h"
2 | @import AVFoundation;
3 |
4 | @interface RCTMediaPlayerView ()
5 |
6 | @property (nonatomic, strong) NSTimer *progressTimer;
7 |
8 | @end
9 |
10 | @implementation RCTMediaPlayerView {
11 | @private
12 | AVPlayer *player;
13 | id progressObserverHandle;
14 | BOOL shouldResumePlay;
15 | BOOL shouldContinuePlayWhenForeground;
16 | BOOL firstLayout;
17 | BOOL firstReady;
18 | }
19 |
20 | + (Class)layerClass {
21 | return [AVPlayerLayer class];
22 | }
23 | - (AVPlayer*)player {
24 | return [(AVPlayerLayer *)[self layer] player];
25 | }
26 | - (void)setPlayer:(AVPlayer *)player {
27 | [(AVPlayerLayer *)[self layer] setPlayer:player];
28 | }
29 |
30 |
31 | - (instancetype) init {
32 | self = [super init];
33 | return self;
34 | }
35 |
36 | - (void)willMoveToWindow:(UIWindow *)newWindow {
37 | NSLog(@"willMoveToWindow...%@", newWindow);
38 | if(!newWindow) {
39 | [self releasePlayer];
40 | }
41 | }
42 |
43 | - (void)willMoveToSuperview:(UIView *)newSuperview {
44 | NSLog(@"willMoveToSuperview...%@", newSuperview);
45 | if(!newSuperview) {
46 | [self releasePlayer];
47 | }
48 | }
49 |
50 | - (void)initPlayerIfNeeded {
51 | if(!player) {
52 | player = [AVPlayer playerWithURL:[NSURL URLWithString:self.src]];
53 | [self setPlayer:player];
54 | [self addProgressObserver];
55 | [self addObservers];
56 |
57 | if(player) {
58 | if(self.muted) {
59 | player.muted = YES;
60 | } else {
61 | player.muted = NO;
62 | }
63 | }
64 | }
65 | }
66 |
67 | - (void)releasePlayer {
68 | if(player) {
69 | [player pause];
70 | [self removeProgressObserver];
71 | [self removeObservers];
72 | player = nil;
73 | firstReady = false;
74 | }
75 | }
76 |
77 | - (void) setAutoplay:(BOOL)autoplay {
78 | NSLog(@"setAutoplay...autoplay=%d", autoplay);
79 | _autoplay = autoplay;
80 | [self updateProps];
81 | }
82 |
83 | - (void) setSrc: (NSString *)uri {
84 | NSLog(@"setSrc...src=%@", uri);
85 | _src = uri;
86 |
87 | if(player) {
88 | [self releasePlayer];
89 | }
90 | [self updateProps];
91 | }
92 |
93 | - (void) setPreload:(NSString *)preload {
94 | NSLog(@"setPreload...preload=%@", preload);
95 | _preload = preload;
96 | [self updateProps];
97 | }
98 |
99 | - (void) setLoop:(BOOL)loop {
100 | NSLog(@"setLoop...loop=%d", loop);
101 | _loop = loop;
102 | [self updateProps];
103 | }
104 |
105 | - (void) setMuted:(BOOL)muted {
106 | NSLog(@"setMuted...muted=%d", muted);
107 | _muted = muted;
108 | [self updateProps];
109 | }
110 |
111 | - (void) layoutSubviews {
112 | NSLog(@"layoutSubviews...");
113 | [super layoutSubviews];
114 | firstLayout = true;
115 | [self updateProps];
116 | }
117 |
118 | - (void) updateProps {
119 | if(!self.src || !firstLayout) {
120 | return;
121 | }
122 |
123 | if (!player) {
124 | if (self.autoplay) {
125 | [self initPlayerIfNeeded];
126 | [self play];
127 | } else {
128 | if ([self.preload isEqualToString:@"none"]) {
129 |
130 | } else if ([self.preload isEqualToString:@"metadata"]) {
131 |
132 | } else if ([self.preload isEqualToString:@"auto"]) {
133 | [self initPlayerIfNeeded];
134 | }
135 | }
136 | }
137 | if(player) {
138 | if(self.muted) {
139 | player.muted = YES;
140 | } else {
141 | player.muted = NO;
142 | }
143 | }
144 | }
145 |
146 |
147 |
148 | - (void) addProgressObserver {
149 | if(!progressObserverHandle) {
150 | if(player) {
151 | progressObserverHandle = [player addPeriodicTimeObserverForInterval:CMTimeMakeWithSeconds(1, 1) queue:NULL usingBlock:^(CMTime time) {
152 | [self notifyPlayerProgress];
153 | }];
154 | }
155 |
156 | }
157 | }
158 |
159 | - (void) removeProgressObserver {
160 | if(progressObserverHandle) {
161 | if(player) {
162 | [player removeTimeObserver:progressObserverHandle];
163 | progressObserverHandle = nil;
164 | }
165 | }
166 | }
167 |
168 | - (void) notifyPlayerProgress {
169 | if(player && player.currentItem) {
170 | double currentTime = CMTimeGetSeconds(player.currentTime);
171 | double totalTime = CMTimeGetSeconds(player.currentItem.duration);
172 | if(isnan(currentTime) || isinf(currentTime)) {
173 | currentTime = 0;
174 | }
175 | if(isnan(totalTime) || isinf(totalTime)) {
176 | totalTime = 0;
177 | }
178 | if(self.onPlayerProgress) {
179 | self.onPlayerProgress(@{@"current": @(currentTime * 1000), @"total": @(totalTime * 1000)}); //in millisec
180 | }
181 | }
182 | }
183 |
184 | - (void) notifyPlayerBuffering {
185 | if(self.onPlayerBuffering) {
186 | self.onPlayerBuffering(nil);
187 | }
188 | }
189 |
190 | - (void) notifyPlayerBufferOK {
191 | if(self.onPlayerBufferOK) {
192 | self.onPlayerBufferOK(nil);
193 | }
194 | }
195 |
196 | - (void) notifyPlayerBufferChange: (NSArray *)ranges {
197 | if(self.onPlayerBufferChange) {
198 | self.onPlayerBufferChange(@{@"ranges": ranges});
199 | }
200 | }
201 |
202 |
203 | - (void) notifyPlayerPlaying {
204 | if(self.onPlayerPlaying) {
205 | self.onPlayerPlaying(nil);
206 | }
207 | }
208 |
209 | - (void) notifyPlayerPaused {
210 | if (self.onPlayerPaused) {
211 | self.onPlayerPaused(nil);
212 | }
213 | }
214 |
215 | - (void) notifyPlayerFinished {
216 | if (self.onPlayerFinished) {
217 | self.onPlayerFinished(nil);
218 | }
219 | }
220 |
221 |
222 | - (void)addObservers {
223 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillResignActive:)
224 | name:UIApplicationWillResignActiveNotification object:nil];
225 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:)
226 | name:UIApplicationDidBecomeActiveNotification object:nil];
227 |
228 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemDidReachEnd:)
229 | name:AVPlayerItemDidPlayToEndTimeNotification object:[player currentItem]];
230 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemPlaybackStalled:)
231 | name:AVPlayerItemPlaybackStalledNotification object:[player currentItem]];
232 | if (player) {
233 | [player addObserver:self forKeyPath:@"rate" options:0 context:nil];
234 | if (player.currentItem) {
235 | [player.currentItem addObserver:self forKeyPath:@"status" options:0 context:nil];
236 | [player.currentItem addObserver:self forKeyPath:@"loadedTimeRanges" options:0 context:nil];
237 | [player.currentItem addObserver:self forKeyPath:@"playbackBufferFull" options:0 context:nil];
238 | [player.currentItem addObserver:self forKeyPath:@"playbackBufferEmpty" options:0 context:nil];
239 | }
240 | }
241 | }
242 |
243 | - (void)removeObservers {
244 | [[NSNotificationCenter defaultCenter] removeObserver:self];
245 | if (player) {
246 | [player removeObserver:self forKeyPath:@"rate"];
247 | if (player.currentItem) {
248 | [player.currentItem removeObserver:self forKeyPath:@"status"];
249 | [player.currentItem removeObserver:self forKeyPath:@"loadedTimeRanges"];
250 | [player.currentItem removeObserver:self forKeyPath:@"playbackBufferFull"];
251 | [player.currentItem removeObserver:self forKeyPath:@"playbackBufferEmpty"];
252 | }
253 | }
254 | }
255 |
256 | - (void)applicationWillResignActive:(NSNotification *)notification {
257 | shouldContinuePlayWhenForeground = shouldResumePlay;
258 | [self pause];
259 | }
260 |
261 | - (void)applicationDidBecomeActive:(NSNotification *)notification {
262 | if (shouldContinuePlayWhenForeground) {
263 | [self play];
264 | }
265 | }
266 |
267 | - (void)playerItemDidReachEnd:(NSNotification *)notification {
268 | [self notifyPlayerFinished];
269 | if(player) {
270 | [player seekToTime:kCMTimeZero];
271 | if (self.loop) {
272 | [self play];
273 | }
274 | }
275 | }
276 |
277 | - (void)playerItemPlaybackStalled:(NSNotification *)notification {
278 | [self notifyPlayerBuffering];
279 | }
280 |
281 | - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
282 | NSLog(keyPath);
283 | if(!player) {
284 | return;
285 | }
286 | if ([keyPath isEqualToString:@"status"]) {
287 | AVPlayerItem *playerItem = (AVPlayerItem *)object;
288 | if(playerItem.status == AVPlayerItemStatusReadyToPlay) {
289 | NSLog(@"status...ready to play");
290 | firstReady = true;
291 | [self notifyPlayerProgress];
292 | [self notifyPlayerBufferOK];
293 | if(player.rate != 0) {
294 | [self notifyPlayerPlaying];
295 | }
296 | } else if(playerItem.status == AVPlayerItemStatusUnknown) {
297 | NSLog(@"status...unknown");
298 | } else if(playerItem.status == AVPlayerItemStatusFailed) {
299 | NSLog(@"status...failed");
300 | }
301 | } else if ([keyPath isEqualToString:@"loadedTimeRanges"]) {
302 | NSMutableArray *array = [NSMutableArray arrayWithCapacity:1];
303 | for (NSValue *time in player.currentItem.loadedTimeRanges) {
304 | CMTimeRange range = [time CMTimeRangeValue];
305 | [array addObject:@{@"start": @(CMTimeGetSeconds(range.start) * 1000), @"duration": @(CMTimeGetSeconds(range.duration) * 1000)}];
306 | }
307 | [self notifyPlayerBufferChange:array];
308 | } else if( [keyPath isEqualToString:@"rate"]) {
309 | NSLog(@"rate=%f", player.rate);
310 | if(player.rate == 0) {
311 | [self notifyPlayerPaused];
312 | } else {
313 | if (firstReady) {
314 | [self notifyPlayerPlaying];
315 | } else {
316 | [self notifyPlayerBuffering];
317 | }
318 | }
319 | } else if([keyPath isEqualToString:@"playbackBufferFull"]) {
320 | [self notifyPlayerBufferOK];
321 | if (shouldResumePlay) {
322 | [self play];
323 | }
324 | }
325 | }
326 |
327 |
328 |
329 |
330 | - (void)pause {
331 | NSLog(@"pause...");
332 | if (player) {
333 | [player pause];
334 | shouldResumePlay = false;
335 | }
336 | }
337 |
338 | - (void)play {
339 | NSLog(@"play...");
340 | [self initPlayerIfNeeded];
341 | if(player) {
342 | [player play];
343 | shouldResumePlay = YES;
344 | }
345 | }
346 |
347 | - (void)stop {
348 | NSLog(@"stop...");
349 | if (player) {
350 | [player pause];
351 | [player seekToTime:kCMTimeZero];
352 | shouldResumePlay = false;
353 | }
354 | }
355 |
356 | - (void)seekTo: (NSTimeInterval) timeMs {
357 | NSLog(@"seekTo...timeMs=%f", timeMs);
358 | if(player) {
359 | CMTime cmTime = CMTimeMakeWithSeconds(timeMs/1000, 1);
360 | [player seekToTime:cmTime];
361 | }
362 | }
363 | @end
364 |
--------------------------------------------------------------------------------
/library/Controls.js:
--------------------------------------------------------------------------------
1 | import React, {PropTypes} from 'react';
2 |
3 | import ReactNative, {
4 | StyleSheet,
5 | Text,
6 | View,
7 | TouchableOpacity,
8 | NativeModules,
9 | requireNativeComponent,
10 | Dimensions,
11 | ScrollView,
12 | Image,
13 | Platform,
14 | ActivityIndicator,
15 | } from 'react-native';
16 |
17 | import Slider from '@ldn0x7dc/react-native-slider';
18 |
19 | /**
20 | * format as --:-- or --:--:--
21 | * @param timeSec
22 | * @param containHours
23 | * @returns {string}
24 | */
25 | function formatProgress(timeSec, containHours) {
26 | function zeroPad(s) {
27 | if (s.length === 1) {
28 | return '0' + s;
29 | }
30 | return s;
31 | }
32 |
33 | let hours = Math.floor(timeSec / 60.0 / 60.0).toFixed(0);
34 | let minutes = Math.floor(timeSec / 60.0 % 60.0).toFixed(0);
35 | let seconds = Math.floor(timeSec % 60.0).toFixed(0);
36 |
37 | if(hours < 0) {
38 | hours = 0;
39 | }
40 | if (minutes < 0) {
41 | minutes = 0;
42 | }
43 | if(seconds < 0) {
44 | seconds = 0;
45 | }
46 |
47 | hours = zeroPad(hours);
48 | minutes = zeroPad(minutes);
49 | seconds = zeroPad(seconds);
50 |
51 | if (containHours) {
52 | return hours + ':' + minutes + ':' + seconds;
53 | }
54 | return minutes + ':' + seconds;
55 | }
56 |
57 | export default class Controls extends React.Component {
58 |
59 | defaultProps = {
60 | current: 0,
61 | total: 0,
62 | buffering: false,
63 | playing: false
64 | }
65 |
66 | constructor(props) {
67 | super(props);
68 | this.state = {
69 | sliding: false,
70 | current: this.props.current,
71 | };
72 | }
73 |
74 | componentWillReceiveProps(nextProps) {
75 | if (!this.state.sliding) {
76 | if (this.props.current != nextProps.current) {
77 | this.setState({
78 | current: nextProps.current,
79 | });
80 | }
81 | }
82 | }
83 |
84 | render() {
85 | const containHours = this.props.total >= 60 * 60 * 1000;
86 | const currentFormated = formatProgress(this.state.current / 1000, containHours);
87 | const totalFormated = formatProgress(this.props.total / 1000, containHours);
88 |
89 | let bufferIndicator;
90 | if(this.props.buffering) {
91 | bufferIndicator = (
92 |
95 | );
96 | }
97 |
98 | let tracks = [];
99 | if(this.props.bufferRanges) {
100 | tracks = this.props.bufferRanges.map((range) => {
101 | let startValue = range.start;
102 | let endValue = startValue + range.duration;
103 | return {
104 | key: 'bufferTrack:' + startValue + '-' + endValue,
105 | startValue, endValue,
106 | style: {backgroundColor: '#eeeeee66'}
107 | }
108 | });
109 | }
110 | tracks.push(
111 | {
112 | key: 'thumbTrack',
113 | style: {backgroundColor: 'white'}
114 | }
115 | );
116 |
117 |
118 | return (
119 |
121 | {bufferIndicator}
122 |
124 |
125 |
128 |
131 |
132 |
133 |
135 | {currentFormated}
136 |
137 |
138 | {
145 | this.setState({
146 | sliding: false,
147 | current: value
148 | });
149 | this.props.onSeekTo && this.props.onSeekTo(value);
150 | }}
151 | onValueChange={(value) => {
152 | this.setState({
153 | sliding: true,
154 | current: value
155 | });
156 | }}
157 | maximumValue={this.props.total}
158 | minimumValue={0}
159 | value={this.state.current}
160 | disabled={this.props.total > 0}
161 | tracks={tracks}
162 | />
163 |
164 |
166 | {totalFormated}
167 |
168 |
169 |
170 |
171 | );
172 | }
173 | }
--------------------------------------------------------------------------------
/library/MediaPlayerView.js:
--------------------------------------------------------------------------------
1 | import React, {PropTypes} from 'react';
2 |
3 | import ReactNative, {
4 | StyleSheet,
5 | View,
6 | NativeModules,
7 | requireNativeComponent,
8 | Image
9 | } from 'react-native';
10 |
11 | import Controls from './Controls';
12 |
13 | const UIManager = NativeModules.UIManager;
14 | const RCT_MEDIA_PLAYER_VIEW_REF = "RCTMediaPlayerView";
15 | const RCTMediaPlayerView = requireNativeComponent('RCTMediaPlayerView', {
16 | name: 'RCTMediaPlayerView',
17 | propTypes: {
18 | ...View.propTypes,
19 | src: PropTypes.string,
20 | autoplay: PropTypes.bool,
21 | preload: PropTypes.string,
22 | loop: PropTypes.bool,
23 | muted: PropTypes.bool,
24 |
25 | onPlayerPaused: PropTypes.func,
26 | onPlayerPlaying: PropTypes.func,
27 | onPlayerFinished: PropTypes.func,
28 | onPlayerBuffering: PropTypes.func,
29 | onPlayerBufferOK: PropTypes.func,
30 | onPlayerProgress: PropTypes.func,
31 | onPlayerBufferChange: PropTypes.func
32 | }
33 | });
34 |
35 | export default class MediaPlayerView extends React.Component {
36 |
37 | static propTypes = {
38 | ...RCTMediaPlayerView.propTypes,
39 | controls: PropTypes.bool,
40 | poster: PropTypes.string
41 | }
42 |
43 | static defaultProps = {
44 | autoplay: false,
45 | controls: true,
46 | preload: 'none',
47 | loop: false,
48 | }
49 |
50 | constructor(props) {
51 | super(props);
52 | this.state = {
53 | buffering: false,
54 | playing: false,
55 | current: 0,
56 | total: 0,
57 |
58 | width: 0,
59 | height: 0,
60 | showPoster: true
61 |
62 | };
63 | }
64 |
65 | componentWillUnmount() {
66 | console.log('componentWillUnmount...');
67 | this.stop();
68 | }
69 |
70 | render() {
71 | let posterView;
72 | if(this.props.poster && this.state.width && this.state.height && this.state.showPoster) {
73 | posterView = (
74 |
84 | );
85 | }
86 |
87 | let controlsView;
88 | if (this.props.controls) {
89 | controlsView = (
90 | {
97 | if(this.state.playing) {
98 | this.pause();
99 | } else {
100 | this.play();
101 | }
102 | }}
103 | bufferRanges={this.state.bufferRanges}
104 | />
105 | );
106 | }
107 |
108 | return (
109 |
112 |
113 |
125 |
126 | {posterView}
127 | {controlsView}
128 |
129 | );
130 | }
131 |
132 | _onLayout(e) {
133 | const {width, height} = e.nativeEvent.layout;
134 | this.setState({width, height});
135 |
136 | this.props.onLayout && this.props.onLayout(e);
137 | }
138 |
139 | pause() {
140 | UIManager.dispatchViewManagerCommand(
141 | this._getMediaPlayerViewHandle(),
142 | UIManager.RCTMediaPlayerView.Commands.pause,
143 | null
144 | );
145 | }
146 |
147 | play() {
148 | this.setState({showPoster: false})
149 | UIManager.dispatchViewManagerCommand(
150 | this._getMediaPlayerViewHandle(),
151 | UIManager.RCTMediaPlayerView.Commands.play,
152 | null
153 | );
154 | }
155 |
156 | stop() {
157 | UIManager.dispatchViewManagerCommand(
158 | this._getMediaPlayerViewHandle(),
159 | UIManager.RCTMediaPlayerView.Commands.stop,
160 | null
161 | );
162 | }
163 |
164 | seekTo(timeMs) {
165 | this.setState({showPoster: false})
166 | let args = [timeMs];
167 | UIManager.dispatchViewManagerCommand(
168 | this._getMediaPlayerViewHandle(),
169 | UIManager.RCTMediaPlayerView.Commands.seekTo,
170 | args
171 | );
172 | }
173 |
174 | _getMediaPlayerViewHandle() {
175 | return ReactNative.findNodeHandle(this.refs[RCT_MEDIA_PLAYER_VIEW_REF]);
176 | }
177 |
178 | _onPlayerBuffering() {
179 | this.props.onPlayerBuffering && this.props.onPlayerBuffering();
180 |
181 | if (this.props.controls) {
182 | this.setState({
183 | buffering: true
184 | });
185 | }
186 | }
187 |
188 | _onPlayerBufferChange(e) {
189 | this.props.onPlayerBuffering && this.props.onPlayerBuffering(e);
190 |
191 | if (this.props.controls) {
192 | this.setState({
193 | bufferRanges: e.nativeEvent.ranges
194 | });
195 | }
196 | }
197 |
198 | _onPlayerBufferOK() {
199 | this.props.onPlayerBufferOK && this.props.onPlayerBufferOK();
200 |
201 | if (this.props.controls) {
202 | this.setState({
203 | buffering: false
204 | });
205 | }
206 | }
207 |
208 |
209 | _onPlayerPlaying() {
210 | this.props.onPlayerPlaying && this.props.onPlayerPlaying();
211 |
212 | if (this.props.controls) {
213 | this.setState({
214 | buffering: false,
215 | playing: true
216 | });
217 | }
218 | }
219 |
220 | _onPlayerPaused() {
221 | this.props.onPlayerPaused && this.props.onPlayerPaused();
222 |
223 | if (this.props.controls) {
224 | this.setState({
225 | playing: false
226 | });
227 | }
228 | }
229 |
230 | _onPlayerFinished() {
231 | this.props.onPlayerFinished && this.props.onPlayerFinished();
232 |
233 | if (this.props.controls) {
234 | this.setState({
235 | playing: false,
236 | buffering: false
237 | });
238 | }
239 | }
240 |
241 | _onPlayerProgress(event) {
242 | let current = event.nativeEvent.current; //in ms
243 | let total = event.nativeEvent.total; //in ms
244 |
245 | this.props.onPlayerProgress && this.props.onPlayerProgress(current, total);
246 |
247 | if (this.props.controls) {
248 | this.setState({
249 | current: current,
250 | total: total
251 | });
252 | }
253 | }
254 | }
--------------------------------------------------------------------------------
/library/img/media-player-pause@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ldn0x7dc/react-native-media-kit/76b2fa6259a2c1bc1fad3de551afca595cfcb369/library/img/media-player-pause@2x.png
--------------------------------------------------------------------------------
/library/img/media-player-pause@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ldn0x7dc/react-native-media-kit/76b2fa6259a2c1bc1fad3de551afca595cfcb369/library/img/media-player-pause@3x.png
--------------------------------------------------------------------------------
/library/img/media-player-play@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ldn0x7dc/react-native-media-kit/76b2fa6259a2c1bc1fad3de551afca595cfcb369/library/img/media-player-play@2x.png
--------------------------------------------------------------------------------
/library/img/media-player-play@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ldn0x7dc/react-native-media-kit/76b2fa6259a2c1bc1fad3de551afca595cfcb369/library/img/media-player-play@3x.png
--------------------------------------------------------------------------------
/library/img/media-player-thumb@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ldn0x7dc/react-native-media-kit/76b2fa6259a2c1bc1fad3de551afca595cfcb369/library/img/media-player-thumb@2x.png
--------------------------------------------------------------------------------
/library/img/media-player-thumb@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ldn0x7dc/react-native-media-kit/76b2fa6259a2c1bc1fad3de551afca595cfcb369/library/img/media-player-thumb@3x.png
--------------------------------------------------------------------------------
/library/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | import MediaPlayerView from './MediaPlayerView';
4 |
5 | const Video = MediaPlayerView;
6 | const Audio = MediaPlayerView;
7 |
8 | export {Video, Audio};
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-media-kit",
3 | "version": "0.0.14",
4 | "description": "Video and Audio component for react-native apps, supporting both iOS and Android.",
5 | "main": "library/index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "",
10 | "license": "ISC",
11 | "repository": {
12 | "type": "git",
13 | "url": "git+https://github.com/ldn0x7dc/react-native-media-kit.git"
14 | },
15 | "keywords": [
16 | "video",
17 | "audio",
18 | "media",
19 | "react-native"
20 | ],
21 | "bugs": {
22 | "url": "https://github.com/ldn0x7dc/react-native-media-kit/issues"
23 | },
24 | "homepage": "https://github.com/ldn0x7dc/react-native-media-kit#readme",
25 | "dependencies": {
26 | "@ldn0x7dc/react-native-slider": "0.0.3"
27 | }
28 | }
29 |
--------------------------------------------------------------------------------