-
-
Notifications
You must be signed in to change notification settings - Fork 74
Add UI to select playback speed #1476
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
Open
andykelk
wants to merge
6
commits into
music-assistant:main
Choose a base branch
from
andykelk:feature/playback-speed
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+119
−0
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6f36582
Add UI to select playback speed
andykelk 6177ab1
Fix colours for the speed menu
andykelk 0887421
Add UI to select playback speed
andykelk e16828c
Fix colours for the speed menu
andykelk 018e9be
Merge branch 'feature/playback-speed' of github.com:andykelk/frontend…
andykelk 61bcf43
Add playback speed to context menu
andykelk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
76 changes: 76 additions & 0 deletions
76
src/layouts/default/PlayerOSD/PlayerControlBtn/PlaybackSpeedBtn.vue
This file contains hidden or 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,76 @@ | ||
| <template> | ||
| <v-menu | ||
| v-if="isVisible && playerQueue" | ||
| location="top" | ||
| :close-on-content-click="true" | ||
| > | ||
| <template #activator="{ props: menu }"> | ||
| <Button | ||
| v-bind="{ ...menu }" | ||
| variant="icon" | ||
| :title="$t('playback_speed')" | ||
| :disabled="!playerQueue.active || playerQueue.items === 0" | ||
| :style="currentSpeed !== 1.0 ? { color: activeColor } : {}" | ||
| > | ||
| <span class="speed-label">{{ formatSpeed(currentSpeed) }}</span> | ||
| </Button> | ||
| </template> | ||
|
|
||
| <v-list density="compact" nav> | ||
| <v-list-subheader>{{ $t("playback_speed") }}</v-list-subheader> | ||
| <v-list-item | ||
| v-for="speed in SPEED_PRESETS" | ||
| :key="speed" | ||
| :title="formatSpeed(speed)" | ||
| :active="Math.abs(currentSpeed - speed) < 0.01" | ||
| active-color="primary" | ||
| @click="setSpeed(speed)" | ||
| /> | ||
| </v-list> | ||
| </v-menu> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import Button from "@/components/Button.vue"; | ||
| import api from "@/plugins/api"; | ||
| import { PlayerQueue } from "@/plugins/api/interfaces"; | ||
| import { computed } from "vue"; | ||
|
|
||
| const SPEED_PRESETS = [0.5, 0.75, 1.0, 1.25, 1.5, 2.0]; | ||
|
|
||
| // properties | ||
| export interface Props { | ||
| playerQueue: PlayerQueue | undefined; | ||
| isVisible?: boolean; | ||
| activeColor?: string; | ||
| } | ||
|
|
||
| const props = withDefaults(defineProps<Props>(), { | ||
| isVisible: true, | ||
| activeColor: "rgb(var(--v-theme-primary))", | ||
| }); | ||
|
|
||
| const currentSpeed = computed<number>(() => { | ||
| const speed = props.playerQueue?.extra_attributes?.playback_speed; | ||
| return typeof speed === "number" ? speed : 1.0; | ||
| }); | ||
|
|
||
| function formatSpeed(speed: number): string { | ||
| return speed === 1.0 ? "1×" : `${speed}×`; | ||
| } | ||
|
|
||
| function setSpeed(speed: number) { | ||
| if (props.playerQueue) { | ||
| api.queueCommandSetPlaybackSpeed(props.playerQueue.queue_id, speed); | ||
| } | ||
| } | ||
| </script> | ||
|
|
||
| <style scoped> | ||
| .speed-label { | ||
| font-size: 0.75rem; | ||
| font-weight: 600; | ||
| min-width: 28px; | ||
| text-align: center; | ||
| } | ||
| </style> | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
so the playback_speed will now be set on the (current) queue item instead and not at queue level
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.
See here for details:
music-assistant/server@90f369d