diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5de5b92..619bf2c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,6 +12,7 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme.NoActionBar" + android:fullBackupContent="true" tools:ignore="GoogleAppIndexingWarning"> + android:supportsPictureInPicture="true" + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" + tools:targetApi="n" /> \ No newline at end of file diff --git a/app/src/main/java/net/theoks/customstreams/android/PlayerActivity.kt b/app/src/main/java/net/theoks/customstreams/android/PlayerActivity.kt index 7cdf318..0716092 100644 --- a/app/src/main/java/net/theoks/customstreams/android/PlayerActivity.kt +++ b/app/src/main/java/net/theoks/customstreams/android/PlayerActivity.kt @@ -1,8 +1,12 @@ package net.theoks.customstreams.android +import android.app.PictureInPictureParams import android.net.Uri +import android.os.Build import android.os.Bundle +import android.util.Rational import android.widget.Toast +import androidx.annotation.RequiresApi import androidx.appcompat.app.AppCompatActivity import com.google.android.exoplayer2.SimpleExoPlayer import com.google.android.exoplayer2.source.hls.HlsMediaSource @@ -43,4 +47,14 @@ class PlayerActivity : AppCompatActivity() { } super.onDestroy() } + + @RequiresApi(Build.VERSION_CODES.O) + override fun onUserLeaveHint() { + if(player.isPlaying) { + val paramsBuilder = PictureInPictureParams.Builder() + paramsBuilder.setAspectRatio(Rational(16, 9)) + enterPictureInPictureMode(paramsBuilder.build()) + } + } + } \ No newline at end of file