Я создаю приложение для проигрывателя мультимедиа и хочу, чтобы картинка была в картинке. Моя проблема заключается в том, что всякий раз, когда я вхожу в PIP, активность игрока отделяется от предыдущей активности и т. Д.
Снимок экрана: несколько задач
Вот мое объявление активности:
<activity
android:name=".ui.player.PlayerActivity"
android:allowTaskReparenting="true"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:exported="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/player"
android:launchMode="singleTask"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsPictureInPicture="true">
Вот код, который я использую для ввода PIP:
override fun onUserLeaveHint() {
enterPictureInPicture()
}
private fun enterPictureInPicture() {
val player = manager.currentPlayer
if (player is SimpleExoPlayer) {
val format = player.videoFormat
val params = PictureInPictureParams.Builder()
.setAspectRatio(format?.let { Rational(it.width, it.height) } ?: Rational(16, 9))
.build()
enterPictureInPictureMode(params)
}
}