make playlist item selectable
This commit is contained in:
parent
0d8662fb5b
commit
106060625c
|
@ -96,6 +96,7 @@ interface NewPlayer {
|
||||||
fun removePlaylistItem(index: Int)
|
fun removePlaylistItem(index: Int)
|
||||||
fun playStream(item: String, playMode: PlayMode)
|
fun playStream(item: String, playMode: PlayMode)
|
||||||
fun selectChapter(index: Int)
|
fun selectChapter(index: Int)
|
||||||
|
fun selectPlaylistItem(index: Int)
|
||||||
fun playStream(item: String, streamVariant: String, playMode: PlayMode)
|
fun playStream(item: String, streamVariant: String, playMode: PlayMode)
|
||||||
|
|
||||||
data class Builder(val app: Application, val repository: MediaRepository) {
|
data class Builder(val app: Application, val repository: MediaRepository) {
|
||||||
|
@ -342,12 +343,19 @@ class NewPlayerImpl(
|
||||||
override fun selectChapter(index: Int) {
|
override fun selectChapter(index: Int) {
|
||||||
val chapters = currentChapters.value
|
val chapters = currentChapters.value
|
||||||
assert(index in 0..<chapters.size) {
|
assert(index in 0..<chapters.size) {
|
||||||
throw NewPlayerException("Chapter selection out of bound: seleced chapter index: $index, available chapters: ${chapters.size}")
|
throw NewPlayerException("Chapter selection out of bound: selected chapter index: $index, available chapters: ${chapters.size}")
|
||||||
}
|
}
|
||||||
val chapter = chapters[index]
|
val chapter = chapters[index]
|
||||||
currentPosition = chapter.chapterStartInMs
|
currentPosition = chapter.chapterStartInMs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun selectPlaylistItem(index: Int) {
|
||||||
|
assert(index in 0..<playlist.value.size) {
|
||||||
|
throw NewPlayerException("Playlist item selection out of bound: selected item index: $index, available chapters: ${playlist.value.size}")
|
||||||
|
}
|
||||||
|
internalPlayer.seekTo(index, 0)
|
||||||
|
}
|
||||||
|
|
||||||
private fun internalPlayStream(mediaItem: MediaItem, playMode: PlayMode) {
|
private fun internalPlayStream(mediaItem: MediaItem, playMode: PlayMode) {
|
||||||
if (internalPlayer.playbackState == Player.STATE_IDLE) {
|
if (internalPlayer.playbackState == Player.STATE_IDLE) {
|
||||||
internalPlayer.prepare()
|
internalPlayer.prepare()
|
||||||
|
|
|
@ -468,7 +468,8 @@ class VideoPlayerViewModelImpl @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun streamSelected(streamId: Int) {
|
override fun streamSelected(streamId: Int) {
|
||||||
println("stream selected: $streamId")
|
println("gurken stream selected: $streamId")
|
||||||
|
newPlayer?.selectPlaylistItem(streamId)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun cycleRepeatMode() {
|
override fun cycleRepeatMode() {
|
||||||
|
|
|
@ -152,7 +152,7 @@ fun ReorderableStreamItemsList(
|
||||||
) { isDragging ->
|
) { isDragging ->
|
||||||
StreamItem(
|
StreamItem(
|
||||||
playlistItem = playlistItem,
|
playlistItem = playlistItem,
|
||||||
onClicked = { viewModel.streamSelected(0) },
|
onClicked = { viewModel.streamSelected(index) },
|
||||||
reorderableScope = this@ReorderableItem,
|
reorderableScope = this@ReorderableItem,
|
||||||
haptic = haptic,
|
haptic = haptic,
|
||||||
onDragFinished = viewModel::onStreamItemDragFinished,
|
onDragFinished = viewModel::onStreamItemDragFinished,
|
||||||
|
|
Loading…
Reference in New Issue