2.4 KiB
gst-plugins-spotify
This is a GStreamer plugin to read content from Spotify.
Make sure that your application follows Spotify's design guidelines to respect their legal/licensing restrictions.
Spotify Credentials
This plugin requires a Spotify Premium account.
Provide a Spotify access token with 'streaming' scope using the access-token
property. Such a token can be obtained by completing
Spotify's OAuth flow or using the facility on their
Web SDK getting started guide.
A token can also be obtained using librespot-oauth:
cargo install librespot-oauth --example oauth && oauth
Note, Spotify access tokens are only valid for 1 hour and must be refreshed for usage beyond that.
It is therefore advisable to also use the cache-credentials
property. On first usage, your access token is exchanged for a reusable credentials blob and
stored at the location specified by this property. Once obtained, that credentials blob is used for login and any provided access-token
is ignored.
Unlike Spotify access tokens, the user's credentials blob does not expire. Avoiding handling token refresh greatly simplifies plugin usage.
If you do not set cache-credentials
, you must manage refreshing your Spotify access token so it's valid for login when the element starts.
You may also want to cache downloaded files, see the cache-files
property.
spotifyaudiosrc
The spotifyaudiosrc
element can be used to play a song from Spotify using its Spotify URI.
gst-launch-1.0 spotifyaudiosrc access-token=$ACCESS_TOKEN track=spotify:track:3i3P1mGpV9eRlfKccjDjwi ! oggdemux ! vorbisdec ! audioconvert ! autoaudiosink
The element also implements an URI handler which accepts credentials and cache settings as URI parameters:
gst-launch-1.0 playbin3 uri=spotify:track:3i3P1mGpV9eRlfKccjDjwi?access-token=$ACCESS_TOKEN\&cache-credentials=cache\&cache-files=cache