Postby mangokm40 » 18 Mar 2019 14:03
// create the VLC instance
vlcInstance = libvlc_new(argc, args);
...error chk...
// create a VLC media player object
vlcPlayer = libvlc_media_player_new(vlcInstance);
...error chk...
// Get event manager for the player
vlcEventManager = libvlc_media_player_event_manager(vlcPlayer);
// docs claim no error to check
...
libvlc_event_attach(vlcEventManager, libvlc_MediaPlayerEndReached, OnEvent, this);
vlcMediaList = libvlc_media_list_new(vlcInstance);
libvlc_event_attach(vlcEventManager, libvlc_MediaListItemAdded, OnEvent, this);
libvlc_event_attach(vlcEventManager, libvlc_MediaListItemDeleted, OnEvent, this);
....user selects file(s) to play....
....we add the selected file(s) to vlcMediaList....
commandThread = _beginthreadex(... // create/start the UI-command-handling thread
commandThread->Start();
eventThread = _beginthreadex(... // create/start the event-handling thread
eventThread->Start();
libvlc_event_attach(vlcEventManager...
...listen to more events...
libvlc_event_attach(vlcEventManager,
libvlc_MediaPlayerESAdded, // Listen for this event
eventHandlerFunction,
userData);
// get the current media...
libvlc_media_list_lock(vlcMediaList);
libvlc_media_t *currentMedia = libvlc_media_list_item_at_index(vlcMediaList, index); // index changes as we move through the items in the media list
libvlc_media_list_unlock(vlcMediaList);
...
// set the media to be played and start
libvlc_media_player_set_media(vlcPlayer, currentMedia);
libvlc_media_release(currentMedia);
libvlc_media_player_play(vlcPlayer);
/// When the event "libvlc_MediaPlayerESAdded" is fired, we communicate with the event-handler thread
/// through a synchronized-queue. Our event-handling thread then makes a call to
int rc = libvlc_audio_get_mute(vlcPlayer);
/// this call succeeds
....user hits 'stop' button....
/// We sent the request to stop to the command-handler thread through a synch-queue.
/// Our command-handler thread makes a call to
libvlc_media_player_stop( (libvlc_media_player_t*)vlcPlayer );
....user selects file(s) to play....
....we add the selected file(s) to vlcMediaList....
commandThread = _beginthreadex(... // create/start the UI-command-handling thread
commandThread->Start();
eventThread = _beginthreadex(... // create/start the event-handling thread
eventThread->Start();
// start listening to vlc events
libvlc_event_attach(vlcEventManager...
...listen to more events...
libvlc_event_attach(vlcEventManager,
libvlc_MediaPlayerESAdded, // Listen for this event
eventHandlerFunction,
userData);
// get the current media...
libvlc_media_list_lock(vlcMediaList);
libvlc_media_t *currentMedia = libvlc_media_list_item_at_index(vlcMediaList, index); // index changes as we move through the items in the media list
libvlc_media_list_unlock(vlcMediaList);
...
// set the media to be played and start
libvlc_media_player_set_media(vlcPlayer, currentMedia);
libvlc_media_release(currentMedia);
libvlc_media_player_play(vlcPlayer);
/// When the event "libvlc_MediaPlayerESAdded" is fired, we communicate with the event-handler thread
/// through a synchronized-queue. Our event-handling thread then makes a call to
int rc = libvlc_audio_get_mute(vlcPlayer);
// This time, call fails. rc == -1