forked from TheWidlarzGroup/react-native-video-player
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'mrAlbert-development-master'
- Loading branch information
Showing
6 changed files
with
226 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.my.package; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
|
||
import com.facebook.react.bridge.NativeModule; | ||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.bridge.ReactContext; | ||
import com.facebook.react.bridge.ReactContextBaseJavaModule; | ||
import com.facebook.react.bridge.ReactMethod; | ||
|
||
public class BridgeModule extends ReactContextBaseJavaModule{ | ||
public BridgeModule(ReactApplicationContext reactContext) { | ||
super(reactContext); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "BridgeModule"; | ||
} | ||
@ReactMethod | ||
public void showFullscreen(String videoUri) { | ||
Context context = getReactApplicationContext(); | ||
Intent intent = new Intent(context, VideoActivity.class); // mContext got from your overriden constructor | ||
intent.putExtra("VIDEO_URL",videoUri); | ||
getCurrentActivity().startActivity(intent); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.my.package; | ||
|
||
|
||
import com.facebook.react.ReactPackage; | ||
import com.facebook.react.bridge.JavaScriptModule; | ||
import com.facebook.react.bridge.NativeModule; | ||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.uimanager.ViewManager; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class BridgePackage implements ReactPackage { | ||
|
||
@Override | ||
public List<Class<? extends JavaScriptModule>> createJSModules() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public List<NativeModule> createNativeModules( | ||
ReactApplicationContext reactContext) { | ||
List<NativeModule> modules = new ArrayList<>(); | ||
|
||
modules.add(new BridgeModule(reactContext)); | ||
|
||
return modules; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.my.package; | ||
|
||
import android.app.ProgressDialog; | ||
import android.content.Intent; | ||
import android.content.pm.ActivityInfo; | ||
import android.graphics.PixelFormat; | ||
import android.media.MediaPlayer; | ||
import android.net.Uri; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.widget.MediaController; | ||
import android.widget.Toast; | ||
import android.widget.VideoView; | ||
|
||
public class VideoActivity extends AppCompatActivity { | ||
private String videoPath; | ||
|
||
private static ProgressDialog progressDialog; | ||
VideoView myVideoView; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); | ||
setContentView(R.layout.player_fullscreen); | ||
Intent i = getIntent(); | ||
if(i != null){ | ||
myVideoView = (VideoView) findViewById(R.id.videoView); | ||
videoPath = i.getStringExtra("VIDEO_URL"); | ||
progressDialog = ProgressDialog.show(VideoActivity.this, "", "Buffering video...", true); | ||
progressDialog.setCancelable(true); | ||
PlayVideo(); | ||
} | ||
else{ | ||
Toast.makeText(VideoActivity.this, "VideoURL not found", Toast.LENGTH_SHORT).show(); | ||
} | ||
|
||
|
||
} | ||
|
||
private void PlayVideo() { | ||
try { | ||
getWindow().setFormat(PixelFormat.TRANSLUCENT); | ||
MediaController mediaController = new MediaController(VideoActivity.this); | ||
mediaController.setAnchorView(myVideoView); | ||
|
||
Uri video = Uri.parse(videoPath); | ||
myVideoView.setMediaController(mediaController); | ||
myVideoView.setVideoURI(video); | ||
myVideoView.requestFocus(); | ||
myVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { | ||
public void onPrepared(MediaPlayer mp) { | ||
progressDialog.dismiss(); | ||
myVideoView.start(); | ||
} | ||
}); | ||
|
||
|
||
} catch (Exception e) { | ||
progressDialog.dismiss(); | ||
System.out.println("Video Play Error :" + e.toString()); | ||
finish(); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".VideoActivity"> | ||
|
||
<VideoView | ||
android:id="@+id/videoView" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" | ||
android:layout_alignParentTop="true" | ||
android:layout_alignParentBottom="true" | ||
android:layout_alignParentLeft="true" | ||
android:layout_alignParentRight="true" | ||
/> | ||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters