make playlist item deletion more reliable
This commit is contained in:
parent
33b0360507
commit
f5d3c33086
|
@ -96,7 +96,7 @@ interface NewPlayer {
|
|||
fun pause()
|
||||
fun addToPlaylist(item: String)
|
||||
fun movePlaylistItem(fromIndex: Int, toIndex: Int)
|
||||
fun removePlaylistItem(index: Int)
|
||||
fun removePlaylistItem(uniqueId: Long)
|
||||
fun playStream(item: String, playMode: PlayMode)
|
||||
fun selectChapter(index: Int)
|
||||
fun playStream(item: String, streamVariant: String, playMode: PlayMode)
|
||||
|
@ -338,8 +338,14 @@ class NewPlayerImpl(
|
|||
internalPlayer.moveMediaItem(fromIndex, toIndex)
|
||||
}
|
||||
|
||||
override fun removePlaylistItem(index: Int) {
|
||||
internalPlayer.removeMediaItem(index)
|
||||
override fun removePlaylistItem(uniqueId: Long) {
|
||||
for(i in 0..<internalPlayer.mediaItemCount) {
|
||||
val id = internalPlayer.getMediaItemAt(i).mediaId.toLong()
|
||||
if(id == uniqueId) {
|
||||
internalPlayer.removeMediaItem(i)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun playStream(item: String, playMode: PlayMode) {
|
||||
|
|
|
@ -62,7 +62,7 @@ interface VideoPlayerViewModel {
|
|||
fun toggleShuffle()
|
||||
fun onStorePlaylist()
|
||||
fun movePlaylistItem(from: Int, to: Int)
|
||||
fun removePlaylistItem(index: Int)
|
||||
fun removePlaylistItem(uniqueId: Long)
|
||||
fun onStreamItemDragFinished()
|
||||
fun dialogVisible(visible: Boolean)
|
||||
}
|
|
@ -543,8 +543,8 @@ class VideoPlayerViewModelImpl @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
override fun removePlaylistItem(index: Int) {
|
||||
newPlayer?.removePlaylistItem(index)
|
||||
override fun removePlaylistItem(uniqueId: Long) {
|
||||
newPlayer?.removePlaylistItem(uniqueId)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -108,8 +108,8 @@ open class VideoPlayerViewModelDummy : VideoPlayerViewModel {
|
|||
println("dummy impl")
|
||||
}
|
||||
|
||||
override fun removePlaylistItem(index: Int) {
|
||||
println("dummy impl")
|
||||
override fun removePlaylistItem(uniqueId: Long) {
|
||||
println("dummy impl delete uniqueId: $uniqueId")
|
||||
}
|
||||
|
||||
override fun onStreamItemDragFinished() {
|
||||
|
|
|
@ -159,7 +159,7 @@ fun ReorderableStreamItemsList(
|
|||
isDragging = isDragging,
|
||||
isCurrentlyPlaying = playlistItem.uniqueId == uiState.currentlyPlaying.uniqueId,
|
||||
onDelete = {
|
||||
viewModel.removePlaylistItem(index)
|
||||
viewModel.removePlaylistItem(playlistItem.uniqueId)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue