Third block of fixes for review
- audio-only streams plays the same way as video streams - fullscreen mode for tablet with controls on the right place - hidden controls while swiping mini player down - mini player works better
This commit is contained in:
parent
4519dd010d
commit
e063967734
2 changed files with 27 additions and 10 deletions
|
@ -526,12 +526,7 @@ public class VideoDetailFragment
|
||||||
openChannel();
|
openChannel();
|
||||||
break;
|
break;
|
||||||
case R.id.detail_thumbnail_root_layout:
|
case R.id.detail_thumbnail_root_layout:
|
||||||
if (currentInfo.getVideoStreams().isEmpty()
|
openVideoPlayer();
|
||||||
&& currentInfo.getVideoOnlyStreams().isEmpty()) {
|
|
||||||
openBackgroundPlayer(false);
|
|
||||||
} else {
|
|
||||||
openVideoPlayer();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case R.id.detail_title_root_layout:
|
case R.id.detail_title_root_layout:
|
||||||
toggleTitleAndDescription();
|
toggleTitleAndDescription();
|
||||||
|
@ -545,6 +540,7 @@ public class VideoDetailFragment
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.onPlayPause();
|
player.onPlayPause();
|
||||||
player.hideControls(0,0);
|
player.hideControls(0,0);
|
||||||
|
showSystemUi();
|
||||||
}
|
}
|
||||||
else openVideoPlayer();
|
else openVideoPlayer();
|
||||||
|
|
||||||
|
@ -1869,9 +1865,10 @@ public class VideoDetailFragment
|
||||||
case BottomSheetBehavior.STATE_COLLAPSED:
|
case BottomSheetBehavior.STATE_COLLAPSED:
|
||||||
// Re-enable clicks
|
// Re-enable clicks
|
||||||
setOverlayElementsClickable(true);
|
setOverlayElementsClickable(true);
|
||||||
if (player != null && player.isInFullscreen()) player.toggleFullscreen();
|
if (player != null && player.isInFullscreen() && player.isPlaying()) showSystemUi();
|
||||||
break;
|
break;
|
||||||
case BottomSheetBehavior.STATE_DRAGGING:
|
case BottomSheetBehavior.STATE_DRAGGING:
|
||||||
|
if (player != null && player.isControlsVisible()) player.hideControls(0, 0);
|
||||||
break;
|
break;
|
||||||
case BottomSheetBehavior.STATE_SETTLING:
|
case BottomSheetBehavior.STATE_SETTLING:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -534,7 +534,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
if (fragmentListener == null) return;
|
if (fragmentListener == null) return;
|
||||||
|
|
||||||
isFullscreen = !isFullscreen;
|
isFullscreen = !isFullscreen;
|
||||||
setControlsWidth();
|
setControlsSize();
|
||||||
fragmentListener.onFullscreenStateChanged(isInFullscreen());
|
fragmentListener.onFullscreenStateChanged(isInFullscreen());
|
||||||
// When user presses back button in landscape mode and in fullscreen and uses ZOOM mode
|
// When user presses back button in landscape mode and in fullscreen and uses ZOOM mode
|
||||||
// a video can be larger than screen. Prevent it like this
|
// a video can be larger than screen. Prevent it like this
|
||||||
|
@ -1102,19 +1102,39 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
fragmentListener.hideSystemUIIfNeeded();
|
fragmentListener.hideSystemUIIfNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setControlsWidth() {
|
/*
|
||||||
|
* This method measures width and height of controls visible on screen. It ensures that controls will be side-by-side with
|
||||||
|
* NavigationBar and notches but not under them. Tablets have only bottom NavigationBar
|
||||||
|
* */
|
||||||
|
void setControlsSize() {
|
||||||
Point size = new Point();
|
Point size = new Point();
|
||||||
|
Display display = getRootView().getDisplay();
|
||||||
|
if (display == null) return;
|
||||||
// This method will give a correct size of a usable area of a window.
|
// This method will give a correct size of a usable area of a window.
|
||||||
// It doesn't include NavigationBar, notches, etc.
|
// It doesn't include NavigationBar, notches, etc.
|
||||||
getRootView().getDisplay().getSize(size);
|
display.getSize(size);
|
||||||
|
|
||||||
int width = isFullscreen ? size.x : ViewGroup.LayoutParams.MATCH_PARENT;
|
int width = isFullscreen ? size.x : ViewGroup.LayoutParams.MATCH_PARENT;
|
||||||
|
int gravity = isFullscreen ? (display.getRotation() == Surface.ROTATION_90 ? Gravity.START : Gravity.END) : Gravity.TOP;
|
||||||
|
|
||||||
primaryControls.getLayoutParams().width = width;
|
primaryControls.getLayoutParams().width = width;
|
||||||
|
((LinearLayout.LayoutParams) primaryControls.getLayoutParams()).gravity = gravity;
|
||||||
primaryControls.requestLayout();
|
primaryControls.requestLayout();
|
||||||
|
|
||||||
secondaryControls.getLayoutParams().width = width;
|
secondaryControls.getLayoutParams().width = width;
|
||||||
|
((LinearLayout.LayoutParams) secondaryControls.getLayoutParams()).gravity = gravity;
|
||||||
secondaryControls.requestLayout();
|
secondaryControls.requestLayout();
|
||||||
|
|
||||||
getBottomControlsRoot().getLayoutParams().width = width;
|
getBottomControlsRoot().getLayoutParams().width = width;
|
||||||
|
RelativeLayout.LayoutParams bottomParams = ((RelativeLayout.LayoutParams) getBottomControlsRoot().getLayoutParams());
|
||||||
|
bottomParams.removeRule(RelativeLayout.ALIGN_PARENT_START);
|
||||||
|
bottomParams.removeRule(RelativeLayout.ALIGN_PARENT_END);
|
||||||
|
bottomParams.addRule(gravity == Gravity.END ? RelativeLayout.ALIGN_PARENT_END : RelativeLayout.ALIGN_PARENT_START);
|
||||||
getBottomControlsRoot().requestLayout();
|
getBottomControlsRoot().requestLayout();
|
||||||
|
|
||||||
|
ViewGroup controlsRoot = getRootView().findViewById(R.id.playbackControlRoot);
|
||||||
|
controlsRoot.getLayoutParams().height = isFullscreen ? size.y : ViewGroup.LayoutParams.MATCH_PARENT;
|
||||||
|
controlsRoot.requestLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePlaybackButtons() {
|
private void updatePlaybackButtons() {
|
||||||
|
|
Loading…
Reference in a new issue