Page 1 of 1
How to play Audio CDs with libVLC?
Posted: 19 Mar 2011 05:39
by Kevin Hoang
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?
Re: How to play Audio CDs with libVLC?
Posted: 19 Mar 2011 10:16
by Jean-Baptiste Kempf
The same way.
Re: How to play Audio CDs with libVLC?
Posted: 19 Mar 2011 12:35
by Kevin Hoang
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
Re: How to play Audio CDs with libVLC?
Posted: 21 Mar 2011 07:50
by sherington
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.
Re: How to play Audio CDs with libVLC?
Posted: 21 Mar 2011 11:43
by sherington
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.
Re: How to play Audio CDs with libVLC?
Posted: 21 Mar 2011 15:31
by Kevin Hoang
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?
Re: How to play Audio CDs with libVLC?
Posted: 21 Mar 2011 16:14
by sherington
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.
Re: How to play Audio CDs with libVLC?
Posted: 21 Mar 2011 16:28
by Kevin Hoang
You are absolutely right! Thank you very much!
Re: How to play Audio CDs with libVLC?
Posted: 21 Mar 2011 17:01
by RĂ©mi Denis-Courmont
I guess it returns error because there is absolutely no data, but I don't have time to look at it. Patch welcome.
Re: How to play Audio CDs with libVLC?
Posted: 21 Mar 2011 19:58
by Jean-Baptiste Kempf