Skip to content

Commit f097368

Browse files
Removed JS fullscreening for Android
1 parent c9096d1 commit f097368

File tree

7 files changed

+5
-121
lines changed

7 files changed

+5
-121
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- Added `preferredForwardBufferDuration` (iOS) - the duration the player should buffer media from the network ahead of the playhead to guard against playback disruption. (#1944)
1010
- Added `currentPlaybackTime` (Android ExoPlayer, iOS) - when playing an HLS live stream with a `EXT-X-PROGRAM-DATE-TIME` tag configured, then this property will contain the epoch value in msec. (#1944)
1111
- Added `trackId` (Android ExoPlayer) - Configure an identifier for the video stream to link the playback context to the events emitted. (#1944)
12+
- Reverted the JS fullscreening for Android. [#2013](https://github.com/react-native-community/react-native-video/pull/2013)
1213

1314
### Version 5.1.0-alpha5
1415

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ Controls whether the player enters fullscreen on play.
455455
* **false (default)** - Don't display the video in fullscreen
456456
* **true** - Display the video in fullscreen
457457

458-
Platforms: iOS, Android Exoplayer
458+
Platforms: iOS
459459

460460
#### fullscreenAutorotate
461461
If a preferred [fullscreenOrientation](#fullscreenorientation) is set, causes the video to rotate to that orientation but permits rotation of the screen to orientation held by user. Defaults to TRUE.
@@ -468,8 +468,6 @@ Platforms: iOS
468468
* **landscape**
469469
* **portrait**
470470

471-
Note on Android ExoPlayer, the full-screen mode by default goes into landscape mode. Exiting from the full-screen mode will display the video in Initial orientation.
472-
473471
Platforms: iOS
474472

475473
#### headers

Video.js

+2-48
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Component } from 'react';
22
import PropTypes from 'prop-types';
3-
import { StyleSheet, requireNativeComponent, NativeModules, View, ViewPropTypes, Image, Platform, UIManager, findNodeHandle, Dimensions } from 'react-native';
3+
import { StyleSheet, requireNativeComponent, NativeModules, View, ViewPropTypes, Image, Platform, findNodeHandle } from 'react-native';
44
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
55
import TextTrackType from './TextTrackType';
66
import FilterType from './FilterType';
@@ -21,34 +21,7 @@ export default class Video extends Component {
2121

2222
this.state = {
2323
showPoster: !!props.poster,
24-
androidFullScreen: false,
25-
videoContainerLayout_x: 0,
26-
videoContainerLayout_y: 0,
2724
};
28-
this.getDimension();
29-
}
30-
31-
/**
32-
* @description this is will set the width and height needs to be considered for full screen
33-
*/
34-
getDimension() {
35-
if (Dimensions.get('window').width < Dimensions.get('window').height) {
36-
this.width = Math.round(Dimensions.get('window').height);
37-
this.height = Math.round(Dimensions.get('window').width);
38-
}
39-
else {
40-
this.width = Math.round(Dimensions.get('window').width);
41-
this.height = Math.round(Dimensions.get('window').height);
42-
}
43-
}
44-
45-
componentDidMount() {
46-
UIManager.measure(findNodeHandle(this._videoContainer), (x, y) => {
47-
this.setState({
48-
videoContainerLayout_x: x,
49-
videoContainerLayout_y: y,
50-
});
51-
});
5225
}
5326

5427
setNativeProps(nativeProps) {
@@ -172,7 +145,6 @@ export default class Video extends Component {
172145
};
173146

174147
_onFullscreenPlayerWillPresent = (event) => {
175-
Platform.OS === 'android' && this.setState({ androidFullScreen: true });
176148
if (this.props.onFullscreenPlayerWillPresent) {
177149
this.props.onFullscreenPlayerWillPresent(event.nativeEvent);
178150
}
@@ -185,7 +157,6 @@ export default class Video extends Component {
185157
};
186158

187159
_onFullscreenPlayerWillDismiss = (event) => {
188-
Platform.OS === 'android' && this.setState({ androidFullScreen: false });
189160
if (this.props.onFullscreenPlayerWillDismiss) {
190161
this.props.onFullscreenPlayerWillDismiss(event.nativeEvent);
191162
}
@@ -342,25 +313,8 @@ export default class Video extends Component {
342313
resizeMode: this.props.posterResizeMode || 'contain',
343314
};
344315

345-
//androidFullScreen property will only impact on android. It will be always false for iOS.
346-
const videoStyle = this.state.androidFullScreen ? {
347-
position: 'absolute',
348-
top: 0,
349-
left: 0,
350-
width: this.width,
351-
height: this.height,
352-
backgroundColor: '#ffffff',
353-
justifyContent: 'center',
354-
zIndex: 99999,
355-
marginTop: -1 * (this.state.videoContainerLayout_y ? parseFloat(this.state.videoContainerLayout_y) : 0), //margin: 0 - is not working properly. So, updated all the margin individually with 0.
356-
marginLeft: -1 * (this.state.videoContainerLayout_x ? parseFloat(this.state.videoContainerLayout_x) : 0),
357-
} : {};
358-
359316
return (
360-
<View ref={(videoContainer) => {
361-
this._videoContainer = videoContainer;
362-
return videoContainer;
363-
}} style={[nativeProps.style, videoStyle]}>
317+
<View style={nativeProps.style}>
364318
<RCTVideo
365319
ref={this._assignRoot}
366320
{...nativeProps}

android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java

+1-54
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import android.annotation.SuppressLint;
44
import android.app.Activity;
55
import android.content.Context;
6-
import android.content.pm.ActivityInfo;
76
import android.media.AudioManager;
87
import android.net.Uri;
98
import android.os.Handler;
@@ -15,7 +14,6 @@
1514
import android.view.accessibility.CaptioningManager;
1615
import android.widget.FrameLayout;
1716
import android.widget.ImageButton;
18-
import android.widget.ImageView;
1917

2018
import com.brentvatne.react.R;
2119
import com.brentvatne.receiver.AudioBecomingNoisyReceiver;
@@ -101,7 +99,6 @@ class ReactExoplayerView extends FrameLayout implements
10199
private Player.EventListener eventListener;
102100

103101
private ExoPlayerView exoPlayerView;
104-
private int initialOrientation;
105102

106103
private DataSource.Factory mediaDataSourceFactory;
107104
private SimpleExoPlayer player;
@@ -182,7 +179,6 @@ public double getPositionInFirstPeriodMsForCurrentWindow(long currentPosition) {
182179
public ReactExoplayerView(ThemedReactContext context, ReactExoplayerConfig config) {
183180
super(context);
184181
this.themedReactContext = context;
185-
this.initialOrientation = getResources().getConfiguration().orientation;
186182
this.eventEmitter = new VideoEventEmitter(context);
187183
this.config = config;
188184
this.bandwidthMeter = config.getBandwidthMeter();
@@ -335,16 +331,6 @@ public void onClick(View v) {
335331
}
336332
});
337333

338-
//Handling the fullScreenButton click event
339-
FrameLayout fullScreenButton = playerControlView.findViewById(R.id.exo_fullscreen_button);
340-
fullScreenButton.setOnClickListener(new View.OnClickListener() {
341-
@Override
342-
public void onClick(View v) {
343-
setFullscreen(!isFullscreen);
344-
}
345-
});
346-
updateFullScreenIcon(isFullscreen);
347-
348334
// Invoking onPlayerStateChanged event for Player
349335
eventListener = new Player.EventListener() {
350336
@Override
@@ -373,33 +359,6 @@ private void addPlayerControl() {
373359
addView(playerControlView, 1, layoutParams);
374360
}
375361

376-
/**
377-
* Update fullscreen icon
378-
*/
379-
private void updateFullScreenIcon(Boolean fullScreen) {
380-
if(playerControlView != null && player != null) {
381-
//Play the video whenever the user clicks minimize or maximise button. In order to enable the controls
382-
player.setPlayWhenReady(!isPaused);
383-
ImageView fullScreenIcon = playerControlView.findViewById(R.id.exo_fullscreen_icon);
384-
if (fullScreen) {
385-
fullScreenIcon.setImageResource(R.drawable.fullscreen_shrink);
386-
} else {
387-
fullScreenIcon.setImageResource(R.drawable.fullscreen_expand);
388-
}
389-
}
390-
}
391-
392-
/**
393-
* Enable or Disable fullscreen button
394-
*/
395-
private void enableFullScreenButton(Boolean enable) {
396-
if(playerControlView != null) {
397-
FrameLayout fullScreenButton = playerControlView.findViewById(R.id.exo_fullscreen_button);
398-
fullScreenButton.setAlpha(enable ? 1.0f : 0.5f);
399-
fullScreenButton.setEnabled(enable);
400-
}
401-
}
402-
403362
/**
404363
* Update the layout
405364
* @param view view needs to update layout
@@ -625,13 +584,10 @@ private void stopPlayback() {
625584

626585
private void onStopPlayback() {
627586
if (isFullscreen) {
628-
//When the video stopPlayback.
629-
//If the video is in fullscreen, then we will update the video to normal mode.
630-
setFullscreen(!isFullscreen);
587+
setFullscreen(false);
631588
}
632589
setKeepScreenOn(false);
633590
audioManager.abandonAudioFocus(this);
634-
enableFullScreenButton(false);
635591
}
636592

637593
private void updateResumePosition() {
@@ -730,7 +686,6 @@ public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
730686
if (playerControlView != null) {
731687
playerControlView.show();
732688
}
733-
enableFullScreenButton(true);
734689
break;
735690
case Player.STATE_ENDED:
736691
text += "ended";
@@ -1249,8 +1204,6 @@ public void setFullscreen(boolean fullscreen) {
12491204
if (fullscreen == isFullscreen) {
12501205
return; // Avoid generating events when nothing is changing
12511206
}
1252-
1253-
updateFullScreenIcon(fullscreen);
12541207
isFullscreen = fullscreen;
12551208

12561209
Activity activity = themedReactContext.getCurrentActivity();
@@ -1269,17 +1222,11 @@ public void setFullscreen(boolean fullscreen) {
12691222
uiOptions = SYSTEM_UI_FLAG_HIDE_NAVIGATION
12701223
| SYSTEM_UI_FLAG_FULLSCREEN;
12711224
}
1272-
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
12731225
eventEmitter.fullscreenWillPresent();
12741226
decorView.setSystemUiVisibility(uiOptions);
12751227
eventEmitter.fullscreenDidPresent();
12761228
} else {
12771229
uiOptions = View.SYSTEM_UI_FLAG_VISIBLE;
1278-
//orientation, 1 is for Portrait and 2 for Landscape.
1279-
if(this.initialOrientation == 1)
1280-
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
1281-
else
1282-
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
12831230
eventEmitter.fullscreenWillDismiss();
12841231
decorView.setSystemUiVisibility(uiOptions);
12851232
eventEmitter.fullscreenDidDismiss();
Binary file not shown.
Binary file not shown.

android-exoplayer/src/main/res/layout/exo_player_control_view.xml

-16
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,6 @@
7171
android:paddingRight="4dp"
7272
android:includeFontPadding="false"
7373
android:textColor="#FFBEBEBE"/>
74-
<FrameLayout
75-
android:id="@+id/exo_fullscreen_button"
76-
android:layout_width="32dp"
77-
android:layout_height="32dp"
78-
android:layout_gravity="right">
79-
80-
<ImageView
81-
android:id="@+id/exo_fullscreen_icon"
82-
android:layout_width="18dp"
83-
android:layout_height="18dp"
84-
android:layout_gravity="center"
85-
android:adjustViewBounds="true"
86-
android:scaleType="fitCenter"
87-
android:src="@drawable/fullscreen_expand"/>
88-
89-
</FrameLayout>
9074
</LinearLayout>
9175

9276
</LinearLayout>

0 commit comments

Comments
 (0)