Add support for cinema mode (#1305)

## Description
Adds support for cinema mode, which is enabled by default.

When enabled and if starting playback from the beginning, the server is
queried for any "intros", ie prerolls or trailers, to play first. These
are shown in the queue and can be skipped if desired.

The server has to provide the intros, so a plugin like
https://github.com/jellyfin/jellyfin-plugin-intros or
https://github.com/CherryFloors/jellyfin-plugin-cinemamode is required
server-side.

### Related issues
Closes #418
Closes #1180

### Testing
Emulator and server w/
https://github.com/CherryFloors/jellyfin-plugin-cinemamode

## Screenshots
N/A

## AI or LLM usage
None
This commit is contained in:
Damontecres 2026-04-26 10:16:26 -04:00 • committed by GitHub
parent ea6a0227b0
commit edb37f5d69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 170 additions and 64 deletions

View file

@ -12,7 +12,7 @@ import java.util.UUID
* This is not the same thing as a Jellyfin server playlist
*/
class Playlist(
items: List<BaseItem>,
items: List<PlaylistItem>,
startIndex: Int = 0,
) {
val items = items.subList(startIndex, items.size)
@ -23,15 +23,15 @@ class Playlist(
fun hasNext(): Boolean = (index + 1) < items.size
fun getPreviousAndReverse(): BaseItem = items[--index]
fun getPreviousAndReverse(): PlaylistItem = items[--index]
fun getAndAdvance(): BaseItem = items[++index]
fun getAndAdvance(): PlaylistItem = items[++index]
fun peek(): BaseItem? = items.getOrNull(index + 1)
fun peek(): PlaylistItem? = items.getOrNull(index + 1)
fun upcomingItems(): List<BaseItem> = items.subList(index + 1, items.size)
fun upcomingItems(): List<PlaylistItem> = items.subList(index + 1, items.size)
fun advanceTo(id: UUID): BaseItem? {
fun advanceTo(id: UUID): PlaylistItem? {
while (hasNext()) {
val potential = getAndAdvance()
if (potential.id == id) {
@ -52,3 +52,22 @@ data class PlaylistInfo(
val count: Int,
val mediaType: MediaType,
)
sealed interface PlaylistItem {
val id: UUID
val item: BaseItem
data class Media(
override val item: BaseItem,
) : PlaylistItem {
override val id: UUID
get() = item.id
}
data class Intro(
override val item: BaseItem,
) : PlaylistItem {
override val id: UUID
get() = item.id
}
}