-
-
Notifications
You must be signed in to change notification settings - Fork 19
Add the ability to repeat a single video in a playlist #779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,6 +106,8 @@ sealed interface PlaybackAction { | |
| data class Scale( | ||
| val scale: ContentScale, | ||
| ) : PlaybackAction | ||
|
|
||
| data object ToggleRepeatOne : PlaybackAction | ||
| } | ||
|
|
||
| @OptIn(UnstableApi::class) | ||
|
|
@@ -132,6 +134,8 @@ fun PlaybackControls( | |
| scale: ContentScale, | ||
| seekBarIntervals: Int, | ||
| modifier: Modifier = Modifier, | ||
| isPlaylist: Boolean = false, | ||
| repeatOneEnabled: Boolean = false, | ||
| initialFocusRequester: FocusRequester = remember { FocusRequester() }, | ||
| seekBarInteractionSource: MutableInteractionSource = remember { MutableInteractionSource() }, | ||
| ) { | ||
|
|
@@ -197,6 +201,9 @@ fun PlaybackControls( | |
| previousEnabled = previousEnabled, | ||
| nextEnabled = nextEnabled, | ||
| modifier = Modifier, | ||
| isPlaylist = isPlaylist, | ||
| repeatOneEnabled = repeatOneEnabled, | ||
| onToggleRepeatOne = { onPlaybackActionClick(PlaybackAction.ToggleRepeatOne) }, | ||
| ) | ||
| RightPlaybackButtons( | ||
| modifier = Modifier, | ||
|
|
@@ -504,6 +511,9 @@ fun PlaybackButtons( | |
| previousEnabled: Boolean, | ||
| nextEnabled: Boolean, | ||
| modifier: Modifier = Modifier, | ||
| isPlaylist: Boolean = false, | ||
| repeatOneEnabled: Boolean = false, | ||
| onToggleRepeatOne: () -> Unit = {}, | ||
| ) { | ||
| Row( | ||
| modifier = modifier.focusGroup(), | ||
|
|
@@ -552,6 +562,16 @@ fun PlaybackButtons( | |
| enabled = nextEnabled, | ||
| onControllerInteraction = onControllerInteraction, | ||
| ) | ||
| if (isPlaylist) { | ||
| PlaybackButton( | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't want another button on the main playback controls. But this could be moved to the More menu on the left.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Understood. Unfortunately I find that placement super convenient. I probably wouldn't even use this feature if it were tucked in a menu. Maybe it could be optional to display it with the main controls? |
||
| iconRes = if (repeatOneEnabled) R.drawable.baseline_repeat_one_24 else R.drawable.baseline_repeat_24, | ||
| onClick = { | ||
| onControllerInteraction.invoke() | ||
| onToggleRepeatOne() | ||
| }, | ||
| onControllerInteraction = onControllerInteraction, | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -504,6 +504,7 @@ fun PlaybackPageContent( | |
| var showPlaylist by remember { mutableStateOf(false) } | ||
| var contentScale by remember { mutableStateOf(ContentScale.Fit) } | ||
| var playbackSpeed by remember { mutableFloatStateOf(1.0f) } | ||
| var repeatOneEnabled by remember { mutableStateOf(false) } | ||
| LaunchedEffect(playbackSpeed) { player.setPlaybackSpeed(playbackSpeed) } | ||
|
|
||
| val presentationState = rememberPresentationState(player) | ||
|
|
@@ -930,6 +931,12 @@ fun PlaybackPageContent( | |
| PlaybackAction.ShowSceneDetails -> { | ||
| showSceneDetails = true | ||
| } | ||
|
|
||
| PlaybackAction.ToggleRepeatOne -> { | ||
| repeatOneEnabled = !repeatOneEnabled | ||
| player.repeatMode = | ||
| if (repeatOneEnabled) Player.REPEAT_MODE_ONE else Player.REPEAT_MODE_OFF | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be reset back to the global setting. Which is either OFF or REPEAT I believe |
||
| } | ||
| } | ||
| }, | ||
| onSeekBarChange = seekBarState::onValueChange, | ||
|
|
@@ -971,6 +978,7 @@ fun PlaybackPageContent( | |
| videoDecoder = videoDecoder, | ||
| audioDecoder = audioDecoder, | ||
| spriteData = spriteImageLoaded, | ||
| repeatOneEnabled = repeatOneEnabled, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where did these vectors come from?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These were AI-generated based on the existing vectors you had. Apologies, I probably should've called that out. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="24dp" | ||
| android:height="24dp" | ||
| android:viewportWidth="24" | ||
| android:viewportHeight="24" | ||
| android:tint="?attr/colorControlNormal"> | ||
| <path | ||
| android:fillColor="@android:color/white" | ||
| android:pathData="M7,7h10v3l4,-4 -4,-4v3L5,5v6h2L7,7zM17,17L7,17v-3l-4,4 4,4v-3h12v-6h-2v4z"/> | ||
| </vector> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="24dp" | ||
| android:height="24dp" | ||
| android:viewportWidth="24" | ||
| android:viewportHeight="24" | ||
| android:tint="?attr/colorControlNormal"> | ||
| <path | ||
| android:fillColor="@android:color/white" | ||
| android:pathData="M7,7h10v3l4,-4 -4,-4v3L5,5v6h2L7,7zM17,17L7,17v-3l-4,4 4,4v-3h12v-6h-2v4zM13,15L13,9h-1l-2,1v1h1.5v4z"/> | ||
| </vector> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather not make any changes to the old UI. I don't want to vet any new functionality in it.