mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-05-16 15:26:35 +03: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?!
|
// FIXME: Why is currentPlaying passed here and not nextPlaying?!
|
||||||
attachHandlersToPlayer(mediaPlayer, currentPlaying!!, false)
|
attachHandlersToPlayer(mediaPlayer, currentPlaying!!, false)
|
||||||
|
|
||||||
if (onNextSongRequested != null) {
|
postRunnable(onNextSongRequested)
|
||||||
val mainHandler = Handler(context.mainLooper)
|
|
||||||
val myRunnable = Runnable { onNextSongRequested!!.run() }
|
|
||||||
mainHandler.post(myRunnable)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Proxy should not be being used here since the next player was already setup to play
|
// Proxy should not be being used here since the next player was already setup to play
|
||||||
proxy?.stop()
|
proxy?.stop()
|
||||||
proxy = null
|
proxy = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun pause() {
|
fun pause() {
|
||||||
try {
|
try {
|
||||||
@ -479,11 +477,9 @@ class LocalMediaPlayer(private val audioFocusHandler: AudioFocusHandler, private
|
|||||||
setPlayerState(PlayerState.PAUSED)
|
setPlayerState(PlayerState.PAUSED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (onPrepared != null) {
|
|
||||||
val mainHandler = Handler(context.mainLooper)
|
postRunnable(onPrepared)
|
||||||
val myRunnable = Runnable { onPrepared!!.run() }
|
|
||||||
mainHandler.post(myRunnable)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
attachHandlersToPlayer(mediaPlayer, downloadFile, partial)
|
attachHandlersToPlayer(mediaPlayer, downloadFile, partial)
|
||||||
mediaPlayer.prepareAsync()
|
mediaPlayer.prepareAsync()
|
||||||
@ -724,4 +720,12 @@ class LocalMediaPlayer(private val audioFocusHandler: AudioFocusHandler, private
|
|||||||
Timber.w(x, "Next Media player error")
|
Timber.w(x, "Next Media player error")
|
||||||
nextMediaPlayer!!.reset()
|
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