|
|
@ -131,6 +131,7 @@ class AudioPlayService : BaseService(), |
|
|
|
mediaPlayer.setDataSource(this, uri, analyzeUrl.headerMap) |
|
|
|
mediaPlayer.setDataSource(this, uri, analyzeUrl.headerMap) |
|
|
|
mediaPlayer.prepareAsync() |
|
|
|
mediaPlayer.prepareAsync() |
|
|
|
} catch (e: Exception) { |
|
|
|
} catch (e: Exception) { |
|
|
|
|
|
|
|
e.printStackTrace() |
|
|
|
launch { |
|
|
|
launch { |
|
|
|
toast("$url ${e.localizedMessage}") |
|
|
|
toast("$url ${e.localizedMessage}") |
|
|
|
stopSelf() |
|
|
|
stopSelf() |
|
|
@ -147,7 +148,7 @@ class AudioPlayService : BaseService(), |
|
|
|
AudioPlayService.pause = pause |
|
|
|
AudioPlayService.pause = pause |
|
|
|
handler.removeCallbacks(mpRunnable) |
|
|
|
handler.removeCallbacks(mpRunnable) |
|
|
|
position = mediaPlayer.currentPosition |
|
|
|
position = mediaPlayer.currentPosition |
|
|
|
mediaPlayer.pause() |
|
|
|
if (mediaPlayer.isPlaying) mediaPlayer.pause() |
|
|
|
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PAUSED) |
|
|
|
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PAUSED) |
|
|
|
AudioPlay.status = Status.PAUSE |
|
|
|
AudioPlay.status = Status.PAUSE |
|
|
|
postEvent(EventBus.AUDIO_STATE, Status.PAUSE) |
|
|
|
postEvent(EventBus.AUDIO_STATE, Status.PAUSE) |
|
|
@ -417,8 +418,7 @@ class AudioPlayService : BaseService(), |
|
|
|
}) |
|
|
|
}) |
|
|
|
mediaSessionCompat?.setMediaButtonReceiver( |
|
|
|
mediaSessionCompat?.setMediaButtonReceiver( |
|
|
|
PendingIntent.getBroadcast( |
|
|
|
PendingIntent.getBroadcast( |
|
|
|
this, |
|
|
|
this, 0, |
|
|
|
0, |
|
|
|
|
|
|
|
Intent( |
|
|
|
Intent( |
|
|
|
Intent.ACTION_MEDIA_BUTTON, |
|
|
|
Intent.ACTION_MEDIA_BUTTON, |
|
|
|
null, |
|
|
|
null, |
|
|
|