├── android ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ └── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── herudi │ │ │ └── exovideo │ │ │ ├── ExoPlayerIntentPackage.java │ │ │ ├── ExoPlayerIntentModule.java │ │ │ ├── PlayerActivity.java │ │ │ ├── PlayerView.java │ │ │ └── PlayerController.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── herudi │ │ │ └── exovideo │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── herudi │ │ └── exovideo │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── index.js ├── package.json ├── README.md └── LICENSE /android/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | IntentExoplayer 3 | 4 | -------------------------------------------------------------------------------- /android/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/herudi/react-native-exoplayer-intent-video/HEAD/android/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/herudi/react-native-exoplayer-intent-video/HEAD/android/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/herudi/react-native-exoplayer-intent-video/HEAD/android/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/herudi/react-native-exoplayer-intent-video/HEAD/android/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/herudi/react-native-exoplayer-intent-video/HEAD/android/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /android/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /android/src/test/java/com/herudi/exovideo/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.herudi.exovideo; 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 | } -------------------------------------------------------------------------------- /android/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /android/src/androidTest/java/com/herudi/exovideo/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.herudi.exovideo; 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 | } -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import React, { 2 | PropTypes, 3 | Component 4 | } from 'react'; 5 | 6 | import { 7 | NativeModules 8 | } from 'react-native'; 9 | 10 | const { ExoPlayerManager } = NativeModules; 11 | 12 | module.exports = { 13 | ...ExoPlayerManager, 14 | play(data) { 15 | var url = data.url; 16 | var title = data.title === undefined ? null : data.title; 17 | var subtitle = data.subtitle === undefined ? null : data.subtitle; 18 | return ExoPlayerManager.showVideoPlayer(url,title,subtitle); 19 | } 20 | } -------------------------------------------------------------------------------- /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 C:\Android\android-sdk/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/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.1" 6 | 7 | defaultConfig { 8 | minSdkVersion 16 9 | targetSdkVersion 22 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:r2.3.1' 26 | compile 'com.facebook.react:react-native:+' 27 | } 28 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-exoplayer-intent-video", 3 | "version": "0.0.1", 4 | "description": "React native video player with exoplayer, play in new intent android only", 5 | "main": "index", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/herudi/react-native-exoplayer-intent-video.git" 9 | }, 10 | "keywords": [ 11 | "react-native-video", 12 | "react-native-exoplayer", 13 | "react", 14 | "react-native", 15 | "video", 16 | "intent", 17 | "exoplayer", 18 | "player" 19 | ], 20 | "author": "HERUDI", 21 | "license": "GNU", 22 | "bugs": { 23 | "url": "https://github.com/herudi/react-native-exoplayer-intent-video/issues" 24 | }, 25 | "peerDependencies": { 26 | "react-native": ">=0.30.0" 27 | }, 28 | "homepage": "https://github.com/herudi/react-native-exoplayer-intent-video/blob/master/README.md" 29 | } -------------------------------------------------------------------------------- /android/src/main/java/com/herudi/exovideo/ExoPlayerIntentPackage.java: -------------------------------------------------------------------------------- 1 | package com.herudi.exovideo; 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 | 9 | import java.util.Arrays; 10 | import java.util.Collections; 11 | import java.util.List; 12 | 13 | /** 14 | * Created by herudi-sahimar on 25/04/2017. 15 | */ 16 | public class ExoPlayerIntentPackage implements ReactPackage { 17 | @Override 18 | public List createNativeModules(ReactApplicationContext reactContext) { 19 | return Arrays.asList(new ExoPlayerIntentModule(reactContext)); 20 | } 21 | 22 | @Override 23 | public List> createJSModules() { 24 | return Collections.emptyList(); 25 | } 26 | 27 | @Override 28 | public List createViewManagers(ReactApplicationContext reactContext) { 29 | return Collections.emptyList(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /android/src/main/java/com/herudi/exovideo/ExoPlayerIntentModule.java: -------------------------------------------------------------------------------- 1 | package com.herudi.exovideo; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.net.Uri; 6 | 7 | import com.facebook.react.bridge.ActivityEventListener; 8 | import com.facebook.react.bridge.ReactApplicationContext; 9 | import com.facebook.react.bridge.ReactContextBaseJavaModule; 10 | import com.facebook.react.bridge.ReactMethod; 11 | 12 | /** 13 | * Created by herudi-sahimar on 25/04/2017. 14 | */ 15 | public class ExoPlayerIntentModule extends ReactContextBaseJavaModule implements ActivityEventListener { 16 | public final int TAG = 1; 17 | 18 | public ExoPlayerIntentModule(ReactApplicationContext reactContext) { 19 | super(reactContext); 20 | } 21 | 22 | @ReactMethod 23 | public void showVideoPlayer(String url, String title, String sub) { 24 | Activity currentActivity = getCurrentActivity(); 25 | if (currentActivity != null) { 26 | Intent i = new Intent(this.getReactApplicationContext(),PlayerActivity.class); 27 | i.putExtra("url", url); 28 | i.putExtra("title", title); 29 | i.putExtra("subtitle", sub); 30 | currentActivity.startActivityForResult(i, TAG); 31 | } 32 | } 33 | 34 | @Override 35 | public String getName() { 36 | return "ExoPlayerManager"; 37 | } 38 | 39 | @Override 40 | public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) { 41 | if (requestCode == TAG) { 42 | getCurrentActivity().finish(); 43 | } 44 | } 45 | 46 | @Override 47 | public void onNewIntent(Intent intent) { 48 | 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /android/src/main/java/com/herudi/exovideo/PlayerActivity.java: -------------------------------------------------------------------------------- 1 | package com.herudi.exovideo; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.util.Log; 6 | import android.view.View; 7 | 8 | /** 9 | * Created by herudi-sahimar on 24/04/2017. 10 | */ 11 | 12 | public class PlayerActivity extends Activity { 13 | PlayerController playerCtrl; 14 | private static final String TAG = "PlayerActivity"; 15 | 16 | @Override 17 | public void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | playerCtrl = new PlayerController(this); 20 | playerCtrl.fetchVideo( 21 | getIntent().getStringExtra("url"), 22 | getIntent().getStringExtra("title"), 23 | getIntent().getStringExtra("subtitle") 24 | ); 25 | setContentView(playerCtrl.getPlayerView()); 26 | } 27 | 28 | @Override 29 | public void onWindowFocusChanged(boolean hasFocus) { 30 | super.onWindowFocusChanged(hasFocus); 31 | if (hasFocus) { 32 | getWindow().getDecorView().setSystemUiVisibility( 33 | View.SYSTEM_UI_FLAG_LAYOUT_STABLE 34 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION 35 | | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 36 | | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION 37 | | View.SYSTEM_UI_FLAG_FULLSCREEN 38 | | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); 39 | } 40 | } 41 | 42 | @Override 43 | protected void onStop() { 44 | super.onStop(); 45 | Log.v(TAG,"onStop()..."); 46 | } 47 | 48 | @Override 49 | protected void onStart() { 50 | super.onStart(); 51 | Log.v(TAG,"onStart()..."); 52 | 53 | } 54 | 55 | @Override 56 | protected void onResume() { 57 | super.onResume(); 58 | Log.v(TAG,"onResume()..."); 59 | } 60 | 61 | @Override 62 | protected void onPause() { 63 | super.onPause(); 64 | Log.v(TAG,"onPause()..."); 65 | } 66 | 67 | @Override 68 | protected void onDestroy() { 69 | super.onDestroy(); 70 | Log.v(TAG,"onDestroy()..."); 71 | playerCtrl.getPlayer().release(); 72 | } 73 | 74 | } 75 | 76 | 77 | -------------------------------------------------------------------------------- /android/src/main/java/com/herudi/exovideo/PlayerView.java: -------------------------------------------------------------------------------- 1 | package com.herudi.exovideo; 2 | 3 | import android.content.Context; 4 | import android.graphics.Color; 5 | import android.support.v4.content.ContextCompat; 6 | import android.widget.ProgressBar; 7 | import android.widget.RelativeLayout; 8 | import android.widget.TextView; 9 | 10 | import com.google.android.exoplayer2.SimpleExoPlayer; 11 | import com.google.android.exoplayer2.ui.PlaybackControlView; 12 | import com.google.android.exoplayer2.ui.SimpleExoPlayerView; 13 | 14 | /** 15 | * Created by herudi-sahimar on 26/04/2017. 16 | */ 17 | public class PlayerView extends RelativeLayout { 18 | 19 | private SimpleExoPlayerView simpleExoPlayerView; 20 | private ProgressBar progressBar; 21 | private TextView textView; 22 | 23 | public PlayerView(Context context, SimpleExoPlayer player) { 24 | super(context); 25 | simpleExoPlayerView = new SimpleExoPlayerView(context); 26 | progressBar = new ProgressBar(context); 27 | textView = new TextView(context); 28 | textView.setX(40); 29 | textView.setY(20); 30 | textView.setTextColor(Color.parseColor("#FFFFFF")); 31 | textView.setTextSize(16); 32 | textView.setText("By Herudi"); 33 | RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(100,100); 34 | params.addRule(RelativeLayout.CENTER_IN_PARENT); 35 | simpleExoPlayerView.setLayoutParams(new SimpleExoPlayerView.LayoutParams( 36 | SimpleExoPlayerView.LayoutParams.MATCH_PARENT, 37 | SimpleExoPlayerView.LayoutParams.MATCH_PARENT 38 | )); 39 | setLayoutParams(new RelativeLayout.LayoutParams( 40 | RelativeLayout.LayoutParams.WRAP_CONTENT, 41 | RelativeLayout.LayoutParams.WRAP_CONTENT 42 | )); 43 | setBackgroundColor(ContextCompat.getColor(context, android.R.color.black)); 44 | addView(simpleExoPlayerView); 45 | addView(textView); 46 | addView(progressBar,params); 47 | simpleExoPlayerView.setUseController(true); 48 | simpleExoPlayerView.requestFocus(); 49 | simpleExoPlayerView.setPlayer(player); 50 | simpleExoPlayerView.setControllerVisibilityListener(new PlaybackControlView.VisibilityListener() { 51 | @Override 52 | public void onVisibilityChange(int visibility) { 53 | if (visibility==0){ 54 | textView.setVisibility(VISIBLE); 55 | }else { 56 | textView.setVisibility(GONE); 57 | } 58 | } 59 | }); 60 | } 61 | 62 | public PlayerView(Context context) { 63 | super(context); 64 | } 65 | 66 | public ProgressBar getProgressBar() { 67 | return progressBar; 68 | } 69 | 70 | public TextView getTextView() { 71 | return textView; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-native-exoplayer-intent-video 2 | React native video player with exoplayer, play in new intent Android only. 3 | 4 | [![npm version](https://img.shields.io/badge/npm-0.0.1-blue.svg)](https://www.npmjs.com/package/react-native-exoplayer-intent-video) 5 | 6 | ![Screenshot](https://drive.google.com/uc?export=view&id=0BwIOCc0bQ1AncV8tRm9ITjFMYTg) 7 | 8 | ### A. Installation the package 9 | 10 | `npm install react-native-exoplayer-intent-video --save` 11 | 12 | ### B. Linking the library to android 13 | 14 | Use automatically complete the installation: 15 | 16 | `react-native link react-native-exoplayer-intent-video` 17 | 18 | or manually like so: 19 | 20 | ```gradle 21 | // file: android/settings.gradle 22 | ... 23 | 24 | include ':react-native-exoplayer-intent-video' 25 | project(':react-native-exoplayer-intent-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-exoplayer-intent-video/android') 26 | ``` 27 | ```gradle 28 | // file: android/app/build.gradle 29 | ... 30 | 31 | dependencies { 32 | ... 33 | compile project(':react-native-exoplayer-intent-video') 34 | } 35 | ``` 36 | ```java 37 | // file: android/app/src/main/java/com/<...>/MainApplication.java 38 | ... 39 | 40 | import com.herudi.exovideo.ExoPlayerIntentPackage; // <-- add this import 41 | 42 | public class MainApplication extends Application implements ReactApplication { 43 | @Override 44 | protected List getPackages() { 45 | return Arrays.asList( 46 | new MainReactPackage(), 47 | new ExoPlayerIntentPackage() // <-- add this line 48 | ); 49 | } 50 | ... 51 | } 52 | 53 | ``` 54 | ### C. Add Activity in AndroidManifest.xml 55 | ```xml 56 | 62 | 63 | ... 64 | 65 | 66 | 69 | 70 | 71 | ... 72 | 73 | 74 | ``` 75 | 76 | ### D. Usage Example 77 | 78 | ```javascript 79 | /** 80 | * Sample React Native App 81 | * https://github.com/facebook/react-native 82 | * @flow 83 | */ 84 | 85 | import React, { Component } from 'react'; 86 | import { 87 | AppRegistry, 88 | StyleSheet, 89 | Text, 90 | Button, 91 | View 92 | } from 'react-native'; 93 | 94 | //add or import this 95 | import VideoPlayer from 'react-native-exoplayer-intent-video'; 96 | 97 | export default class videoTest extends Component { 98 | render() { 99 | return ( 100 | 101 |