mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-08-18 00:11:22 +00:00
Merge branch 'pip-improvement' of gitlab.futo.org:videostreaming/grayjay into pip-improvement
This commit is contained in:
commit
180b320cd7
2 changed files with 17 additions and 11 deletions
|
@ -436,10 +436,6 @@ class VideoDetailView : ConstraintLayout {
|
||||||
showChaptersUI();
|
showChaptersUI();
|
||||||
};
|
};
|
||||||
|
|
||||||
_layoutPlayerContainer.addOnLayoutChangeListener { v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom ->
|
|
||||||
onShouldEnterPictureInPictureChanged.emit()
|
|
||||||
}
|
|
||||||
|
|
||||||
_title.setOnLongClickListener {
|
_title.setOnLongClickListener {
|
||||||
val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager;
|
val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager;
|
||||||
val clip = ClipData.newPlainText("Video Title", (it as TextView).text);
|
val clip = ClipData.newPlainText("Video Title", (it as TextView).text);
|
||||||
|
@ -2031,6 +2027,10 @@ class VideoDetailView : ConstraintLayout {
|
||||||
videoTrackFormats.distinctBy { it.height }.sortedByDescending { it.height },
|
videoTrackFormats.distinctBy { it.height }.sortedByDescending { it.height },
|
||||||
audioTrackFormats.distinctBy { it.bitrate }.sortedByDescending { it.bitrate });
|
audioTrackFormats.distinctBy { it.bitrate }.sortedByDescending { it.bitrate });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_layoutPlayerContainer.post {
|
||||||
|
onShouldEnterPictureInPictureChanged.emit()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var _didTriggerDatasourceErrorCount = 0;
|
private var _didTriggerDatasourceErrorCount = 0;
|
||||||
|
@ -2491,7 +2491,6 @@ class VideoDetailView : ConstraintLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
isPlaying = playing;
|
isPlaying = playing;
|
||||||
onShouldEnterPictureInPictureChanged.emit()
|
|
||||||
updateTracker(lastPositionMilliseconds, playing, true);
|
updateTracker(lastPositionMilliseconds, playing, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2625,6 +2624,9 @@ class VideoDetailView : ConstraintLayout {
|
||||||
setProgressBarOverlayed(false);
|
setProgressBarOverlayed(false);
|
||||||
}
|
}
|
||||||
onFullscreenChanged.emit(fullscreen);
|
onFullscreenChanged.emit(fullscreen);
|
||||||
|
_layoutPlayerContainer.post {
|
||||||
|
onShouldEnterPictureInPictureChanged.emit()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setCastEnabled(isCasting: Boolean) {
|
private fun setCastEnabled(isCasting: Boolean) {
|
||||||
|
@ -2899,10 +2901,6 @@ class VideoDetailView : ConstraintLayout {
|
||||||
} else {
|
} else {
|
||||||
_layoutPlayerContainer.setPadding(0, 0, 0, 0);
|
_layoutPlayerContainer.setPadding(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
_layoutPlayerContainer.post {
|
|
||||||
onShouldEnterPictureInPictureChanged.emit()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fun getPictureInPictureParams() : PictureInPictureParams {
|
fun getPictureInPictureParams() : PictureInPictureParams {
|
||||||
var videoSourceWidth = _player.exoPlayer?.player?.videoSize?.width ?: 0;
|
var videoSourceWidth = _player.exoPlayer?.player?.videoSize?.width ?: 0;
|
||||||
|
@ -2913,16 +2911,23 @@ class VideoDetailView : ConstraintLayout {
|
||||||
videoSourceHeight = 9;
|
videoSourceHeight = 9;
|
||||||
}
|
}
|
||||||
val aspectRatio = videoSourceWidth.toDouble() / videoSourceHeight;
|
val aspectRatio = videoSourceWidth.toDouble() / videoSourceHeight;
|
||||||
|
val r = _player.getVideoRect()
|
||||||
if(aspectRatio > 2.38) {
|
if(aspectRatio > 2.38) {
|
||||||
videoSourceWidth = 16;
|
videoSourceWidth = 16;
|
||||||
videoSourceHeight = 9;
|
videoSourceHeight = 9;
|
||||||
|
|
||||||
|
// shrink the left and right equally to get the rect to be 16 by 9 aspect ratio
|
||||||
|
// we don't want a picture in picture mode that's more squashed than 16 by 9
|
||||||
|
val targetWidth = r.height() * 16 / 9
|
||||||
|
val shrinkAmount = (r.width() - targetWidth) / 2
|
||||||
|
r.left += shrinkAmount
|
||||||
|
r.right -= shrinkAmount
|
||||||
}
|
}
|
||||||
else if(aspectRatio < 0.43) {
|
else if(aspectRatio < 0.43) {
|
||||||
videoSourceHeight = 16;
|
videoSourceHeight = 16;
|
||||||
videoSourceWidth = 9;
|
videoSourceWidth = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
val r = _player.getVideoRect()
|
|
||||||
val playpauseAction = if(_player.playing)
|
val playpauseAction = if(_player.playing)
|
||||||
RemoteAction(Icon.createWithResource(context, R.drawable.ic_pause_notif), context.getString(R.string.pause), context.getString(R.string.pauses_the_video), MediaControlReceiver.getPauseIntent(context, 5));
|
RemoteAction(Icon.createWithResource(context, R.drawable.ic_pause_notif), context.getString(R.string.pause), context.getString(R.string.pauses_the_video), MediaControlReceiver.getPauseIntent(context, 5));
|
||||||
else
|
else
|
||||||
|
|
|
@ -500,7 +500,8 @@ class FutoVideoPlayer : FutoVideoPlayerBase {
|
||||||
|
|
||||||
fun getVideoRect(): Rect {
|
fun getVideoRect(): Rect {
|
||||||
val r = Rect()
|
val r = Rect()
|
||||||
_videoView.getGlobalVisibleRect(r)
|
// this is the only way i could reliably get a reference to a view that matches perfectly with the video playback
|
||||||
|
_videoView.subtitleView?.getGlobalVisibleRect(r)
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue