[PR #332] [MERGED] feat: add support for local file playback #484

Closed
opened 2026-02-28 14:33:10 +03:00 by kerem · 0 comments
Owner

📋 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: masterHead: feat/local-file-playback


📝 Commits (2)

  • 63613e3 add support for local file playback
  • 72d3a3b core: 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 of

  • item_id a unique, opaque identifier, meaningful only to Spotify's API
  • file_id a unique identifier that points into the local filesystem cache
  • file_format an enum indicating what codec this file should be played with
  • duration a std::time::Duration indicating the track's length

For remote files hosted on CDN, Spotify's API provides item_id, file_format, and duration, and the app stores file_id if/when it begins streaming the track. For local files, we don't need file_id, since the track already resides on disk, so it's left blank (Default::default()). We're able to guess file_format and duration by using Symphonia's Probe. Local files don't have an item_id on Spotify's end, so we have to generate our own. To do this, this PR includes LocalItemRegistry, which is a singleton that registers PathBufs 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.

## 📋 Pull Request Information **Original PR:** https://github.com/jpochyla/psst/pull/332 **Author:** [@superhawk610](https://github.com/superhawk610) **Created:** 8/26/2022 **Status:** ✅ Merged **Merged:** 9/22/2022 **Merged by:** [@jpochyla](https://github.com/jpochyla) **Base:** `master` ← **Head:** `feat/local-file-playback` --- ### 📝 Commits (2) - [`63613e3`](https://github.com/jpochyla/psst/commit/63613e3946b7599ee9eaef66ad11b31229d2d31a) add support for local file playback - [`72d3a3b`](https://github.com/jpochyla/psst/commit/72d3a3b91a738a5ed2b24932dd582bd203414df4) core: Minor adjustment in the LocalItemRegistry ### 📊 Changes **11 files changed** (+500 additions, -401 deletions) <details> <summary>View changed files</summary> 📝 `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) </details> ### 📄 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 of - `item_id` a unique, opaque identifier, meaningful only to Spotify's API - `file_id` a unique identifier that points into the local filesystem cache - `file_format` an enum indicating what codec this file should be played with - `duration` a `std::time::Duration` indicating the track's length For remote files hosted on CDN, Spotify's API provides `item_id`, `file_format`, and `duration`, and the app stores `file_id` if/when it begins streaming the track. For local files, we don't need `file_id`, since the track already resides on disk, so it's left blank (`Default::default()`). We're able to guess `file_format` and `duration` by using Symphonia's `Probe`. Local files don't have an `item_id` on Spotify's end, so we have to generate our own. To do this, this PR includes `LocalItemRegistry`, which is a singleton that registers `PathBuf`s 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). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-28 14:33:10 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/psst#484
No description provided.