My initialization code currently looks like this:
Code: Select all
vlcInstance=libvlc_new(0,NULL);
QString rtsp_url="rtsp://<my_rtsp_source>";
libvlc_media_t *vlcMedia=libvlc_media_new_location(vlcInstance,rtsp_url.toUtf8());
vlcPlayer=libvlc_media_player_new_from_media(vlcMedia);
libvlc_audio_set_volume(vlcPlayer,75);
vlcEventManager=libvlc_media_player_event_manager(vlcPlayer);
libvlc_event_attach(vlcEventManager,libvlc_MediaPlayerPlaying,
&play_event_handler,this);
libvlc_event_attach(vlcEventManager,libvlc_MediaPlayerEncounteredError,
&vlc_error_handler,this);
libvlc_media_player_set_xwindow(vlcPlayer, ui->videoframe->winId());
libvlc_media_player_play(vlcPlayer);
Code: Select all
if (vlcPlayer!=nullptr){
if(libvlc_media_player_is_playing(vlcPlayer)){
libvlc_media_player_stop(vlcPlayer);
}
libvlc_media_player_release(vlcPlayer);
vlcPlayer=nullptr;
}
if(vlcInstance!=nullptr){
libvlc_release(vlcInstance);
vlcInstance=nullptr;
}