Is there anything else I should be doing before releasing the media player to prevent it from hanging? Here's a concise version of my code:
Code: Select all
vlc_mediaPlayerEventManager = libvlc_media_player_event_manager(vlc_mplayer);
libvlc_event_detach(vlc_mediaPlayerEventManager, libvlc_MediaPlayerPositionChanged, callback, this);
libvlc_event_detach(vlc_mediaPlayerEventManager, libvlc_MediaPlayerPlaying, callback, this);
libvlc_event_detach(vlc_mediaPlayerEventManager, libvlc_MediaPlayerStopped, callback, this);
libvlc_event_detach(vlc_mediaPlayerEventManager, libvlc_MediaPlayerPaused, callback, this);
libvlc_media_player_release(vlc_mplayer);
libvlc_release(vlc_instan);
vlc_mplayer = 0;
vlc_instan = 0;
vlc_instan = libvlc_new(vlc_args.size(), &vlc_args[0]);
libvlc_log_set_file(vlc_instan, file);
vlc_media = libvlc_media_new_path (vlc_instan,pmedia.toUTF8().getAddress());
String subtitlePath = "file:///" + vidPath.substring(0, vidPath.lastIndexOf(TopComponent::sysPathChar)) + TopComponent::sysPathChar + subtitleLanguage + ".srt";
int result = libvlc_media_slaves_add(vlc_media, libvlc_media_slave_type_subtitle, 4, subtitlePath.toUTF8().getAddress());
vlc_mediaEventManager = libvlc_media_event_manager(vlc_media);
libvlc_event_attach(vlc_mediaEventManager,libvlc_MediaParsedChanged,callback,this);
libvlc_media_parse_with_options(vlc_media, libvlc_media_parse_local, 0);
vlc_mplayer = libvlc_media_player_new_from_media (vlc_media);
libvlc_media_release (vlc_media);
vlc_mediaPlayerEventManager = libvlc_media_player_event_manager(vlc_mplayer);
libvlc_event_attach(vlc_mediaPlayerEventManager, libvlc_MediaPlayerPositionChanged, callback, this);
libvlc_event_attach(vlc_mediaPlayerEventManager, libvlc_MediaPlayerPlaying, callback, this);
libvlc_event_attach(vlc_mediaPlayerEventManager, libvlc_MediaPlayerStopped, callback, this);
libvlc_event_attach(vlc_mediaPlayerEventManager, libvlc_MediaPlayerPaused, callback, this);
libvlc_media_player_set_hwnd(vlc_mplayer, vlc_visor->getWindowHandle());