-
-
Notifications
You must be signed in to change notification settings - Fork 519
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
81aa372
commit 67d470f
Showing
8 changed files
with
111 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
app/src/main/java/org/jellyfin/androidtv/integration/dream/model/DreamContent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
package org.jellyfin.androidtv.integration.dream.model | ||
|
||
import android.graphics.Bitmap | ||
import org.jellyfin.playback.core.queue.QueueEntry | ||
import org.jellyfin.sdk.model.api.BaseItemDto | ||
import org.jellyfin.sdk.model.api.LyricDto | ||
|
||
sealed interface DreamContent { | ||
data object Logo : DreamContent | ||
data class LibraryShowcase(val item: BaseItemDto, val backdrop: Bitmap, val logo: Bitmap?) : DreamContent | ||
data class NowPlaying(val item: BaseItemDto, val lyrics: LyricDto?) : DreamContent | ||
data class NowPlaying(val entry: QueueEntry, val item: BaseItemDto) : DreamContent | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 0 additions & 48 deletions
48
app/src/main/java/org/jellyfin/androidtv/ui/composable/mediaItem.kt
This file was deleted.
Oops, something went wrong.
67 changes: 67 additions & 0 deletions
67
app/src/main/java/org/jellyfin/androidtv/ui/composable/playback.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package org.jellyfin.androidtv.ui.composable | ||
|
||
import androidx.compose.animation.core.Animatable | ||
import androidx.compose.animation.core.LinearEasing | ||
import androidx.compose.animation.core.tween | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.collectAsState | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.remember | ||
import org.jellyfin.playback.core.PlaybackManager | ||
import org.jellyfin.playback.core.model.PlayState | ||
import org.jellyfin.playback.core.queue.queue | ||
import org.koin.compose.koinInject | ||
import kotlin.math.roundToInt | ||
import kotlin.time.Duration | ||
|
||
@Composable | ||
fun rememberQueueEntry( | ||
playbackManager: PlaybackManager = koinInject(), | ||
) = remember(playbackManager) { | ||
playbackManager.queue.entry | ||
}.collectAsState() | ||
|
||
@Composable | ||
fun rememberPlayerProgress( | ||
playbackManager: PlaybackManager = koinInject(), | ||
): Float { | ||
val playState by playbackManager.state.playState.collectAsState() | ||
val active = playbackManager.state.positionInfo.active | ||
val duration = playbackManager.state.positionInfo.duration | ||
|
||
return rememberPlayerProgress( | ||
playing = playState == PlayState.PLAYING, | ||
active = active, | ||
duration = duration, | ||
) | ||
} | ||
|
||
@Composable | ||
fun rememberPlayerProgress( | ||
playing: Boolean, | ||
active: Duration, | ||
duration: Duration, | ||
): Float { | ||
val animatable = remember { Animatable(0f) } | ||
|
||
LaunchedEffect(playing, duration) { | ||
val activeMs = active.inWholeMilliseconds.toFloat() | ||
val durationMs = duration.inWholeMilliseconds.toFloat() | ||
|
||
if (active == Duration.ZERO) animatable.snapTo(0f) | ||
else animatable.snapTo((activeMs / durationMs).coerceIn(0f, 1f)) | ||
|
||
if (playing) { | ||
animatable.animateTo( | ||
targetValue = 1f, | ||
animationSpec = tween( | ||
durationMillis = (durationMs - activeMs).roundToInt(), | ||
easing = LinearEasing, | ||
) | ||
) | ||
} | ||
} | ||
|
||
return animatable.value | ||
} |
Oops, something went wrong.