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;
}