Local music support
Is your feature already implemented in the latest master?
Please go through the Features README page to make sure your request feature hasn't been implemented.
Is your feature request related to a problem? Please describe. No, it isn't.
Describe the solution you'd like
Much appreciated if you (or your contributors) add support to local music. I know that's not wise (because it named spotify_player not local_player or something else), but it would be fun to play local music.
Describe alternatives you've considered
I used
termusic. It is good, but not as perfect as this project. I don't like its UI. I think spotify_player is more interesting for me
Additional context It would be good to add local music (I don't have anything else to say😁)
i would like to see this implemented as well
Same here. Some of the artists I follow don't upload to spotify, so I instead have their music downloaded, and played through spotify locally. It would be nice to do that with this program as well!
Well, you can use termusic.
I am using it. But I like the spotify_player's UI more.
I am mentioning @aome510 because it may cause him/her to see the issue (The software is provided "as is", it means I cannot sue him/her because for not implementing the feature)
I will open a PR soon
Thanks for raising. Somewhat related to #62. I don't have any plan to implement local music or offline feature cause I don't really need one.
That said, feel free to implement one and open a PR. PRs are welcomed and highly appreciated!
I have been looking at this a little bit, though I can't make any promises... It seems like the issue is that we pass the list of tracks returned by the Spotify API into filter_map(try_from_playlist_item) which calls try_from_full_track_with_date, which itself returns None any track that has no id set: https://github.com/aome510/spotify-player/blob/a445674b6f6664626e1a2e0d30675f3c9831fa60/spotify_player/src/state/model.rs#L385
Local files may not have an id according to rspotify_model.
My initial thoughts are that we need to map these differently with enough information so that they can be played via some alternative mechanism. I've not studied the API closely enough yet to know what that is.
It is easy enough to display local files and send a request to play these to librespot (although I have done some hacks which will need cleaning up). However, librespot doesn't currently support local playback, so that will need to be implemented first. See: https://github.com/librespot-org/librespot/discussions/1525
Or we can use another library, such as rodio just for playing local files, and adding local file support as an optional feature. Which it can be enabled or disabled by default.
Then we can add a parameter to the app’s settings, which can be enabled with —l/—-local and settings file.
Just noticed that this issue is still active and I thought I might chime in here.
Or we can use another library, such as
rodiojust for playing local files,
I've done pretty much exactly this here https://github.com/KUHLwasStolen/spotify-player/tree/local-playback ...
and adding local file support as an optional feature.
... however, making it an optional feature looks pretty hard to me (at least with the approach that I took) as I had to make some major changes to spotify_player. (Not saying it's impossible, but a ton of #[cfg(feature = "local")] would be required haha)
That said, feel free to check out my fork and leave feedback.
Currently all the basic local player functionality works and I also enabled the app to start without Internet connection or login (otherwise local playback wouldn't really make sense if it still depends on Spotify/Internet anyway).
Currently supported formats are mp3 and flac, but after some more testing I can extend the support to all the usual audio formats.
Next up on my to-do list is implementing shuffle and repeat functionality.
Edit: the local player is accessible by default via pressing g o ("go offline") and it will start in the directory specified in the local_library_root config option.
Yes, I didn't consider the possibility that you could just extend the app with local audio capability directly. Nice work!
Does your player allow playing local files that are in an existing Spotify playlist? That to me would be the main advantage of doing this via Spotify.
I also want to say that I am looking into adding local files support into librespot but it looks like it could be a long road with lots of changes to the library. I have however made an initial PR to lay the groundwork with some refactoring in how the app handles URIs.
That said, maybe I misunderstood the issue a little bit - perhaps the original poster was actually talking about a separate local player (as you have made) and https://github.com/aome510/spotify-player/issues/333 is more about Spotify local files specifically (which is what I am focusing on)
Does your player allow playing local files that are in an existing Spotify playlist? That to me would be the main advantage of doing this via Spotify.
No, my player works completely independent from Spotify, at the moment. I'm not quite sure how I would handle this tbh in the event of a device switch, because music files may be local to only one device. Or how does the official app handle this?
perhaps the original poster was actually talking about a separate local player (as you have made) and https://github.com/aome510/spotify-player/issues/333 is more about Spotify local files specifically
I think I'll also ask for more details in #333, as I'm now a bit confused myself haha
how does the official app handle this?
Any tracks it can't find on the same device it shows as greyed out and refuses to play them with an error pop up if you try.
This is the only thing stopping me from switching from official client! I have many songs from bandcamp downloaded as mp3s which are integrated into my spotify client, and since I have the files on my phone and PC it is very convenient and they work just like normal spotify songs.
Hello, I opened a PR (#833) now.
I currently just added a member called local_player and that member prints a message. Contributions are welcome.