mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-02-17 04:00:39 +01:00
Introduce postRunnable helper function
This commit is contained in:
parent
93eced9516
commit
493a587b37
@ -240,17 +240,15 @@ class LocalMediaPlayer(private val audioFocusHandler: AudioFocusHandler, private
|
||||
// FIXME: Why is currentPlaying passed here and not nextPlaying?!
|
||||
attachHandlersToPlayer(mediaPlayer, currentPlaying!!, false)
|
||||
|
||||
if (onNextSongRequested != null) {
|
||||
val mainHandler = Handler(context.mainLooper)
|
||||
val myRunnable = Runnable { onNextSongRequested!!.run() }
|
||||
mainHandler.post(myRunnable)
|
||||
}
|
||||
postRunnable(onNextSongRequested)
|
||||
|
||||
// Proxy should not be being used here since the next player was already setup to play
|
||||
proxy?.stop()
|
||||
proxy = null
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Synchronized
|
||||
fun pause() {
|
||||
try {
|
||||
@ -479,11 +477,9 @@ class LocalMediaPlayer(private val audioFocusHandler: AudioFocusHandler, private
|
||||
setPlayerState(PlayerState.PAUSED)
|
||||
}
|
||||
}
|
||||
if (onPrepared != null) {
|
||||
val mainHandler = Handler(context.mainLooper)
|
||||
val myRunnable = Runnable { onPrepared!!.run() }
|
||||
mainHandler.post(myRunnable)
|
||||
}
|
||||
|
||||
postRunnable(onPrepared)
|
||||
|
||||
}
|
||||
attachHandlersToPlayer(mediaPlayer, downloadFile, partial)
|
||||
mediaPlayer.prepareAsync()
|
||||
@ -724,4 +720,12 @@ class LocalMediaPlayer(private val audioFocusHandler: AudioFocusHandler, private
|
||||
Timber.w(x, "Next Media player error")
|
||||
nextMediaPlayer!!.reset()
|
||||
}
|
||||
|
||||
private fun postRunnable(runnable: Runnable?) {
|
||||
if (runnable != null) {
|
||||
val mainHandler = Handler(context.mainLooper)
|
||||
val myRunnable = Runnable { runnable.run() }
|
||||
mainHandler.post(myRunnable)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user