[READ-ONLY] Mirror of https://github.com/probablykasper/ferrum. Music library app for Mac, Linux and Windows ferrum.kasper.space
electron linux macos music music-library music-player napi windows
0

Configure Feed

Select the types of activity you want to include in your feed.

Allow pressing play to start current playlist

Kasper (Sep 27, 2024, 7:42 AM +0200) 965299a8 980dece7

+39 -12
+1
CHANGELOG.md
··· 18 18 - Make time & volume sliders look ok 19 19 - Small design updates to tracklist header & filter textbox 20 20 - Respect user's locale time 21 + - Allow pressing play to start the current playlist 21 22 - Make sidebar not focusable by mouse 22 23 - Fix covers updates sometimes not being reflected in the queue panel 23 24 - Fix dragging tracks to up next/autoplay queue boundary
+14 -6
src/components/Player.svelte
··· 19 19 import Slider from './Slider.svelte' 20 20 import { get_flattened_tracklists, handle_selected_tracks_action } from '@/lib/menus' 21 21 import { ipc_renderer } from '@/lib/window' 22 + import { tracks_page_item_ids } from './TrackList.svelte' 22 23 23 24 async function playing_context_menu() { 24 25 const playing = queue.getCurrent() ··· 110 111 > 111 112 </div> 112 113 </button> 113 - <button on:click={previous} tabindex="-1" on:mousedown|preventDefault> 114 + <button class="previous" on:click={previous} tabindex="-1" on:mousedown|preventDefault> 114 115 <svg 115 116 xmlns="http://www.w3.org/2000/svg" 116 117 class="parent-active-zoom" ··· 124 125 </svg> 125 126 </button> 126 127 127 - <button class="play-pause" on:click={play_pause} tabindex="-1" on:mousedown|preventDefault> 128 + <button 129 + class="play-pause" 130 + on:click={play_pause} 131 + class:cannot-play={$tracks_page_item_ids.length === 0} 132 + tabindex="-1" 133 + on:mousedown|preventDefault 134 + > 128 135 {#if $time_record.paused} 129 136 <svg 130 137 xmlns="http://www.w3.org/2000/svg" ··· 152 159 {/if} 153 160 </button> 154 161 155 - <button on:click={skip_to_next} tabindex="-1" on:mousedown|preventDefault> 162 + <button class="next" on:click={skip_to_next} tabindex="-1" on:mousedown|preventDefault> 156 163 <svg 157 164 xmlns="http://www.w3.org/2000/svg" 158 165 class="parent-active-zoom" ··· 281 288 background-color: var(--player-bg-color) 282 289 &:not(:hover).dev 283 290 background: linear-gradient(90deg, hsl(205deg 60% 15%), hsl(280deg 60% 15%)) 284 - .stopped .middle 285 - pointer-events: none 286 - opacity: 0.25 291 + .stopped 292 + .time-bar, .side-controls, .previous, .next, .play-pause.cannot-play 293 + pointer-events: none 294 + opacity: 0.35 287 295 .left 288 296 width: 30% 289 297 display: flex
+3 -1
src/components/TrackList.svelte
··· 14 14 } 15 15 }) 16 16 export const group_album_tracks = writable(true) 17 + export const tracks_page_item_ids = writable<TracksPage['itemIds']>([]) 17 18 </script> 18 19 19 20 <script lang="ts"> ··· 39 40 import { dragged } from '../lib/drag-drop' 40 41 import * as dragGhost from './DragGhost.svelte' 41 42 import VirtualListBlock, { scroll_container_keydown } from './VirtualListBlock.svelte' 42 - import type { ItemId, Track } from 'ferrum-addon/addon' 43 + import type { ItemId, Track, TracksPage } from 'ferrum-addon/addon' 43 44 import Cover from './Cover.svelte' 44 45 import Header from './Header.svelte' 45 46 import { writable } from 'svelte/store' ··· 69 70 groupAlbumTracks: $group_album_tracks, 70 71 }) 71 72 } 73 + $: $tracks_page_item_ids = tracks_page.itemIds 72 74 73 75 function handle_action(action: SelectedTracksAction) { 74 76 if (selection.items.size === 0) {
+21 -5
src/lib/player.ts
··· 1 - import { derived, writable } from 'svelte/store' 1 + import { derived, get, writable } from 'svelte/store' 2 2 import type { Writable } from 'svelte/store' 3 3 import { clamp } from './helpers' 4 4 import quit from './quit' 5 - import { add_play, add_play_time, add_skip, get_track, paths, read_cover_async } from '@/lib/data' 5 + import { 6 + add_play, 7 + add_play_time, 8 + add_skip, 9 + get_track, 10 + get_track_ids, 11 + paths, 12 + read_cover_async, 13 + } from '@/lib/data' 6 14 import type { Track, TrackID } from '../../ferrum-addon' 7 15 import { ipc_renderer, join_paths } from './window' 8 16 import { queue, set_new_queue, next as queueNext, prev as queuePrev } from './queue' 17 + import { tracks_page_item_ids } from '@/components/TrackList.svelte' 9 18 10 19 const audio = new Audio() 11 20 let is_stopped = true ··· 185 194 } 186 195 187 196 export function play_pause() { 188 - if (is_stopped) return 189 - else if (audio.paused) start_playback() 190 - else pause_playback() 197 + if (is_stopped) { 198 + if (get(tracks_page_item_ids).length > 0) { 199 + const all_track_ids = get_track_ids(get(tracks_page_item_ids)) 200 + new_playback_instance(all_track_ids, 0) 201 + } 202 + } else if (audio.paused) { 203 + start_playback() 204 + } else { 205 + pause_playback() 206 + } 191 207 } 192 208 193 209 export function reload() {