-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a sample to start at a given time (#392)
- Loading branch information
Showing
5 changed files
with
53 additions
and
0 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
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
36 changes: 36 additions & 0 deletions
36
...arbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/showcases/StartAtGivenTimeExample.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,36 @@ | ||
/* | ||
* Copyright (c) SRG SSR. All rights reserved. | ||
* License information is available from the LICENSE file. | ||
*/ | ||
package ch.srgssr.pillarbox.demo.ui.showcases | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.DisposableEffect | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.platform.LocalContext | ||
import ch.srgssr.pillarbox.demo.shared.data.DemoItem | ||
import ch.srgssr.pillarbox.demo.shared.di.PlayerModule | ||
import ch.srgssr.pillarbox.demo.ui.player.PlayerView | ||
import kotlin.time.Duration.Companion.minutes | ||
|
||
/** | ||
* Simple example to demonstrate how to start content at a given time (10min). | ||
*/ | ||
@Composable | ||
fun StartAtGivenTimeExample() { | ||
val context = LocalContext.current | ||
val player = remember { | ||
PlayerModule.provideDefaultPlayer(context).apply { | ||
setMediaItem(DemoItem.AppleBasic_16_9_TS_HLS.toMediaItem()) | ||
prepare() | ||
play() | ||
seekTo(10.minutes.inWholeMilliseconds) | ||
} | ||
} | ||
DisposableEffect(player) { | ||
onDispose { | ||
player.release() | ||
} | ||
} | ||
PlayerView(player = player) | ||
} |
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