mirror of
https://github.com/jellyfin/jellyfin-android.git
synced 2026-09-03 05:10:27 +03:00
Merge pull request #53 from jellyfin/pip
Support Picture-in-Picture in ExoPlayer
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
android:name=".player.PlayerActivity"
|
||||
android:launchMode="singleTop"
|
||||
android:screenOrientation="sensorLandscape"
|
||||
android:supportsPictureInPicture="true"
|
||||
android:theme="@style/AppTheme.Player" />
|
||||
|
||||
<activity
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package org.jellyfin.mobile.player
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.PictureInPictureParams
|
||||
import android.content.Intent
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.content.res.Configuration
|
||||
import android.os.Bundle
|
||||
import android.os.Message
|
||||
import android.os.Messenger
|
||||
import android.os.RemoteException
|
||||
import android.os.*
|
||||
import android.view.*
|
||||
import android.widget.ImageButton
|
||||
import android.widget.TextView
|
||||
@@ -99,6 +97,11 @@ class PlayerActivity : AppCompatActivity() {
|
||||
titleTextView.text = jellyfinMediaSource.title
|
||||
}
|
||||
|
||||
// Disable controller in PiP
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && isInPictureInPictureMode) {
|
||||
playerView.useController = false
|
||||
}
|
||||
|
||||
// Handle current orientation and update fullscreen state
|
||||
restoreFullscreenState()
|
||||
setupFullscreenSwitcher()
|
||||
@@ -248,6 +251,16 @@ class PlayerActivity : AppCompatActivity() {
|
||||
return viewModel.mediaSourceManager.selectSubtitle(index)
|
||||
}
|
||||
|
||||
override fun onUserLeaveHint() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && viewModel.playerOrNull?.isPlaying == true) {
|
||||
enterPictureInPictureMode(PictureInPictureParams.Builder().build())
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration) {
|
||||
playerView.useController = !isInPictureInPictureMode
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
orientationListener.disable()
|
||||
|
||||
Reference in New Issue
Block a user