add fullscreenOrientation
This commit is contained in:
parent
0b7ea71d77
commit
5fe76574bb
@ -469,7 +469,7 @@ Platforms: iOS
|
|||||||
* **landscape**
|
* **landscape**
|
||||||
* **portrait**
|
* **portrait**
|
||||||
|
|
||||||
Platforms: iOS
|
Platforms: Android ExoPlayer, iOS
|
||||||
|
|
||||||
#### headers
|
#### headers
|
||||||
Pass headers to the HTTP client. Can be used for authorization. Headers must be a part of the source object.
|
Pass headers to the HTTP client. Can be used for authorization. Headers must be a part of the source object.
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.brentvatne.exoplayer;
|
package com.brentvatne.exoplayer;
|
||||||
|
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -14,6 +15,7 @@ import com.google.android.exoplayer2.ui.PlayerControlView;
|
|||||||
|
|
||||||
public class ExoPlayerFullscreenVideoActivity extends AppCompatActivity implements ReactExoplayerView.FullScreenDelegate {
|
public class ExoPlayerFullscreenVideoActivity extends AppCompatActivity implements ReactExoplayerView.FullScreenDelegate {
|
||||||
public static final String EXTRA_ID = "extra_id";
|
public static final String EXTRA_ID = "extra_id";
|
||||||
|
public static final String EXTRA_ORIENTATION = "extra_orientation";
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private PlayerControlView playerControlView;
|
private PlayerControlView playerControlView;
|
||||||
@ -22,8 +24,14 @@ public class ExoPlayerFullscreenVideoActivity extends AppCompatActivity implemen
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.exo_player_fullscreen_video);
|
|
||||||
id = getIntent().getIntExtra(EXTRA_ID, -1);
|
id = getIntent().getIntExtra(EXTRA_ID, -1);
|
||||||
|
String orientation = getIntent().getStringExtra(EXTRA_ORIENTATION);
|
||||||
|
if ("landscape".equals(orientation)) {
|
||||||
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
|
||||||
|
} else if ("portrait".equals(orientation)) {
|
||||||
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
|
||||||
|
}
|
||||||
|
setContentView(R.layout.exo_player_fullscreen_video);
|
||||||
player = ReactExoplayerView.getViewInstance(id).getPlayer();
|
player = ReactExoplayerView.getViewInstance(id).getPlayer();
|
||||||
|
|
||||||
ExoPlayerView playerView = findViewById(R.id.player_view);
|
ExoPlayerView playerView = findViewById(R.id.player_view);
|
||||||
@ -54,20 +62,18 @@ public class ExoPlayerFullscreenVideoActivity extends AppCompatActivity implemen
|
|||||||
super.onResume();
|
super.onResume();
|
||||||
boolean isPaused = ReactExoplayerView.getViewInstance(id).isPaused();
|
boolean isPaused = ReactExoplayerView.getViewInstance(id).isPaused();
|
||||||
player.setPlayWhenReady(!isPaused);
|
player.setPlayWhenReady(!isPaused);
|
||||||
ReactExoplayerView.getViewInstance(id).registerFullScreenDelegate(this);
|
if (ReactExoplayerView.getViewInstance(id) != null) {
|
||||||
|
ReactExoplayerView.getViewInstance(id).registerFullScreenDelegate(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
player.setPlayWhenReady(false);
|
player.setPlayWhenReady(false);
|
||||||
ReactExoplayerView.getViewInstance(id).registerFullScreenDelegate(null);
|
if (ReactExoplayerView.getViewInstance(id) != null) {
|
||||||
}
|
ReactExoplayerView.getViewInstance(id).registerFullScreenDelegate(null);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
ReactExoplayerView.getViewInstance(id).removeViewInstance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -81,8 +87,11 @@ public class ExoPlayerFullscreenVideoActivity extends AppCompatActivity implemen
|
|||||||
@Override
|
@Override
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
if ((keyCode == KeyEvent.KEYCODE_BACK)) {
|
if ((keyCode == KeyEvent.KEYCODE_BACK)) {
|
||||||
ReactExoplayerView.getViewInstance(id).setFullscreen(false);
|
if (ReactExoplayerView.getViewInstance(id) != null) {
|
||||||
return false;
|
ReactExoplayerView.getViewInstance(id).setFullscreen(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
}
|
}
|
||||||
|
@ -114,6 +114,7 @@ class ReactExoplayerView extends FrameLayout implements
|
|||||||
private long resumePosition;
|
private long resumePosition;
|
||||||
private boolean loadVideoStarted;
|
private boolean loadVideoStarted;
|
||||||
private boolean isFullscreen;
|
private boolean isFullscreen;
|
||||||
|
private String fullScreenOrientation;
|
||||||
private boolean isInBackground;
|
private boolean isInBackground;
|
||||||
private boolean isPaused;
|
private boolean isPaused;
|
||||||
private boolean isBuffering;
|
private boolean isBuffering;
|
||||||
@ -266,6 +267,7 @@ class ReactExoplayerView extends FrameLayout implements
|
|||||||
|
|
||||||
public void cleanUpResources() {
|
public void cleanUpResources() {
|
||||||
stopPlayback();
|
stopPlayback();
|
||||||
|
instances.remove(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
//BandwidthMeter.EventListener implementation
|
//BandwidthMeter.EventListener implementation
|
||||||
@ -300,10 +302,6 @@ class ReactExoplayerView extends FrameLayout implements
|
|||||||
this.fullScreenDelegate = delegate;
|
this.fullScreenDelegate = delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeViewInstance() {
|
|
||||||
instances.remove(uid);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Internal methods
|
// Internal methods
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -323,6 +321,7 @@ class ReactExoplayerView extends FrameLayout implements
|
|||||||
instances.put(uid, this);
|
instances.put(uid, this);
|
||||||
Intent intent = new Intent(getContext(), ExoPlayerFullscreenVideoActivity.class);
|
Intent intent = new Intent(getContext(), ExoPlayerFullscreenVideoActivity.class);
|
||||||
intent.putExtra(ExoPlayerFullscreenVideoActivity.EXTRA_ID, this.uid);
|
intent.putExtra(ExoPlayerFullscreenVideoActivity.EXTRA_ID, this.uid);
|
||||||
|
intent.putExtra(ExoPlayerFullscreenVideoActivity.EXTRA_ORIENTATION, this.fullScreenOrientation);
|
||||||
getContext().startActivity(intent);
|
getContext().startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1268,6 +1267,10 @@ class ReactExoplayerView extends FrameLayout implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFullscreenOrientation(String orientation) {
|
||||||
|
this.fullScreenOrientation = orientation;
|
||||||
|
}
|
||||||
|
|
||||||
public void setUseTextureView(boolean useTextureView) {
|
public void setUseTextureView(boolean useTextureView) {
|
||||||
exoPlayerView.setUseTextureView(useTextureView);
|
exoPlayerView.setUseTextureView(useTextureView);
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
|
|||||||
private static final String PROP_PLAY_IN_BACKGROUND = "playInBackground";
|
private static final String PROP_PLAY_IN_BACKGROUND = "playInBackground";
|
||||||
private static final String PROP_DISABLE_FOCUS = "disableFocus";
|
private static final String PROP_DISABLE_FOCUS = "disableFocus";
|
||||||
private static final String PROP_FULLSCREEN = "fullscreen";
|
private static final String PROP_FULLSCREEN = "fullscreen";
|
||||||
|
private static final String PROP_FULLSCREEN_ORIENTATION = "fullscreenOrientation";
|
||||||
private static final String PROP_USE_TEXTURE_VIEW = "useTextureView";
|
private static final String PROP_USE_TEXTURE_VIEW = "useTextureView";
|
||||||
private static final String PROP_SELECTED_VIDEO_TRACK = "selectedVideoTrack";
|
private static final String PROP_SELECTED_VIDEO_TRACK = "selectedVideoTrack";
|
||||||
private static final String PROP_SELECTED_VIDEO_TRACK_TYPE = "type";
|
private static final String PROP_SELECTED_VIDEO_TRACK_TYPE = "type";
|
||||||
@ -264,6 +265,11 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
|
|||||||
videoView.setFullscreen(fullscreen);
|
videoView.setFullscreen(fullscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ReactProp(name = PROP_FULLSCREEN_ORIENTATION)
|
||||||
|
public void setFullscreenOrientation(final ReactExoplayerView videoView, final String fullscreenOrientation) {
|
||||||
|
videoView.setFullscreenOrientation(fullscreenOrientation);
|
||||||
|
}
|
||||||
|
|
||||||
@ReactProp(name = PROP_USE_TEXTURE_VIEW, defaultBoolean = true)
|
@ReactProp(name = PROP_USE_TEXTURE_VIEW, defaultBoolean = true)
|
||||||
public void setUseTextureView(final ReactExoplayerView videoView, final boolean useTextureView) {
|
public void setUseTextureView(final ReactExoplayerView videoView, final boolean useTextureView) {
|
||||||
videoView.setUseTextureView(useTextureView);
|
videoView.setUseTextureView(useTextureView);
|
||||||
|
Loading…
Reference in New Issue
Block a user