playbin and volume in C++
Sebastian Dröge
sebastian at centricular.com
Sun Jun 29 23:45:58 PDT 2014
On Mo, 2014-06-30 at 08:29 +0200, Marco Trapanese wrote:
> Hello,
> from command line I type:
>
> gst-launch-1.0 playbin uri=file:///path-to-mp4 audio-sink=alsasink
> volume=1.0
>
> and it just works.
> Now I want to do the same from a C++ application:
>
> GstElement *pipeline;
> GstElement *audiosink;
> GstElement *volume;
>
> pipeline = gst_element_factory_make("playbin", "player");
> g_object_set(G_OBJECT(pipeline), "uri", "path-to-mp4", NULL);
>
> volume = gst_element_factory_make("volume", "volume");
> g_object_set (G_OBJECT(pipeline), "volume", volume, 1.0, NULL);
>
> audiosink = gst_element_factory_make ("alsasink", "audio_sink");
> g_object_set (G_OBJECT(pipeline), "audio-sink", audiosink, NULL);
>
> gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PLAYING);
>
>
> But the audio doesn't work. If I remove the two "volume" lines it works.
> Where is the mistake?
The gst-launch pipeline is different than the pipeline you build
manually here. You don't need to create a separate volume element but
can directly set the "volume" property on playbin.
> When the pipeline is playing will I be able to change the volume just
> calling again the g_object_set with another volume value?
Yes
--
Sebastian Dröge, Centricular Ltd - http://www.centricular.com
Expertise, Straight from the Source
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 949 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20140630/1ffc2995/attachment.sig>
More information about the gstreamer-devel
mailing list