Merge pull request #2714 from Bnyro/master

Fix that queue doesn't regenerate
This commit is contained in:
Bnyro 2023-01-16 15:19:26 +01:00 committed by GitHub
commit a34e113100
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -250,8 +250,11 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
context?.hideKeyboard(view) context?.hideKeyboard(view)
// reset the callbacks of the playing queue
PlayingQueue.resetToDefaults()
// clear the playing queue // clear the playing queue
if (!keepQueue) PlayingQueue.resetToDefaults() if (!keepQueue) PlayingQueue.clear()
changeOrientationMode() changeOrientationMode()
@ -340,15 +343,13 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
// actions that don't depend on video information // actions that don't depend on video information
private fun initializeOnClickActions() { private fun initializeOnClickActions() {
binding.closeImageView.setOnClickListener { binding.closeImageView.setOnClickListener {
viewModel.isMiniPlayerVisible.value = false PlayingQueue.clear()
binding.playerMotionLayout.transitionToEnd()
val mainActivity = activity as MainActivity
mainActivity.supportFragmentManager.beginTransaction()
.remove(this)
.commit()
BackgroundHelper.stopBackgroundPlay(requireContext()) BackgroundHelper.stopBackgroundPlay(requireContext())
killPlayerFragment()
} }
playerBinding.closeImageButton.setOnClickListener { playerBinding.closeImageButton.setOnClickListener {
PlayingQueue.clear()
BackgroundHelper.stopBackgroundPlay(requireContext())
killPlayerFragment() killPlayerFragment()
} }
playerBinding.autoPlay.visibility = View.VISIBLE playerBinding.autoPlay.visibility = View.VISIBLE
@ -1208,8 +1209,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
}.flatten() }.flatten()
.filter { it > 0 } .filter { it > 0 }
.sortedDescending() .sortedDescending()
.toSet() .distinct()
.toList()
return resolutions.map { return resolutions.map {
VideoResolution( VideoResolution(
@ -1358,8 +1358,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
override fun onCaptionsClicked() { override fun onCaptionsClicked() {
if (!this@PlayerFragment::streams.isInitialized || if (!this@PlayerFragment::streams.isInitialized ||
streams.subtitles == null || streams.subtitles.isNullOrEmpty()
streams.subtitles!!.isEmpty()
) { ) {
Toast.makeText(context, R.string.no_subtitles_available, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.no_subtitles_available, Toast.LENGTH_SHORT).show()
return return
@ -1374,7 +1373,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
BaseBottomSheet() BaseBottomSheet()
.setSimpleItems(subtitlesNamesList) { index -> .setSimpleItems(subtitlesNamesList) { index ->
val language = if (index > 0) subtitleCodesList[index] else null val language = subtitleCodesList.getOrNull(index)
updateCaptionsLanguage(language) updateCaptionsLanguage(language)
this.captionLanguage = language this.captionLanguage = language
} }
@ -1523,6 +1522,8 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
mainActivity.supportFragmentManager.beginTransaction() mainActivity.supportFragmentManager.beginTransaction()
.remove(this) .remove(this)
.commit() .commit()
onDestroy()
} }
override fun onConfigurationChanged(newConfig: Configuration) { override fun onConfigurationChanged(newConfig: Configuration) {