Page 1 of 1

Cannot play second file in playlist

Posted: 02 Dec 2009 18:49
by xrc2
My VLC code could't play second file after finished first. Why?
I need to play all files in playlist one-by-one.

Code: Select all

int main() { libvlc_instance_t *handler = NULL; libvlc_exception_t exceptions; libvlc_media_list_t *medialist = NULL; char cur_dir[MAX_PATH] = {0}; getcwd(cur_dir, MAX_PATH); char plugin_path[MAX_PATH] = {0}; sprintf(plugin_path, "--plugin-path=%s", cur_dir); const char * const vlc_args[] = { "-I", "dummy", "--no-play-and-stop", //"--loop", [b] --This option doen't work for me (maybe it's only for GUI version of VLC)[/b] //"--repeat", [b]--This option doen't work for me (maybe it's only for GUI version of VLC)[/b] plugin_path, "--ignore-config"}; libvlc_exception_init(&exceptions); handler = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args, &exceptions); medialist = libvlc_media_list_new (handler, &exceptions); libvlc_media_t *p_md1 = libvlc_media_new( handler, "d:\\Movies\\video1.mp4", &exceptions ); libvlc_media_t *p_md2 = libvlc_media_new( handler, "d:\\Movies\\video2.mp4", &exceptions ); libvlc_media_list_add_media( medialist, p_md1, &exceptions ); libvlc_media_list_add_media( medialist, p_md2, &exceptions ); libvlc_media_release (p_md1); libvlc_media_release (p_md2); libvlc_media_list_player_t *p_mlp = libvlc_media_list_player_new( handler, &exceptions ); libvlc_media_player_t *p_mp = libvlc_media_player_new( handler, &exceptions ); libvlc_media_list_player_set_media_list( p_mlp, medialist, &exceptions ); libvlc_media_list_player_set_media_player( p_mlp, p_mp, &exceptions ); // PLAY libvlc_media_list_player_play(p_mlp, &exceptions); libvlc_media_list_player_next(p_mlp, &exceptions); //--Try to play next file... int count = libvlc_media_list_count(medialist, &exceptions); //--There are 2 files in playlist. //libvlc_media_list_player_play_item_at_index(listPlayer, 1, &exceptions); //--If uncomment this line then second file will play. return 0; }

Re: Cannot play second file in playlist

Posted: 19 Dec 2009 21:44
by Antivirusvivente
I have the same problem, just i'm using the COM component AxVLC, and not the VLC lib.
I use that code in vb.NET

VLC.playlist.add(URL)
VLC.playlist.play()

Then the component plays only the 1st media of the playlist, to play the 2nd, i must do that:
VLC.playlist.next

Can anyone help us?

PS. Sorry for the bad english, i'm an italian developer and i'm trying to develop a Youtube Player with this COM component

Re: Cannot play second file in playlist

Posted: 09 Jan 2011 20:01
by dungtran88
I'm also have that same issue. I really need help figure this out. Does anyone know or have any idea how I should code this so that it will play the next item in the playlist automatically? Help greatly appreciated.