简体   繁体   中英

Spotify play full tracks workaround?

I am trying to build an application that plays Spotify songs, among other features. I am well aware that the Spotify API doesn't provide web access to full tracks on desktop. However, I'd still like to explore other workarounds or options. My web app is built on Python and Javascript, so any solution would have to work with those. However if you know of any solutions in other languages, feel free to post those as well. Here are the things I'd like to try before giving up:

  1. Are there any unofficial APIs that provide access to full length tracks? For example, I found this guy https://pyspotify.mopidy.com/en/latest/ . Would that one or any other ones be viable to use? I know some of these become quickly deprecated as Spotify updates, but it's best to have something to play for now rather than nothing.

  2. Hidden Spotify play button: Would there be a way for me to embed the play button next to each track's name as a hidden element, and then when I click on my own play button an event is triggered that "clicks" the Spotify play button? I would maybe trigger a click event on the div that the Spotify button is stored in, or have the browser detect its coordinates and click on it. If this seems like a viable option, how would that code even look?

  3. Play track directly to Spotify: I would definitely be ok with clicking on a track and have it play on the user's desktop client or web player. I've been using an app called Unision that does just that. When you try to play a Spotify song, it opens up my desktop Spotify and begins playing the song automatically. If they did it, then there must be a way. How would that solution look like?

Any feedback would be greatly appreciated.

Thank you for reading my post.

Arielle from Spotify here. At the time of this question, there was no way to play full tracks in the web. For those of you looking at this in the future, you can now use the Web Playback SDK!

https://beta.developer.spotify.com/documentation/web-playback-sdk/

The Web Playback SDK is client-side JavaScript library which allows you to create a new player in Spotify Connect and play any audio track from Spotify in the browser via Encrypted Media Extensions. It's the same technology we use to power our Web Player experience.

Some things you can do with the Web Playback SDK:

  • Create a new player in Spotify Connect
  • Stream an audio track in supported browsers
  • Get metadata for the current track
  • Get metadata about the user's listening session
  • Control local playback (pause, resume, volume, etc)

Happy hacking!

I solved this by using the third option and calling the track URI with the parameter autoplay:true. So to call a particular song from my code, I would just refer to the following URL:

spotify:track:3rTIcUMMP2Ez33DfjJlb9e:autoplay:true

which makes the song start playing automatically on the Spotify Client.

If anyone has any suggestions as to how to approach ideas 1 and 2, those are still options worth looking into.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM