[gst-devel] Playing Mp3 help

basavaraj P basavarajp82 at gmail.com
Thu Nov 19 09:40:46 CET 2009


Hello,

Following is code which plays mp3 using playbin

*  /* set up */
  play = gst_element_factory_make ("playbin2", "play");
  g_object_set (G_OBJECT (play), "uri",
"file:///home/basavaraj/Music/JabSeTereNaina.mp3", NULL);

  bus = gst_pipeline_get_bus (GST_PIPELINE (play));
//  gst_bus_add_watch (bus, my_bus_callback, loop);
  gst_object_unref (bus);

  gst_element_set_state (play, GST_STATE_PLAYING);
*

Following is code which does not play mp3. Please help me what all plugins
we need to connect and
how to find their capabilities

*  /* Create gstreamer elements */
  GstElement* pipeline = gst_pipeline_new ("audio-player");
  GstElement* source   = gst_element_factory_make ("filesrc",
"file-source");
  GstElement* demuxer  = gst_element_factory_make ("mpegdemux2",
"mpeg-demuxer");
  GstElement* decoder  = gst_element_factory_make ("flump3dec",
"fluendo-decoder");
//  GstElement* decoder = gst_element_factory_make("decodebin",
"decoderbin");
  GstElement* conv     = gst_element_factory_make ("audioconvert",
"converter");
  GstElement* sink     = gst_element_factory_make ("autoaudiosink",
"audio-output");

  if (!pipeline || !source || !demuxer || !decoder || !conv || !sink) {
    g_printerr ("One element could not be created. Exiting.\n");
    return -1;
  }

  /* Set up the pipeline */

  /* we set the input filename to the source element */
//  g_object_set (G_OBJECT (source), "uri",
"file:///home/basavaraj/Music/Jab.mp3", NULL);
  g_object_set (G_OBJECT (source), "location",
"/home/basavaraj/Music/Jab.mp3", NULL);

  /* we add a message handler */
  GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_add_watch (bus, bus_call, loop);
  gst_object_unref (bus);

  /* we add all elements into the pipeline */
  /* file-source | mp3-demuxer | mp3-decoder | converter | alsa-output */
  gst_bin_add_many (GST_BIN (pipeline),
                    source, demuxer, decoder, conv, sink, NULL);

  /* we link the elements together */
  /* file-source -> mp3-demuxer ~> mp3-decoder -> converter -> alsa-output
*/
  gst_element_link (source, demuxer);
  g_signal_connect (demuxer, "pad-added", G_CALLBACK (on_pad_added),
decoder);

  /* Set the pipeline to "playing" state*/
  g_print ("Now playing: %s\n", argv[1]);
  gst_element_set_state (pipeline, GST_STATE_PLAYING);
*

Thanks in advance,
Basavaraj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20091119/48261cef/attachment.htm>


More information about the gstreamer-devel mailing list