Rework BrandedQueueEntry and UserQueueEntry implementation
This commit is contained in:
committed by
Niels van Velzen
parent
539c8f5937
commit
0938a8a19a
@@ -1,20 +1,36 @@
|
||||
package org.jellyfin.playback.core.queue.item
|
||||
|
||||
// Queue Items
|
||||
sealed interface QueueEntry {
|
||||
/**
|
||||
* The QueueEntry is a single entry in a queue. It can represent any supported media type.
|
||||
* Implementations normally extend one of it's subclasses [BrandedQueueEntry] or [UserQueueEntry].
|
||||
*/
|
||||
interface QueueEntry {
|
||||
/**
|
||||
* Whether this entry can be skipped and seeked or not. Normally set to `true`.
|
||||
*/
|
||||
val skippable: Boolean
|
||||
val metadata: QueueEntryMetadata?
|
||||
|
||||
/**
|
||||
* The metadata for this item.
|
||||
*/
|
||||
val metadata: QueueEntryMetadata
|
||||
}
|
||||
|
||||
/**
|
||||
* Branded queue items are used for intros, trailers, advertisements and other related videos
|
||||
* It is not possible to seek or skip these items and are normally invisible when showing a queue's contents
|
||||
* Branded queue entries are used for intros, trailers, advertisements and other related videos. It
|
||||
* is not possible to seek or skip these items and are normally invisible when showing a queue's
|
||||
* contents.
|
||||
*/
|
||||
abstract class BrandedQueueEntry : QueueEntry {
|
||||
open class BrandedQueueEntry : QueueEntry {
|
||||
override val skippable = false
|
||||
override val metadata = QueueEntryMetadata.Empty
|
||||
}
|
||||
|
||||
/**
|
||||
* User queue entries are used for regular media like music tracks, movies and series episodes. This
|
||||
* is the entry type used most often.
|
||||
*/
|
||||
open class UserQueueEntry : QueueEntry {
|
||||
override val skippable = true
|
||||
override val metadata = QueueEntryMetadata()
|
||||
override val metadata = QueueEntryMetadata.Empty
|
||||
}
|
||||
|
||||
@@ -24,4 +24,8 @@ data class QueueEntryMetadata(
|
||||
val trackNumber: Long? = null,
|
||||
val writer: String? = null,
|
||||
val year: Long? = null,
|
||||
)
|
||||
) {
|
||||
companion object {
|
||||
val Empty = QueueEntryMetadata()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.jellyfin.playback.jellyfin.queue.item
|
||||
|
||||
import org.jellyfin.playback.core.queue.item.QueueEntry
|
||||
import org.jellyfin.playback.core.queue.item.QueueEntryMetadata
|
||||
import org.jellyfin.playback.core.queue.item.UserQueueEntry
|
||||
import org.jellyfin.sdk.api.client.ApiClient
|
||||
@@ -11,7 +12,8 @@ import kotlin.time.Duration.Companion.nanoseconds
|
||||
class BaseItemDtoUserQueueEntry private constructor(
|
||||
val baseItem: BaseItemDto,
|
||||
override val metadata: QueueEntryMetadata,
|
||||
) : UserQueueEntry() {
|
||||
base: QueueEntry,
|
||||
) : QueueEntry by base {
|
||||
companion object {
|
||||
fun build(api: ApiClient, baseItem: BaseItemDto): BaseItemDtoUserQueueEntry {
|
||||
val metadata = QueueEntryMetadata(
|
||||
@@ -41,7 +43,7 @@ class BaseItemDtoUserQueueEntry private constructor(
|
||||
}
|
||||
)
|
||||
|
||||
return BaseItemDtoUserQueueEntry(baseItem, metadata)
|
||||
return BaseItemDtoUserQueueEntry(baseItem, metadata, UserQueueEntry())
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user