mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
Open audio player in PlayerFragment when starting audio mode
This commit is contained in:
parent
bc54390f31
commit
0e2400d782
@ -110,15 +110,15 @@ import com.google.android.exoplayer2.ui.StyledPlayerView
|
|||||||
import com.google.android.exoplayer2.upstream.DefaultDataSource
|
import com.google.android.exoplayer2.upstream.DefaultDataSource
|
||||||
import com.google.android.exoplayer2.util.MimeTypes
|
import com.google.android.exoplayer2.util.MimeTypes
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import java.io.IOException
|
|
||||||
import java.util.*
|
|
||||||
import java.util.concurrent.Executors
|
|
||||||
import kotlin.math.abs
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.chromium.net.CronetEngine
|
import org.chromium.net.CronetEngine
|
||||||
import retrofit2.HttpException
|
import retrofit2.HttpException
|
||||||
|
import java.io.IOException
|
||||||
|
import java.util.*
|
||||||
|
import java.util.concurrent.Executors
|
||||||
|
import kotlin.math.abs
|
||||||
|
|
||||||
class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||||
|
|
||||||
@ -350,13 +350,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
BackgroundHelper.stopBackgroundPlay(requireContext())
|
BackgroundHelper.stopBackgroundPlay(requireContext())
|
||||||
}
|
}
|
||||||
playerBinding.closeImageButton.setOnClickListener {
|
playerBinding.closeImageButton.setOnClickListener {
|
||||||
viewModel.isFullscreen.value = false
|
killFragment()
|
||||||
binding.playerMotionLayout.transitionToEnd()
|
|
||||||
val mainActivity = activity as MainActivity
|
|
||||||
mainActivity.supportFragmentManager.beginTransaction()
|
|
||||||
.remove(this)
|
|
||||||
.commit()
|
|
||||||
BackgroundHelper.stopBackgroundPlay(requireContext())
|
|
||||||
}
|
}
|
||||||
playerBinding.autoPlay.visibility = View.VISIBLE
|
playerBinding.autoPlay.visibility = View.VISIBLE
|
||||||
|
|
||||||
@ -473,6 +467,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun playOnBackground() {
|
private fun playOnBackground() {
|
||||||
|
BackgroundHelper.stopBackgroundPlay(requireContext())
|
||||||
BackgroundHelper.playOnBackground(
|
BackgroundHelper.playOnBackground(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
videoId!!,
|
videoId!!,
|
||||||
@ -480,6 +475,10 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
playlistId,
|
playlistId,
|
||||||
channelId
|
channelId
|
||||||
)
|
)
|
||||||
|
handler.postDelayed({
|
||||||
|
(activity as MainActivity).navController.navigate(R.id.audioPlayerFragment)
|
||||||
|
killFragment()
|
||||||
|
}, 500)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setFullscreen() {
|
private fun setFullscreen() {
|
||||||
@ -1520,6 +1519,15 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
return exoPlayer.isPlaying && !backgroundModeRunning
|
return exoPlayer.isPlaying && !backgroundModeRunning
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun killFragment() {
|
||||||
|
viewModel.isFullscreen.value = false
|
||||||
|
binding.playerMotionLayout.transitionToEnd()
|
||||||
|
val mainActivity = activity as MainActivity
|
||||||
|
mainActivity.supportFragmentManager.beginTransaction()
|
||||||
|
.remove(this)
|
||||||
|
.commit()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||||
super.onConfigurationChanged(newConfig)
|
super.onConfigurationChanged(newConfig)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user