Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local media playback #208

Open
ikirmitz opened this issue Apr 14, 2020 · 15 comments
Open

Local media playback #208

ikirmitz opened this issue Apr 14, 2020 · 15 comments
Labels
enhancement New feature or request

Comments

@ikirmitz
Copy link

Is there a way for librespot-jave to playback local content the same way Spotify desktop does?
If yes, can you please provide a link or some instructions on how to configure it?
Many thanks

@devgianlu
Copy link
Member

Right now there is no way to reproduce local tracks because I never thought that would be useful. Could you describe your usa case/scenario? Just to understand how it could work.

@ikirmitz
Copy link
Author

I've set up librespot-java to run as a service on a headless raspberry pi. The audio is then routed through darkice to a local icecast server that works as a mini radio station for other devices in the house.
I have an extensive collection of bootlegs, mashups and recordings of live DJ sets that I would like to be able to play back along with spotify tracks. I can do that with the regular spotify desktop client and I can even create playlists with mixed content.

The actual files can reside on a network share or locally on the pi.
Let me know if you need more info

@devgianlu devgianlu added the enhancement New feature or request label Apr 14, 2020
@devgianlu
Copy link
Member

I never thought of using a network share, but it could work this way. The problem before was that the client only communicates (I think) the name of the file which would make pretty unpractical synchronizing tracks between two devices without additional software.

I don't think there's any way to create a "custom" local track, so the user has to add the mounted network share to the local files on the desktop client and then setup librespot to search the local tracks on said network share.

Not too bad.

@ikirmitz
Copy link
Author

Yes, I suppose in my case the network share should be served by the pi itself but in theory any network share will work?
I'm not a JAVA dev but I do node/js/perl etc. I can help you test/debug the enhancement. My only problem is I haven't managed to compile librespot-java from source on the pi and I couldn't find any instructions on how to cross-compile on my Ubuntu desktop.

FYI I've created a simple nodejs script that runs as a service and hooks on the librespot-java api. Its role is to update the icecast metadata whenever it receives the metadataAvailable event since darkice doesn't seem to support this natively.

@devgianlu
Copy link
Member

My only problem is I haven't managed to compile librespot-java from source on the pi and I couldn't find any instructions on how to cross-compile on my Ubuntu desktop.

With Java there is no need to cross-compile. Just run mvn clean package to create the JAR executables, then you can copy them over to your Pi.

@ikirmitz
Copy link
Author

Oh that's nice, cheers

@ikirmitz
Copy link
Author

I just wanted to add something I only just recently discovered: the ability for mobile spotify clients to "download" playlists with local files created on a desktop client. Maybe of use to you

https://support.spotify.com/us/using_spotify/features/listen-to-local-files/

@Zageron
Copy link

Zageron commented Feb 26, 2021

This does seem very useful, similar to how the android works. I load files on my desktop, create a playlist, then click download on a the playlist on my phone, now I can listen to those tracks on my phone through Spotify. Would be useful to have some sort of mechanism to tell this app to do this with some playlists.

@devgianlu
Copy link
Member

I have not forgotten about this! I am in the process of implementing local files playback.

@Zageron
Copy link

Zageron commented Apr 20, 2021

I have not forgotten about this! I am in the process of implementing local files playback.

How will we get to decide which playlists or songs to download to the device?

@devgianlu
Copy link
Member

devgianlu commented Apr 20, 2021

How will we get to decide which playlists or songs to download to the device?

For the moment you'll have to point librespot-java to where you have your local files and it'll take them from there. Following the shared drive idea.

Having the download functionality would require to reverse engineer the transfer protocol, so that's enough for a start.

@devgianlu
Copy link
Member

devgianlu commented Apr 20, 2021

Turns out this is harder than what I thought, the Spotify client doesn't communicate to librespot-java where the file really is, but just some metadata (name, artist, album, duration).

Reversing the transfer protocol might be needed to understand where the files are.

@ikirmitz
Copy link
Author

First of all thanks for keep looking at this, great news!
I don't have much insight to offer as to how the spotify tranfer protocol really works but what I have noticed is that spotify will auto-detect if local files in a playlist are present on your system based on some kind of hash. What I mean by that is:

  1. On a PC with spotify client installed, point the client to a folder with local media
  2. Add some of these files in a playlist
  3. Share this playlist with any other user (including yourself on a different PC). They wont be able to download or play your files local files... but
  4. Share the files with the user. They need to download them to a folder and configure spotify client to play local media from that folder
  5. Now spotify can play these files from the playlist. No extra config required. As long as the files are identical, it will play them

Hope that helps

@devgianlu
Copy link
Member

devgianlu commented Apr 21, 2021

Mhh, I wonder if the client indexes the folder and matches the files based on the metadata (that's not optimal because there's nothing preventing two tracks from having the exact same metadata). But I cannot see any identifier being transmitted with the tracks. It makes sense for it not to have the full path to file because of security reasons, but at least the filename. Or maybe I am missing some feature flag in the client configuration.

UPDATE
I was indeed missing the audio/local supported type, but adding that doesn't change anything.

The Spotify Desktop app logs aren't very useful, all that is reported is Wifi Sync Connected to .... There is clearly traffic between the two devices.

@ikirmitz
Copy link
Author

I can definitely do some tests and see if the match is based on metadata and/or filename. Will keep you posted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants