spotifyaudiosrc usage

Guillaume Desmottes guillaume at desmottes.be
Tue Jun 14 07:15:39 UTC 2022


On 3/06/22 20:23, Jonas Kvinge via gstreamer-devel wrote:
> I use playbin in a music player with a custom audio sink setup using a 
> bin. The basic pipeline is: queue2 ! audioconvert ! audiosink where I 
> add the queue to the bin using a ghost pad then set the bin on the 
> playbin pipeline. I assume I can not use playbin with spotifyaudiosrc 
> so I have to set up a different pipeline when playing spotify songs?


Yes, but we have some plan to make it possible to use spotifyaudiosrc 
from playbin,
see https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/204


>
> I tried the following code:
>
> gst_init(nullptr, nullptr); GstElement *spotifyaudiosrc = 
> gst_element_factory_make("spotifyaudiosrc", "spotifyaudiosrc0"); 
> g_object_set(G_OBJECT(spotifyaudiosrc), "track", 
> "spotify:track:3i3P1mGpV9eRlfKccjDjwi", nullptr); 
> g_object_set(G_OBJECT(spotifyaudiosrc), "username", "user", nullptr); 
> g_object_set(G_OBJECT(spotifyaudiosrc), "password", "pass", nullptr); 
> GstElement *oggdemux = gst_element_factory_make("oggdemux", 
> "oggdemux0"); g_signal_connect(G_OBJECT(oggdemux), "pad-added", 
> G_CALLBACK(&PadAdded), this); GstElement *vorbisdec = 
> gst_element_factory_make("vorbisdec", "vorbisdec0"); GstElement 
> *audioconverter = gst_element_factory_make("audioconvert", 
> "audioconvert0"); vorbisdec_ = vorbisdec; GstElement *audiosink = 
> gst_element_factory_make("alsasink", "alsasink"); 
> g_object_set(G_OBJECT(audiosink), "device", "hw:1,0", nullptr); 
> gst_element_link(spotifyaudiosrc, oggdemux); 
> gst_element_link(oggdemux, vorbisdec); gst_element_link(vorbisdec, 
> audioconverter); gst_element_link(audioconverter, audiosink); 
> gst_element_set_state(spotifyaudiosrc, GST_STATE_PLAYING);
>
You need to create a pipeline and put all the elements inside.

Also, oggdemux src pads are dynamics so you need to connect it to 
vorbisdec in the pad added callback,.

See for example 
https://gstreamer.freedesktop.org/documentation/tutorials/basic/dynamic-pipelines.html?gi-language=c


     G.



More information about the gstreamer-devel mailing list