How to play Audio CDs with libVLC?

This forum is about all development around libVLC.
Kevin Hoang
Blank Cone
Blank Cone
Posts: 43
Joined: 25 Mar 2010 05:14

How to play Audio CDs with libVLC?

Postby Kevin Hoang » 19 Mar 2011 05:39

I try to play audio CD same as DVD way, but it does not works. So, how to play a Audio CDs and get list of track?

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: How to play Audio CDs with libVLC?

Postby Jean-Baptiste Kempf » 19 Mar 2011 10:16

The same way.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

Kevin Hoang
Blank Cone
Blank Cone
Posts: 43
Joined: 25 Mar 2010 05:14

Re: How to play Audio CDs with libVLC?

Postby Kevin Hoang » 19 Mar 2011 12:35

Yes, the same. I got an error message: main stream error: cannot pre fill buffer. But I try with compiled vlc program it works well

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: How to play Audio CDs with libVLC?

Postby sherington » 21 Mar 2011 07:50

Yes, the same. I got an error message: main stream error: cannot pre fill buffer. But I try with compiled vlc program it works well
I see the same problem as you, works in vlc, not with libvlc. According to the logs it reads the CD TOC, does a CDDB look-up, I can see the right number of tracks reported in the log, but the audio fails to play.

The only way I can play cd audio is to explicitly specify the track via a media option, e.g. in my Java bindings I do this:

Code: Select all

mediaPlayer.playMedia("cdda:///dev/cdrom", ":cdda-track=6");
Without ":cdda-track=" I get the same error you get.

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: How to play Audio CDs with libVLC?

Postby sherington » 21 Mar 2011 11:43

The code for this is in vlc/modules/access/cdda.c.

There are two code paths, one that plays a specific track and the other that plays nothing but creates sub-items for each track. This is done in the GetTracks() function.

What I have seen happen is if you "play" an mrl like "cdda:///dev/cdrom" you get an "error" callback (other access modules give you a "finished" callback). If you then get the sub-items from the media player (using libvlc_media_subitems) you get one sub-item for each track on the cd. If you get the mrl for the each sub-item it says something like "cdda:///dev/cdrom" - there is no track information (no artist, title etc even though that has been retrieved), but behind the scenes that media instance does know which track it relates to. I think libvlc_media_get_meta will give you the track information.

If you then use the libvlc_media_t instance from the sub-item, you can play it. However, I don't get seem to get any "finished" event when the sub-item has finished playing, so I don't know when to play the next sub-item, making it useless at the moment.

That's as much as I understand about this right now. Maybe someone else knows better.
Last edited by sherington on 21 Mar 2011 17:17, edited 1 time in total.

Kevin Hoang
Blank Cone
Blank Cone
Posts: 43
Joined: 25 Mar 2010 05:14

Re: How to play Audio CDs with libVLC?

Postby Kevin Hoang » 21 Mar 2011 15:31

As you said, I try to parse a audio CD to get list of sub-items like this:

libvlc_media_t* media = libvlc_media_new_location(instance, "cdda:///dev/cdrom3");
libvlc_media_list_t* mediaList = libvlc_media_subitems(media);

But, I don't know why mediaList is NULL value after call libvlc_media_subitems. something wrong with my code?

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: How to play Audio CDs with libVLC?

Postby sherington » 21 Mar 2011 16:14

As you said, I try to parse a audio CD to get list of sub-items like this:

libvlc_media_t* media = libvlc_media_new_location(instance, "cdda:///dev/cdrom3");
libvlc_media_list_t* mediaList = libvlc_media_subitems(media);

But, I don't know why mediaList is NULL value after call libvlc_media_subitems. something wrong with my code?
I believe you have to play the media to get the sub-items populated - play and then wait for the "error" callback.

Kevin Hoang
Blank Cone
Blank Cone
Posts: 43
Joined: 25 Mar 2010 05:14

Re: How to play Audio CDs with libVLC?

Postby Kevin Hoang » 21 Mar 2011 16:28

You are absolutely right! Thank you very much!

Rémi Denis-Courmont
Developer
Developer
Posts: 15266
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: How to play Audio CDs with libVLC?

Postby Rémi Denis-Courmont » 21 Mar 2011 17:01

I guess it returns error because there is absolutely no data, but I don't have time to look at it. Patch welcome.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: How to play Audio CDs with libVLC?

Postby Jean-Baptiste Kempf » 21 Mar 2011 19:58

Patch welcome.
+1
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 5 guests