Fix undesired radio restart when playing from SearchResultScreen
This commit is contained in:
parent
b9489e5274
commit
52627239e3
2 changed files with 10 additions and 6 deletions
|
@ -202,11 +202,15 @@ fun SearchResultScreen(
|
||||||
is YouTube.Item.Artist -> artistRoute(item.info.endpoint!!.browseId)
|
is YouTube.Item.Artist -> artistRoute(item.info.endpoint!!.browseId)
|
||||||
is YouTube.Item.Song -> {
|
is YouTube.Item.Song -> {
|
||||||
player?.mediaController?.forcePlay(item.asMediaItem)
|
player?.mediaController?.forcePlay(item.asMediaItem)
|
||||||
item.info.endpoint?.let(YoutubePlayer.Radio::setup)
|
item.info.endpoint?.let {
|
||||||
|
YoutubePlayer.Radio.setup(it, false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
is YouTube.Item.Video -> {
|
is YouTube.Item.Video -> {
|
||||||
player?.mediaController?.forcePlay(item.asMediaItem)
|
player?.mediaController?.forcePlay(item.asMediaItem)
|
||||||
item.info.endpoint?.let(YoutubePlayer.Radio::setup)
|
item.info.endpoint?.let {
|
||||||
|
YoutubePlayer.Radio.setup(it, false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,9 @@ import com.google.common.util.concurrent.ListenableFuture
|
||||||
import it.vfsfitvnm.youtubemusic.Outcome
|
import it.vfsfitvnm.youtubemusic.Outcome
|
||||||
import it.vfsfitvnm.youtubemusic.YouTube
|
import it.vfsfitvnm.youtubemusic.YouTube
|
||||||
import it.vfsfitvnm.youtubemusic.models.NavigationEndpoint
|
import it.vfsfitvnm.youtubemusic.models.NavigationEndpoint
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.guava.await
|
import kotlinx.coroutines.guava.await
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
class YoutubePlayer(mediaController: MediaController) : PlayerState(mediaController) {
|
class YoutubePlayer(mediaController: MediaController) : PlayerState(mediaController) {
|
||||||
object Radio {
|
object Radio {
|
||||||
|
@ -34,7 +34,7 @@ class YoutubePlayer(mediaController: MediaController) : PlayerState(mediaControl
|
||||||
nextContinuation = Outcome.Initial
|
nextContinuation = Outcome.Initial
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setup(watchEndpoint: NavigationEndpoint.Endpoint.Watch?) {
|
fun setup(watchEndpoint: NavigationEndpoint.Endpoint.Watch?, play: Boolean = true) {
|
||||||
setup(
|
setup(
|
||||||
videoId = watchEndpoint?.videoId,
|
videoId = watchEndpoint?.videoId,
|
||||||
playlistId = watchEndpoint?.playlistId,
|
playlistId = watchEndpoint?.playlistId,
|
||||||
|
@ -42,7 +42,7 @@ class YoutubePlayer(mediaController: MediaController) : PlayerState(mediaControl
|
||||||
playlistSetVideoId = watchEndpoint?.playlistSetVideoId
|
playlistSetVideoId = watchEndpoint?.playlistSetVideoId
|
||||||
)
|
)
|
||||||
|
|
||||||
listener?.process(true)
|
listener?.process(play)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun process(player: Player, force: Boolean = false, play: Boolean = false) {
|
suspend fun process(player: Player, force: Boolean = false, play: Boolean = false) {
|
||||||
|
|
Loading…
Reference in a new issue