Fix player not working after quitting from notification
This commit is contained in:
parent
bc04472b6f
commit
b971dbbe4b
4 changed files with 10 additions and 12 deletions
|
@ -99,7 +99,8 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play
|
||||||
override fun onStateChanged(bottomSheet: View, newState: Int) {
|
override fun onStateChanged(bottomSheet: View, newState: Int) {
|
||||||
when (newState) {
|
when (newState) {
|
||||||
STATE_EXPANDED,
|
STATE_EXPANDED,
|
||||||
STATE_DRAGGING -> {
|
STATE_DRAGGING,
|
||||||
|
-> {
|
||||||
mainActivity.getBottomSheetBehavior().isDraggable = false
|
mainActivity.getBottomSheetBehavior().isDraggable = false
|
||||||
}
|
}
|
||||||
STATE_COLLAPSED -> {
|
STATE_COLLAPSED -> {
|
||||||
|
@ -312,7 +313,6 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play
|
||||||
super.onServiceConnected()
|
super.onServiceConnected()
|
||||||
updateSong()
|
updateSong()
|
||||||
updatePlayPauseDrawableState()
|
updatePlayPauseDrawableState()
|
||||||
updatePlayPauseDrawableState()
|
|
||||||
updateQueue()
|
updateQueue()
|
||||||
updateIsFavoriteIcon()
|
updateIsFavoriteIcon()
|
||||||
}
|
}
|
||||||
|
@ -379,15 +379,17 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play
|
||||||
|
|
||||||
private fun setUpPlayPauseFab() {
|
private fun setUpPlayPauseFab() {
|
||||||
binding.playbackControlsFragment.playPauseButton.setOnClickListener(
|
binding.playbackControlsFragment.playPauseButton.setOnClickListener(
|
||||||
PlayPauseButtonOnClickHandler()
|
PlayPauseButtonOnClickHandler())
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
private fun setUpPrevNext() {
|
private fun setUpPrevNext() {
|
||||||
updatePrevNextColor()
|
updatePrevNextColor()
|
||||||
binding.playbackControlsFragment.nextButton.setOnTouchListener(MusicSeekSkipTouchListener(requireActivity(), true))
|
binding.playbackControlsFragment.nextButton.setOnTouchListener(MusicSeekSkipTouchListener(
|
||||||
binding.playbackControlsFragment.previousButton.setOnTouchListener(MusicSeekSkipTouchListener(requireActivity(), false))
|
requireActivity(),
|
||||||
|
true))
|
||||||
|
binding.playbackControlsFragment.previousButton.setOnTouchListener(
|
||||||
|
MusicSeekSkipTouchListener(requireActivity(), false))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updatePrevNextColor() {
|
private fun updatePrevNextColor() {
|
||||||
|
@ -469,7 +471,7 @@ class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_play
|
||||||
oldLeft: Int,
|
oldLeft: Int,
|
||||||
oldTop: Int,
|
oldTop: Int,
|
||||||
oldRight: Int,
|
oldRight: Int,
|
||||||
oldBottom: Int
|
oldBottom: Int,
|
||||||
) {
|
) {
|
||||||
val panel = getQueuePanel()
|
val panel = getQueuePanel()
|
||||||
if (panel.state == STATE_COLLAPSED) {
|
if (panel.state == STATE_COLLAPSED) {
|
||||||
|
|
|
@ -851,7 +851,6 @@ class MusicService : MediaBrowserServiceCompat(),
|
||||||
stopForeground(true)
|
stopForeground(true)
|
||||||
isForeground = false
|
isForeground = false
|
||||||
notificationManager?.cancel(PlayingNotification.NOTIFICATION_ID)
|
notificationManager?.cancel(PlayingNotification.NOTIFICATION_ID)
|
||||||
playbackManager.release()
|
|
||||||
AudioManagerCompat.abandonAudioFocusRequest(audioManager!!,
|
AudioManagerCompat.abandonAudioFocusRequest(audioManager!!,
|
||||||
AudioFocusRequestCompat.Builder(AudioManagerCompat.AUDIOFOCUS_GAIN)
|
AudioFocusRequestCompat.Builder(AudioManagerCompat.AUDIOFOCUS_GAIN)
|
||||||
.setOnAudioFocusChangeListener(audioFocusListener)
|
.setOnAudioFocusChangeListener(audioFocusListener)
|
||||||
|
|
|
@ -118,9 +118,7 @@ class PlaybackManager(val context: Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun release() {
|
fun release() {
|
||||||
if (playback != null) {
|
|
||||||
playback?.release()
|
playback?.release()
|
||||||
}
|
|
||||||
playback = null
|
playback = null
|
||||||
closeAudioEffectSession()
|
closeAudioEffectSession()
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ class ThrottledSeekHandler(
|
||||||
|
|
||||||
fun notifySeek() {
|
fun notifySeek() {
|
||||||
musicService.updateMediaSessionPlaybackState()
|
musicService.updateMediaSessionPlaybackState()
|
||||||
musicService.updateMediaSessionMetaData()
|
|
||||||
handler.removeCallbacks(this)
|
handler.removeCallbacks(this)
|
||||||
handler.postDelayed(this, THROTTLE)
|
handler.postDelayed(this, THROTTLE)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue