Yokan / rebuild
Course 1 8624561

PlayerContract.kt

composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/ui/screens/player/PlayerContract.kt

implementation66 lines
1package eu.friedcutlet.yokan.ui.screens.player23import androidx.compose.ui.graphics.ImageBitmap4import eu.friedcutlet.yokan.database.DbCustomButton5import eu.friedcutlet.yokan.database.DbVideo6import eu.friedcutlet.yokan.domain.Chapter7import eu.friedcutlet.yokan.services.media.AniSkipMarker8import eu.friedcutlet.yokan.services.media.cast.CastDevice9import eu.friedcutlet.yokan.services.media.cast.CastStatus10import eu.friedcutlet.yokan.services.media.player.SeekThumbnail1112internal data class PlayerState(13    /** Selected releases in the title's sort order, retaining the opened alternate. */14    val episodes: List<Chapter> = emptyList(),15    /** The episode list dialog: the title's filters applied. */16    val visibleEpisodes: List<Chapter> = emptyList(),17    val customButtons: List<DbCustomButton> = emptyList(),18    /** Streams of this episode in the source's order. */19    val videos: List<DbVideo> = emptyList(),20    /** The stream the controller plays; null while loading, without streams, or after an external handoff. */21    val selectedVideo: DbVideo? = null,22    val loading: Boolean = true,23    val error: String? = null,24    /** Where [selectedVideo] starts when the controller loads it, and whether it plays at once. */25    val startPositionMs: Long = 0L,26    val autoplay: Boolean = true,27    val aniSkipMarkers: List<AniSkipMarker> = emptyList(),28    /** Seek-preview tiles of the selected stream, sorted by start time. */29    val seekThumbnails: List<SeekThumbnail> = emptyList(),30    /** Decoded sprite sheets by URL, loaded on first use while seeking. */31    val seekSprites: Map<String, ImageBitmap> = emptyMap(),32    /** Null when no cast session is active. */33    val castStatus: CastStatus? = null,34    val castSupported: Boolean = false,35    /** The platform shows its own device picker, so casting starts without [castDevices]. */36    val castUsesSystemPicker: Boolean = false,37    val castDevices: List<CastDevice> = emptyList(),38)3940internal sealed interface PlayerEvent {41    /** Opens the episode [offset] steps away in title order, when there is one. */42    data class SwitchEpisode(val offset: Int) : PlayerEvent43    data class SavePosition(val positionMs: Long, val durationMs: Long) : PlayerEvent44    data class LoadSeekSprite(val url: String) : PlayerEvent45    /** A quality change: [video] continues from [startPositionMs]. */46    data class SelectVideo(val video: DbVideo, val startPositionMs: Long, val autoplay: Boolean) : PlayerEvent47    /** The controller reported [error] at [positionMs]; fails over to the next stream when enabled. */48    data class PlaybackFailed(val error: String, val positionMs: Long) : PlayerEvent49    data class OpenExternalPlayer(val video: DbVideo) : PlayerEvent50    data class SetCastDiscovery(val active: Boolean) : PlayerEvent51    /** Casts the episode from [startPositionMs], then queues the following episodes. */52    data class StartCasting(val device: CastDevice?, val startPositionMs: Long, val subtitleFile: String?) : PlayerEvent53    data object StopCasting : PlayerEvent54    data object CastPlayPause : PlayerEvent55    data class CastSeek(val positionMs: Long) : PlayerEvent56    data object CastPrevious : PlayerEvent57    data object CastNext : PlayerEvent58    data class CastJumpTo(val index: Int) : PlayerEvent59}6061internal sealed interface PlayerEffect {62    data class ShowNotice(val text: String) : PlayerEffect63    /** The episode plays in an external player instead. */64    data object Exit : PlayerEffect65    data class OpenEpisode(val episode: Chapter) : PlayerEffect66}67

Search chapters, reference and source filenames.