Проблемы с режимом PIPJAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Проблемы с режимом PIP

Сообщение Anonymous »

У меня есть действие, которое называется MpvActivity, я выполняю его в режиме pip, но когда я хочу завершить действие, например, пользователь нажимает на значок крестика или выбирает новое видео, все мое приложение уничтожается.
Я не знаю, почему это происходит и как мне можно завершить действие Mpv, просто предоставьте любое решение, связанное с этим
я пробовал так много методов, но все не работает
это файл манифеста здесь я начинаю действие Mpv

Код: Выделить всё

override fun onVideoItemClick(position: Int, videoPath: String, duration: Long) {
adapterVideoPosition = position
Objectsss.isVideoSelected = true
Objectsss.position = position

val intent = Intent(requireContext(), MPVActivity::class.java)
intent.putExtra("position", position)
intent.putExtra("video_title", videoAdapter.videos[position].videoName)
intent.putExtra("folder_Id", folderId)
intent.putExtra("filepath", videoAdapter.videos[position].videoPath)

if (adClass.isOtherInterAdLoaded()) {
requireContext().startActivity(intent)
if (AppConfig.mainScreenItemsInter) {
adClass.displayInterstitialAd()
}
} else {
if (!adClass.isInterAdLoading()) {
if (AppConfig.mainScreenItemsInter) {
adClass.loadDashBoardInterstitialAd()
}
}
requireContext().startActivity(intent)
}

val currentDate = Calendar.getInstance().time
val formattedDate = SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()).format(currentDate)

lifecycleScope.launch {
val videoPath = videoAdapter.videos[position].videoPath
val videoId = videoAdapter.videos[position].videoId
val videoEntity = videoPath?.let { allVideoDao.getVideoByPath(it) }

videoEntity?.let {
val currentPlayingDuration = it.currentPlayingDuration
videoPlayerViewModel.insertOrUpdateVideoPath(videoId, videoPath, position, formattedDate, duration, currentPlayingDuration)
} ?: run {
//Log.d(TAG, "Video not found in database")
}
}

val intent1 = Intent("FINISH_ACTIVITY")
LocalBroadcastManager.getInstance(requireContext()).sendBroadcast(intent1)
}
А вот мой метод Pip для кликов, с которым я справляюсь

Код: Выделить всё

 topPiPBtn.setOnClickListener { goIntoPiP() }
Это весело

Код: Выделить всё

   private fun goIntoPiP() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
return
updatePiPParams(true)
enterPictureInPictureMode()
}
вот другие методы

Код: Выделить всё

private fun updatePiPParams(force: Boolean = false) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
return
if (!isInPictureInPictureMode &&  !force)
return
val intent1 = NotificationButtonReceiver.createIntent(this, "PLAY_PAUSE")
val action1 = if (psc.pause) {
RemoteAction(
Icon.createWithResource(this, R.drawable.ic_play_arrow_black_24dp),
"Play", "", intent1
)
} else {
RemoteAction(
Icon.createWithResource(this, R.drawable.ic_pause_black_24dp),
"Pause", "", intent1
)
}

val params = with(PictureInPictureParams.Builder()) {
val aspect = player.getVideoAspect() ?: 0.0
setAspectRatio(Rational(aspect.times(10000).toInt(), 10000))
setActions(listOf(action1))
}
try {
setPictureInPictureParams(params.build())
} catch (e: IllegalArgumentException) {
// Android has some limits of what the aspect ratio can be
params.setAspectRatio(Rational(1, 1))
setPictureInPictureParams(params.build())
}
}

override fun onStop() {
super.onStop()
if (isInPictureInPictureMode) {
finish()
}
activityIsStopped = true
}

override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean) {

super.onPictureInPictureModeChanged(isInPictureInPictureMode)
if (!isInPictureInPictureMode) {

}
}

Я тоже пробовал onPictureInPictureModeChanged, но ничего не работает, такая же ситуация, что с этим делать

Подробнее здесь: https://stackoverflow.com/questions/790 ... ode-issues
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»