mirror of
https://github.com/jpochyla/psst.git
synced 2026-04-27 07:25:52 +03:00
[PR #332] [MERGED] feat: add support for local file playback #484
Labels
No labels
api
bug
build
documentation
duplicate
enhancement
good first issue
help wanted
idea
invalid
linux
lowprio
macos
pull-request
upstream
windows
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/psst#484
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/jpochyla/psst/pull/332
Author: @superhawk610
Created: 8/26/2022
Status: ✅ Merged
Merged: 9/22/2022
Merged by: @jpochyla
Base:
master← Head:feat/local-file-playback📝 Commits (2)
63613e3add support for local file playback72d3a3bcore: Minor adjustment in the LocalItemRegistry📊 Changes
11 files changed (+500 additions, -401 deletions)
View changed files
📝
Cargo.lock(+233 -371)📝
psst-core/Cargo.toml(+1 -0)📝
psst-core/src/audio/mod.rs(+1 -0)➕
psst-core/src/audio/probe.rs(+74 -0)📝
psst-core/src/error.rs(+3 -1)📝
psst-core/src/item_id.rs(+71 -2)📝
psst-core/src/metadata.rs(+3 -3)📝
psst-core/src/player/file.rs(+66 -17)📝
psst-core/src/player/item.rs(+35 -6)📝
psst-gui/src/main.rs(+1 -0)📝
psst-gui/src/webapi/local.rs(+12 -1)📄 Description
This PR adds support for local file playback. Local files have been visible in the UI, but not playable, since #136.
Resolves #326.
Implementation
The primary struct used to identify a track for playback is
MediaPath, which is composed ofitem_ida unique, opaque identifier, meaningful only to Spotify's APIfile_ida unique identifier that points into the local filesystem cachefile_formatan enum indicating what codec this file should be played withdurationastd::time::Durationindicating the track's lengthFor remote files hosted on CDN, Spotify's API provides
item_id,file_format, andduration, and the app storesfile_idif/when it begins streaming the track. For local files, we don't needfile_id, since the track already resides on disk, so it's left blank (Default::default()). We're able to guessfile_formatanddurationby using Symphonia'sProbe. Local files don't have anitem_idon Spotify's end, so we have to generate our own. To do this, this PR includesLocalItemRegistry, which is a singleton that registersPathBufs corresponding to local tracks and associates each with a unique ID that may be used in place of Spotify's item ID.I can confirm that this works locally, though actually getting Symphonia to playback all tracks is a bit hit or miss (using an album from Bandcamp, about half the tracks work flawlessly and the other half won't play).
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.