Skip to content

Commit

Permalink
Add option to transfer a queue
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Aug 24, 2024
1 parent 315ee9e commit c516b8c
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 24 deletions.
54 changes: 53 additions & 1 deletion src/layouts/default/ItemContextMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,35 @@
:disabled="menuItem.disabled == true"
:prepend-icon="menuItem.icon"
:append-icon="menuItem.selected ? 'mdi-check' : undefined"
@click="() => (menuItem.action ? menuItem.action() : '')"
@click.stop="(e) => menuItemClicked(e, menuItem)"
/>
</div>
</v-list>
</v-card>
</v-menu>
<v-menu
v-model="showSubmenu"
:target="[subMenuPosX, subMenuPosY]"
@update:model-value="
(v) => {
store.dialogActive = v;
}
"
>
<v-card min-width="260">
<v-list density="compact" slim tile>
<div
v-for="subMenuItem of subMenuItems.filter((x) => !x.hide)"
:key="subMenuItem.label"
class="menurow"
>
<v-list-item
variant="text"
:title="$t(subMenuItem.label, subMenuItem.labelArgs || [])"
:disabled="subMenuItem.disabled == true"
:prepend-icon="subMenuItem.icon"
:append-icon="subMenuItem.selected ? 'mdi-check' : undefined"
@click="(e) => menuItemClicked(e, subMenuItem)"
/>
</div>
</v-list>
Expand All @@ -46,6 +74,11 @@ const items = ref<ContextMenuItem[]>([]);
const posX = ref(0);
const posY = ref(0);

const showSubmenu = ref<boolean>(false);
const subMenuItems = ref<ContextMenuItem[]>([]);
const subMenuPosX = ref(0);
const subMenuPosY = ref(0);

onMounted(() => {
eventbus.on('contextmenu', async (evt: ItemContextMenuDialogEvent) => {
items.value = evt.items;
Expand All @@ -59,6 +92,24 @@ onMounted(() => {
eventbus.off('contextmenu');
});
});

const menuItemClicked = function (
evt: MouseEvent | KeyboardEvent,
menuItem: ContextMenuItem,
) {
if (menuItem.subItems) {
evt.preventDefault();
subMenuItems.value = menuItem.subItems;
(subMenuPosX.value = (evt as PointerEvent).clientX),
(subMenuPosY.value = (evt as PointerEvent).clientY),
(showSubmenu.value = true);
return;
} else if (menuItem.action) {
menuItem.action();
}
show.value = false;
store.dialogActive = false;
};
</script>

<script lang="ts">
Expand Down Expand Up @@ -88,6 +139,7 @@ export interface ContextMenuItem {
disabled?: boolean;
hide?: boolean;
selected?: boolean;
subItems?: ContextMenuItem[];
}

export const showContextMenuForMediaItem = async function (
Expand Down
19 changes: 19 additions & 0 deletions src/layouts/default/PlayerOSD/PlayerFullscreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,25 @@ const openQueueMenu = function (evt: Event) {
? 'mdi-repeat'
: 'mdi-repeat-off',
},
{
label: 'transfer_queue',
icon: 'mdi-swap-horizontal',
subItems: Object.values(api.queues)
.filter((p) => p.queue_id != store.activePlayerQueue?.queue_id)
.map((p) => {
return {
label: p.display_name,
labelArgs: [],
action: () => {
api.queueCommandTransfer(
store.activePlayerQueue!.queue_id,
p.queue_id,
);
store.activePlayerId = p.queue_id;
},
};
}),
},
];
eventbus.emit('contextmenu', {
items: menuItems,
Expand Down
12 changes: 12 additions & 0 deletions src/plugins/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,18 @@ export class MusicAssistantApi {
...args,
});
}
public queueCommandTransfer(
sourceQueue: string,
targetQueue: string,
autoPlay?: boolean,
) {
// Transfer queue to another queue.
this._sendCommand('player_queues/transfer', {
source_queue_id: sourceQueue,
target_queue_id: targetQueue,
auto_play: autoPlay,
});
}

// Player related functions/commands

Expand Down
47 changes: 24 additions & 23 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"mass": "Music Assistant",
"new_playlist_name": "Enter a name for the new playlist",
"no_content": "No items found.",
"no_content_filter": "No items found for the current filter\/search conditions.",
"no_content_filter": "No items found for the current filter/search conditions.",
"no_player": "No player selected",
"off": "Off",
"on": "On",
Expand Down Expand Up @@ -93,7 +93,7 @@
"add_provider": "Add a new provider",
"advanced_settings": "Advanced settings",
"check_docs": "Check out the documentation",
"codeowners": "Authors\/credits",
"codeowners": "Authors/credits",
"config_player": "Configure player: {0}",
"configure": "Configure",
"delete": "Delete",
Expand Down Expand Up @@ -164,7 +164,7 @@
},
"flow_mode": {
"label": "Enable queue flow mode",
"description": "Enable \"flow\" mode where all queue tracks are sent as a continuous audio stream.\nUse for players that do not natively support gapless and\/or crossfading or if the player has trouble transitioning between tracks."
"description": "Enable \"flow\" mode where all queue tracks are sent as a continuous audio stream.\nUse for players that do not natively support gapless and/or crossfading or if the player has trouble transitioning between tracks."
},
"auto_play": {
"label": "Automatically play (resume on power on)",
Expand Down Expand Up @@ -236,8 +236,8 @@
"options": {
"play": "Play artist track(s) now and keep the remaining queue item(s).",
"replace": "Clear the queue and play the artist track(s)",
"next": "Play the item(s) right after the currently played\/buffered item.",
"replace_next": "Clear the queue and play the artist track(s) right after the currently played\/buffered item.",
"next": "Play the item(s) right after the currently played/buffered item.",
"replace_next": "Clear the queue and play the artist track(s) right after the currently played/buffered item.",
"add": "Add the artist track(s) at the end of the queue."
}
},
Expand All @@ -247,8 +247,8 @@
"options": {
"play": "Play album track(s) now and keep the remaining queue item(s).",
"replace": "Clear the queue and play the album track(s)",
"next": "Play the item(s) right after the currently played\/buffered item.",
"replace_next": "Clear the queue and play the album track(s) right after the currently played\/buffered item.",
"next": "Play the item(s) right after the currently played/buffered item.",
"replace_next": "Clear the queue and play the album track(s) right after the currently played/buffered item.",
"add": "Add the album track(s) at the end of the queue."
}
},
Expand All @@ -258,8 +258,8 @@
"options": {
"play": "Play track(s) now and keep the remaining queue item(s).",
"replace": "Clear the queue and play the track(s).",
"next": "Play the track(s) right after the currently played\/buffered item.",
"replace_next": "Clear the queue and play the track(s) right after the currently played\/buffered item.",
"next": "Play the track(s) right after the currently played/buffered item.",
"replace_next": "Clear the queue and play the track(s) right after the currently played/buffered item.",
"add": "Add the track(s) at the end of the queue."
}
},
Expand All @@ -269,8 +269,8 @@
"options": {
"play": "Play playlist track(s) now and keep the remaining queue item(s).",
"replace": "Clear the queue and play the playlist track(s)",
"next": "Play the item(s) right after the currently played\/buffered item.",
"replace_next": "Clear the queue and play the playlist track(s) right after the currently played\/buffered item.",
"next": "Play the item(s) right after the currently played/buffered item.",
"replace_next": "Clear the queue and play the playlist track(s) right after the currently played/buffered item.",
"add": "Add the playlist track(s) at the end of the queue."
}
},
Expand All @@ -280,8 +280,8 @@
"options": {
"play": "Play radio station now and keep the remaining queue item(s).",
"replace": "Clear the queue and play the radio station",
"next": "Play the item(s) right after the currently played\/buffered item.",
"replace_next": "Clear the queue and play the radio station(s) right after the currently played\/buffered item.",
"next": "Play the item(s) right after the currently played/buffered item.",
"replace_next": "Clear the queue and play the radio station(s) right after the currently played/buffered item.",
"add": "Add the radio station(s) at the end of the queue."
}
},
Expand Down Expand Up @@ -322,7 +322,7 @@
},
"icon": {
"label": "Icon",
"description": "Material design icon for this player.\n\nSee https:\/\/pictogrammers.com\/library\/mdi\/."
"description": "Material design icon for this player.\n\nSee https://pictogrammers.com/library/mdi/."
},
"frontend": "User Interface",
"frontend_desc": "Configuration settings for the Music Assistant User Interface (frontend). Note that these settings are stored at a device level.",
Expand Down Expand Up @@ -422,21 +422,21 @@
"tooltip": {
"album_artist_filter": "Toggle album-artist filter",
"explicit": "Explicit",
"filter_library": "Toggle in-library\/favorite filter",
"library": "Toggle in-library\/favorite",
"filter_library": "Toggle in-library/favorite filter",
"library": "Toggle in-library/favorite",
"linked": "This provideritem is linked to the current itemdetails",
"refresh": "Refresh the items listing",
"refresh_new_content": "New content is available, click to refresh the listing",
"search": "Show\/hide search input",
"search": "Show/hide search input",
"select_items": "Select multiple items",
"sort_options": "Sort options",
"toggle_view_mode": "Toggle view mode list\/thumbs",
"toggle_view_mode": "Toggle view mode list/thumbs",
"filter_favorites": "Only show favorites",
"favorite": "Mark\/unmark as favorite",
"favorite": "Mark/unmark as favorite",
"open_provider_link": "Open this item on the provider's website",
"collapse_expand": "Collapse\/expand this listing",
"collapse_expand": "Collapse/expand this listing",
"back": "Back",
"show_menu": "Show\/hide menu",
"show_menu": "Show/hide menu",
"search_filter_active": "Search is currently filtering results",
"play_sample": "Play sample",
"album_type": "Album type",
Expand Down Expand Up @@ -486,5 +486,6 @@
"image_source": "Source",
"image_make_primary": "Make primary",
"update_metadata": "Update metadata",
"cancel": "Cancel"
}
"cancel": "Cancel",
"transfer_queue": "Transfer queue to another player"
}

0 comments on commit c516b8c

Please sign in to comment.