The essential part of the code I use
Code: Select all
vlcMedia := libvlc_media_new_path(vlcInstance, PAnsiChar(T));
p_em := libvlc_media_event_manager(vlcMedia);
Event := TEvent.Create(nil, False, False, '');
libvlc_event_attach(p_em, NativeInt(libvlc_MediaParsedChanged), ParseChangeEvent, Pointer(Event));
libvlc_media_parse_with_options(vlcMedia, libvlc_media_parse_local, 0);
Event.WaitFor(CTimeout);
libvlc_event_detach(p_em, NativeInt(libvlc_MediaParsedChanged), ParseChangeEvent, Pointer(Event));
if libvlc_media_get_parsed_status(vlcMedia) = libvlc_media_parsed_status_done then
Len := libvlc_media_get_duration(vlcMedia);
I've tried another approach with playing the file first, then stopping.
libvlc_media_player_get_length - returns the correct duration
libvlc_media_get_duration - returns garbage