mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-11-07 03:04:50 +01:00
Add shuffle parameter to playback intent (#1813)
## Description Adds an optional boolean parameter `shuffle` that is read for the playback intent. When true, it will cause the resulting media to be shuffled if applicable. Something can be shuffled if the `itemId` is a grouping on media such as a playlist, series, season, or even library. ### Related issues Depends on #1756 ### Testing Emulator with the documented command ## Screenshots N/A ## AI or LLM usage None
This commit is contained in:
parent
e94e82479b
commit
bd1a6c44ee
4 changed files with 22 additions and 3 deletions
15
Intents.md
15
Intents.md
|
|
@ -1,8 +1,5 @@
|
||||||
# Intents
|
# Intents
|
||||||
|
|
||||||
> [!WARNING]
|
|
||||||
> This feature is only available in the develop builds until the next release!
|
|
||||||
|
|
||||||
> [!IMPORTANT]
|
> [!IMPORTANT]
|
||||||
> This feature is experimental and the exact behaviors and/or parameters may change at any time
|
> This feature is experimental and the exact behaviors and/or parameters may change at any time
|
||||||
|
|
||||||
|
|
@ -93,6 +90,7 @@ Shorthand action: `play`
|
||||||
Parameters:
|
Parameters:
|
||||||
- `itemId` - Required, the UUID of the media item
|
- `itemId` - Required, the UUID of the media item
|
||||||
- `position` - Optional, the start position for playback in milliseconds
|
- `position` - Optional, the start position for playback in milliseconds
|
||||||
|
- `shuffle` - Optional, whether to shuffle the resulting items
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
|
|
@ -120,6 +118,17 @@ adb shell am start \
|
||||||
adb shell am start -d 'wholphin://play?itemId=5cf8f8e7-2a5f-4aa9-8c12-ddf63d42ee6d\&position=270000'
|
adb shell am start -d 'wholphin://play?itemId=5cf8f8e7-2a5f-4aa9-8c12-ddf63d42ee6d\&position=270000'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Shuffle a series (`itemId` is the Series ID):
|
||||||
|
```bash
|
||||||
|
adb shell am start \
|
||||||
|
-a com.github.damontecres.wholphin.PLAYBACK \
|
||||||
|
-n 'com.github.damontecres.wholphin/.MainActivity' \
|
||||||
|
--es itemId "5cf8f8e7-2a5f-4aa9-8c12-ddf63d42ee6d" \
|
||||||
|
--ez shuffle true
|
||||||
|
|
||||||
|
adb shell am start -d 'wholphin://play?itemId=5cf8f8e7-2a5f-4aa9-8c12-ddf63d42ee6d\&shuffle=true'
|
||||||
|
```
|
||||||
|
|
||||||
## More examples
|
## More examples
|
||||||
|
|
||||||
### Switch user
|
### Switch user
|
||||||
|
|
|
||||||
|
|
@ -103,11 +103,13 @@ class IntentService
|
||||||
|
|
||||||
"com.github.damontecres.wholphin.PLAYBACK", "play" -> {
|
"com.github.damontecres.wholphin.PLAYBACK", "play" -> {
|
||||||
val position = intent.getLongParam("position")?.coerceAtLeast(0)
|
val position = intent.getLongParam("position")?.coerceAtLeast(0)
|
||||||
|
val shuffle = intent.getBooleanExtra("shuffle", false)
|
||||||
|
|
||||||
val playbackDestination =
|
val playbackDestination =
|
||||||
Destination.Playback(
|
Destination.Playback(
|
||||||
itemId = itemId,
|
itemId = itemId,
|
||||||
positionMs = position ?: 0L,
|
positionMs = position ?: 0L,
|
||||||
|
shuffle = shuffle,
|
||||||
)
|
)
|
||||||
|
|
||||||
if (itemDestination is Destination.Playback) {
|
if (itemDestination is Destination.Playback) {
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ sealed class Destination(
|
||||||
val positionMs: Long,
|
val positionMs: Long,
|
||||||
val forceTranscoding: Boolean = false,
|
val forceTranscoding: Boolean = false,
|
||||||
val backend: PlayerBackend? = null,
|
val backend: PlayerBackend? = null,
|
||||||
|
val shuffle: Boolean = false,
|
||||||
) : Destination(true) {
|
) : Destination(true) {
|
||||||
constructor(item: BaseItem) : this(item.id, item.resumeMs)
|
constructor(item: BaseItem) : this(item.id, item.resumeMs)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -332,10 +332,17 @@ class PlaybackViewModel
|
||||||
filter = destination.filter,
|
filter = destination.filter,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
val shuffled =
|
||||||
|
if (destination is Destination.Playback) {
|
||||||
|
destination.shuffle
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
// Try to create a playlist
|
// Try to create a playlist
|
||||||
playlistCreator.createFrom(
|
playlistCreator.createFrom(
|
||||||
item = queriedItem,
|
item = queriedItem,
|
||||||
recursive = true,
|
recursive = true,
|
||||||
|
shuffled = shuffled,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
when (val r = playlistResult) {
|
when (val r = playlistResult) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue