Fix live stream PiP mode

Prevent splash screen when opening PiP mode

Changelog: changed
This commit is contained in:
Kai 2025-06-10 15:27:14 -05:00
commit 515c5e00e9
No known key found for this signature in database
2 changed files with 19 additions and 4 deletions

View file

@ -429,6 +429,9 @@ class VideoDetailView : ConstraintLayout {
showChaptersUI(); showChaptersUI();
}; };
_layoutPlayerContainer.addOnLayoutChangeListener { v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom ->
onShouldEnterPictureInPictureChanged.emit()
}
_buttonSubscribe.onSubscribed.subscribe { _buttonSubscribe.onSubscribed.subscribe {
_slideUpOverlay = UISlideOverlays.showSubscriptionOptionsOverlay(it, _overlayContainer); _slideUpOverlay = UISlideOverlays.showSubscriptionOptionsOverlay(it, _overlayContainer);
@ -2746,6 +2749,7 @@ class VideoDetailView : ConstraintLayout {
_overlayContainer.removeAllViews(); _overlayContainer.removeAllViews();
_overlay_quality_selector?.hide(); _overlay_quality_selector?.hide();
_container_content.visibility = GONE
_player.fillHeight(false) _player.fillHeight(false)
_layoutPlayerContainer.setPadding(0, 0, 0, 0); _layoutPlayerContainer.setPadding(0, 0, 0, 0);
@ -2754,11 +2758,16 @@ class VideoDetailView : ConstraintLayout {
Logger.i(TAG, "handleLeavePictureInPicture") Logger.i(TAG, "handleLeavePictureInPicture")
if(!_player.isFullScreen) { if(!_player.isFullScreen) {
_container_content.visibility = VISIBLE
_player.fitHeight(); _player.fitHeight();
_layoutPlayerContainer.setPadding(0, 0, 0, TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 6.0f, Resources.getSystem().displayMetrics).toInt()); _layoutPlayerContainer.setPadding(0, 0, 0, TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 6.0f, Resources.getSystem().displayMetrics).toInt());
} 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;
@ -2778,9 +2787,7 @@ class VideoDetailView : ConstraintLayout {
videoSourceWidth = 9; videoSourceWidth = 9;
} }
val r = Rect(); val r = _player.getVideoRect()
_player.getGlobalVisibleRect(r);
r.right = r.right - _player.paddingEnd;
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
@ -2789,7 +2796,8 @@ class VideoDetailView : ConstraintLayout {
val toBackgroundAction = RemoteAction(Icon.createWithResource(context, R.drawable.ic_screen_share), context.getString(R.string.background), context.getString(R.string.background_switch_audio), MediaControlReceiver.getToBackgroundIntent(context, 7)); val toBackgroundAction = RemoteAction(Icon.createWithResource(context, R.drawable.ic_screen_share), context.getString(R.string.background), context.getString(R.string.background_switch_audio), MediaControlReceiver.getToBackgroundIntent(context, 7));
val params = PictureInPictureParams.Builder() val params = PictureInPictureParams.Builder()
.setAspectRatio(Rational(videoSourceWidth, videoSourceHeight)).setSourceRectHint(r) .setAspectRatio(Rational(videoSourceWidth, videoSourceHeight))
.setSourceRectHint(r)
.setActions(listOf(toBackgroundAction, playpauseAction)) .setActions(listOf(toBackgroundAction, playpauseAction))
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {

View file

@ -4,6 +4,7 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.res.Resources import android.content.res.Resources
import android.graphics.Color import android.graphics.Color
import android.graphics.Rect
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.media.AudioManager import android.media.AudioManager
import android.net.Uri import android.net.Uri
@ -464,6 +465,12 @@ class FutoVideoPlayer : FutoVideoPlayerBase {
_control_autoplay_fullscreen.setColorFilter(ContextCompat.getColor(context, if (StatePlayer.instance.autoplay) com.futo.futopay.R.color.primary else R.color.white)) _control_autoplay_fullscreen.setColorFilter(ContextCompat.getColor(context, if (StatePlayer.instance.autoplay) com.futo.futopay.R.color.primary else R.color.white))
} }
fun getVideoRect(): Rect {
val r = Rect()
_videoView.getGlobalVisibleRect(r)
return r
}
private fun setSystemBrightness(brightness: Float) { private fun setSystemBrightness(brightness: Float) {
Log.i(TAG, "setSystemBrightness $brightness") Log.i(TAG, "setSystemBrightness $brightness")
if (android.provider.Settings.System.canWrite(context)) { if (android.provider.Settings.System.canWrite(context)) {