diff --git a/es-core/src/components/VideoVlcComponent.cpp b/es-core/src/components/VideoVlcComponent.cpp index 704c08aca..4378cb9e6 100644 --- a/es-core/src/components/VideoVlcComponent.cpp +++ b/es-core/src/components/VideoVlcComponent.cpp @@ -7,6 +7,7 @@ #include "Settings.h" #include #include +#include #ifdef WIN32 #include @@ -254,8 +255,24 @@ void VideoVlcComponent::startVideo() if (mMedia) { unsigned track_count; - // Get the media metadata so we can find the aspect ratio - libvlc_media_parse(mMedia); + int parseResult; + libvlc_event_t vlcEvent; + + // Asynchronous media parsing + libvlc_event_attach(libvlc_media_event_manager(mMedia), libvlc_MediaParsedChanged, VlcMediaParseCallback, 0); + parseResult = libvlc_media_parse_with_options(mMedia, libvlc_media_parse_local, -1); + + if (!parseResult) + { + // Wait for a maximum of 1 second for the media parsing + for(int i=0; i<200; i++) + { + if ((libvlc_media_get_parsed_status(mMedia))) + break; + SDL_Delay(5); + }; + } + libvlc_media_track_t** tracks; track_count = libvlc_media_tracks_get(mMedia, &tracks); for (unsigned track = 0; track < track_count; ++track) diff --git a/es-core/src/components/VideoVlcComponent.h b/es-core/src/components/VideoVlcComponent.h index c350b8cb3..5a1d381ee 100644 --- a/es-core/src/components/VideoVlcComponent.h +++ b/es-core/src/components/VideoVlcComponent.h @@ -3,6 +3,7 @@ #define ES_CORE_COMPONENTS_VIDEO_VLC_COMPONENT_H #include "VideoComponent.h" +#include struct SDL_mutex; struct SDL_Surface; @@ -61,6 +62,8 @@ private: void setupContext(); void freeContext(); + static void VlcMediaParseCallback(const libvlc_event_t *event, void *user_data) {}; + private: static libvlc_instance_t* mVLC; libvlc_media_t* mMedia;