Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add close-button to fullscreen & re-show MediaControllers in Full-screen #3

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f977113
Exit fullscreen if endWithThumbnail is set
Sep 27, 2017
d766714
Merge pull request #56 from luminos-software/bug/exit_fullscreen_if_e…
Sep 27, 2017
7918dee
0.8.4
cornedor Sep 27, 2017
b2fef1d
Fix Image deprecation on RN > 0.46
Sep 27, 2017
4a8634a
Merge pull request #57 from luminos-software/feature/ImageBackground_…
Oct 10, 2017
1536ac5
0.8.5
cornedor Oct 10, 2017
8d97d65
Added seek function
cornedor Nov 20, 2017
07f938f
0.8.6
cornedor Nov 20, 2017
5e8d173
0.8.6
cornedor Nov 20, 2017
ed4fb61
Reset progress to 0 when replaying video
cornedor Jan 17, 2018
e02b327
Add stop, pause and resume methods
cornedor Jan 17, 2018
4e8deff
0.9.0
cornedor Jan 17, 2018
32d6e7d
0.9.0
cornedor Jan 17, 2018
f8ff52f
Fix video repeating when loop turned off
Feb 20, 2018
f6de282
Merge pull request #78 from calvium/FixLoop
Mar 1, 2018
133b2b5
v0.9.1
cornedor Mar 1, 2018
cbe9266
0.9.1
cornedor Mar 1, 2018
98853f1
feat: onMutePress props callback
uribro Mar 7, 2018
613cef0
Add prop to enable pause video programmatically
Bomberlt May 8, 2018
47b7a54
Fix crash when endWithThumbnail is enabled
jeswinsimon Nov 2, 2018
a5f3c51
Merge pull request #102 from jeswinsimon/master
Nov 7, 2018
cdb9b4b
Merge pull request #89 from Bomberlt/Fix-#65-pause-video-programmatic…
Nov 7, 2018
7f1aa6f
Merge branch 'master' into master
Nov 7, 2018
85de6b9
Merge pull request #80 from tismo-dev/master
Nov 7, 2018
6dde57a
0.10.0
cornedor Nov 7, 2018
fa9810b
Add
xstable Feb 26, 2019
1f77c50
Merge remote-tracking branch 'project_initiator/master' into merge_wi…
xstable Feb 26, 2019
11fd8e8
Update react-native-video dependency to 4.4.0
xstable Feb 28, 2019
96841c0
Add Contributors to package.json
xstable Feb 28, 2019
63ae2f3
Fix Bug for missing "NativeModules"
xstable Feb 28, 2019
dfe7480
Fixed Play-Button on Non-Fullscreen Video doesn't work
xstable Feb 28, 2019
adf39ff
Fix Bug, that controls doesn't appear if tap on video (older Android-…
xstable Mar 6, 2019
1fc37b3
Increment Patch-Version
xstable Mar 6, 2019
b325619
Change Repository-Entry
xstable Mar 6, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
## 0.10.1
- Updated dependency of react-native-video to 4.4.0
- Added 'close'-Button on Fullscreen for Android
- Added duration/play time for IOS (with upgrading react-native-video)

## 0.9.1
- Fixed video repeating when loop turned off (thanks @mattvot)

## 0.9.0
- Added `stop` method.
- Added `pause` method.
- Added `resume` method.
- Fixed seekbar not resetting after replaying video.

## 0.8.6
- Added `seek` method.

## 0.8.2
- Fixed error in more Android versions

Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,24 @@ All other props are passed to the react-native-video component.
- playArrow
- videoWrapper

## Methods

| Method | Props | Description |
|-------------------------|-----------------|---------------------------------------------------------------------------|
| seek | time: float | Seek the player to the given time. |
| stop | | Stop the playback and reset back to 0:00. |
| pause | | Pause the playback. |
| resume | | Resume the playback. |

## Future features

- [X] Make seek bar seekable.
- [x] Make player customizable.
- [ ] Add volume control
- [X] Add fullscreen button
- [ ] Add loader
- [ ] Add video duration/play time
- [ ] Add loader
- [X] Add video duration/play time for IOS
- [ ] Add video duration/play time for Android

## Setting up fullscreen on Android

Expand Down
7 changes: 1 addition & 6 deletions android/app/src/main/java/BridgeModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
import com.facebook.react.bridge.ActivityEventListener;
import com.facebook.react.bridge.BaseActivityEventListener;
import com.facebook.react.bridge.Promise;
import android.util.Log;


public class BridgeModule extends ReactContextBaseJavaModule {
static final int VIDEO_PROGRESS_REQUEST = 13214; // The request code
Expand Down Expand Up @@ -54,21 +52,18 @@ public String getName() {
}

@ReactMethod
public void showFullscreen(String videoUri, int position, int mainVer, int patchVer, final Promise promise) {
public void showFullscreen(String videoUri, int position, final Promise promise) {
Activity currentActivity = getCurrentActivity();
Context context = getReactApplicationContext();

// Store the promise to resolve/reject when video returns data
mBridgePromise = promise;
Log.i("VIDEO","GO FULLSCREEN");

try {
Intent intent = new Intent(context, VideoActivity.class); // mContext got from your overriden constructor
Bundle extras = new Bundle();
extras.putString("VIDEO_URL",videoUri);
extras.putInt("VIDEO_POSITION",position);
extras.putInt("MAIN_VER",mainVer);
extras.putInt("PATCH_VER",patchVer);
intent.putExtras(extras);
currentActivity.startActivityForResult(intent, VIDEO_PROGRESS_REQUEST);
} catch (Exception e) {
Expand Down
32 changes: 24 additions & 8 deletions android/app/src/main/java/VideoActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class VideoActivity extends AppCompatActivity {
private Bundle extras;
private static final int MAX_DURATION = 500;
private static ProgressDialog progressDialog;
private static MediaController mediaController;

VideoView myVideoView;

@Override
Expand All @@ -36,12 +38,6 @@ protected void onCreate(Bundle savedInstanceState) {
extras = i.getExtras();
videoPath = extras.getString("VIDEO_URL");
videoPosition = extras.getInt("VIDEO_POSITION");
mainVer = extras.getInt("MAIN_VER");
patchVer = extras.getInt("PATCH_VER");
Log.v("VIDEOACTIVITY",videoPath);
Log.v("VIDEOACTIVITY",videoPosition);
Log.v("VIDEOACTIVITY",mainVer);
Log.v("VIDEOACTIVITY",patchVer);
myVideoView = (VideoView) findViewById(R.id.videoView);
progressDialog = ProgressDialog.show(VideoActivity.this, "", "Buffering video...", true);
progressDialog.setCancelable(true);
Expand All @@ -51,7 +47,8 @@ protected void onCreate(Bundle savedInstanceState) {
Toast.makeText(VideoActivity.this, "VideoURL not found", Toast.LENGTH_SHORT).show();
}

// Touch listener to close fullscreen video on doubleclick

// Touch listener to: show MediaControllers on singleclick & close fullscreen video on doubleclick
myVideoView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Expand All @@ -77,7 +74,7 @@ public boolean onTouch(View v, MotionEvent event) {
private void PlayVideo() {
try {
getWindow().setFormat(PixelFormat.TRANSLUCENT);
MediaController mediaController = new MediaController(VideoActivity.this);
mediaController = new MediaController(VideoActivity.this);
mediaController.setAnchorView(myVideoView);

Uri video = Uri.parse(videoPath);
Expand All @@ -86,6 +83,18 @@ private void PlayVideo() {
myVideoView.requestFocus();
myVideoView.setKeepScreenOn(true);
myVideoView.seekTo(videoPosition * 1000);
mediaController.setPrevNextListeners(new View.OnClickListener() {
@Override
public void onClick(View v) {
// next button clicked
mediaController.show();
}
}, new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
myVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
progressDialog.dismiss();
Expand Down Expand Up @@ -127,4 +136,11 @@ protected void finishProgress(Boolean isEnd) {
public void onBackPressed(){
finishProgress();
}
public void onClick(View v) {
switch(v.getId()) {
case R.id.closeBtn:
finishProgress();
break;
}
}
}
39 changes: 26 additions & 13 deletions android/app/src/main/res/layout/player_fullscreen.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
<?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">
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">

<Button
android:id="@+id/closeBtn"
style="@style/Widget.AppCompat.Button.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:background="@color/colorAccent"
android:onClick="onClick"
android:text="X"
android:textSize="24sp" />

<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"
/>
android:id="@+id/videoView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_marginStart="0dp"
android:layout_marginTop="0dp"
android:layout_marginEnd="0dp"
android:layout_marginBottom="0dp"
android:onClick="onClick"
android:padding="0dp" />
</RelativeLayout>
15 changes: 14 additions & 1 deletion example/app/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { View, Text } from 'react-native';
import { View, Text, Button } from 'react-native';
import VideoPlayer from 'react-native-video-player';

const VIMEO_ID = '179859217';
Expand Down Expand Up @@ -37,6 +37,19 @@ export default class App extends Component {
videoHeight={this.state.video.height}
duration={this.state.video.duration/* I'm using a hls stream here, react-native-video
can't figure out the length, so I pass it here from the vimeo config */}
ref={r => this.player = r}
/>
<Button
onPress={() => this.player.stop()}
title="Stop"
/>
<Button
onPress={() => this.player.pause()}
title="Pause"
/>
<Button
onPress={() => this.player.resume()}
title="Resume"
/>
</View>
);
Expand Down
Loading