Removed JS fullscreening for Android (#2013)
This commit is contained in:
		| @@ -3,7 +3,6 @@ package com.brentvatne.exoplayer; | ||||
| import android.annotation.SuppressLint; | ||||
| import android.app.Activity; | ||||
| import android.content.Context; | ||||
| import android.content.pm.ActivityInfo; | ||||
| import android.media.AudioManager; | ||||
| import android.net.Uri; | ||||
| import android.os.Handler; | ||||
| @@ -15,7 +14,6 @@ import android.view.Window; | ||||
| import android.view.accessibility.CaptioningManager; | ||||
| import android.widget.FrameLayout; | ||||
| import android.widget.ImageButton; | ||||
| import android.widget.ImageView; | ||||
|  | ||||
| import com.brentvatne.react.R; | ||||
| import com.brentvatne.receiver.AudioBecomingNoisyReceiver; | ||||
| @@ -101,7 +99,6 @@ class ReactExoplayerView extends FrameLayout implements | ||||
|     private Player.EventListener eventListener; | ||||
|  | ||||
|     private ExoPlayerView exoPlayerView; | ||||
|     private int initialOrientation; | ||||
|  | ||||
|     private DataSource.Factory mediaDataSourceFactory; | ||||
|     private SimpleExoPlayer player; | ||||
| @@ -182,7 +179,6 @@ class ReactExoplayerView extends FrameLayout implements | ||||
|     public ReactExoplayerView(ThemedReactContext context, ReactExoplayerConfig config) { | ||||
|         super(context); | ||||
|         this.themedReactContext = context; | ||||
|         this.initialOrientation = getResources().getConfiguration().orientation; | ||||
|         this.eventEmitter = new VideoEventEmitter(context); | ||||
|         this.config = config; | ||||
|         this.bandwidthMeter = config.getBandwidthMeter(); | ||||
| @@ -335,16 +331,6 @@ class ReactExoplayerView extends FrameLayout implements | ||||
|             } | ||||
|         }); | ||||
|  | ||||
|         //Handling the fullScreenButton click event | ||||
|         FrameLayout fullScreenButton = playerControlView.findViewById(R.id.exo_fullscreen_button); | ||||
|         fullScreenButton.setOnClickListener(new View.OnClickListener() { | ||||
|             @Override | ||||
|             public void onClick(View v) { | ||||
|                 setFullscreen(!isFullscreen); | ||||
|             } | ||||
|         }); | ||||
|         updateFullScreenIcon(isFullscreen); | ||||
|  | ||||
|         // Invoking onPlayerStateChanged event for Player | ||||
|         eventListener = new Player.EventListener() { | ||||
|             @Override | ||||
| @@ -373,33 +359,6 @@ class ReactExoplayerView extends FrameLayout implements | ||||
|         addView(playerControlView, 1, layoutParams); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Update fullscreen icon | ||||
|      */ | ||||
|     private void updateFullScreenIcon(Boolean fullScreen) { | ||||
|         if(playerControlView != null && player != null) { | ||||
|             //Play the video whenever the user clicks minimize or maximise button. In order to enable the controls | ||||
|             player.setPlayWhenReady(!isPaused); | ||||
|             ImageView fullScreenIcon = playerControlView.findViewById(R.id.exo_fullscreen_icon); | ||||
|             if (fullScreen) { | ||||
|                 fullScreenIcon.setImageResource(R.drawable.fullscreen_shrink); | ||||
|             } else { | ||||
|                 fullScreenIcon.setImageResource(R.drawable.fullscreen_expand); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Enable or Disable fullscreen button | ||||
|      */ | ||||
|     private void enableFullScreenButton(Boolean enable) { | ||||
|         if(playerControlView != null) { | ||||
|             FrameLayout fullScreenButton = playerControlView.findViewById(R.id.exo_fullscreen_button); | ||||
|             fullScreenButton.setAlpha(enable ? 1.0f : 0.5f); | ||||
|             fullScreenButton.setEnabled(enable); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Update the layout | ||||
|      * @param view  view needs to update layout | ||||
| @@ -625,13 +584,10 @@ class ReactExoplayerView extends FrameLayout implements | ||||
|  | ||||
|     private void onStopPlayback() { | ||||
|         if (isFullscreen) { | ||||
|             //When the video stopPlayback. | ||||
|             //If the video is in fullscreen, then we will update the video to normal mode. | ||||
|             setFullscreen(!isFullscreen); | ||||
|             setFullscreen(false); | ||||
|         } | ||||
|         setKeepScreenOn(false); | ||||
|         audioManager.abandonAudioFocus(this); | ||||
|         enableFullScreenButton(false); | ||||
|     } | ||||
|  | ||||
|     private void updateResumePosition() { | ||||
| @@ -730,7 +686,6 @@ class ReactExoplayerView extends FrameLayout implements | ||||
|                 if (playerControlView != null) { | ||||
|                     playerControlView.show(); | ||||
|                 } | ||||
|                 enableFullScreenButton(true); | ||||
|                 break; | ||||
|             case Player.STATE_ENDED: | ||||
|                 text += "ended"; | ||||
| @@ -1249,8 +1204,6 @@ class ReactExoplayerView extends FrameLayout implements | ||||
|         if (fullscreen == isFullscreen) { | ||||
|             return; // Avoid generating events when nothing is changing | ||||
|         } | ||||
|  | ||||
|         updateFullScreenIcon(fullscreen); | ||||
|         isFullscreen = fullscreen; | ||||
|  | ||||
|         Activity activity = themedReactContext.getCurrentActivity(); | ||||
| @@ -1269,17 +1222,11 @@ class ReactExoplayerView extends FrameLayout implements | ||||
|                 uiOptions = SYSTEM_UI_FLAG_HIDE_NAVIGATION | ||||
|                         | SYSTEM_UI_FLAG_FULLSCREEN; | ||||
|             } | ||||
|             activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); | ||||
|             eventEmitter.fullscreenWillPresent(); | ||||
|             decorView.setSystemUiVisibility(uiOptions); | ||||
|             eventEmitter.fullscreenDidPresent(); | ||||
|         } else { | ||||
|             uiOptions = View.SYSTEM_UI_FLAG_VISIBLE; | ||||
|             //orientation, 1 is for Portrait and 2 for Landscape. | ||||
|             if(this.initialOrientation == 1) | ||||
|                 activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); | ||||
|             else | ||||
|                 activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); | ||||
|             eventEmitter.fullscreenWillDismiss(); | ||||
|             decorView.setSystemUiVisibility(uiOptions); | ||||
|             eventEmitter.fullscreenDidDismiss(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user