Page 1 of 1

libvlc_media_player_get_chapter_count() returns the correct value only after the player is started

Posted: 30 Aug 2021 21:29
by mss555
Hello all,

Coming from https://github.com/oaubert/python-vlc/issues/189, the issue I'm observing is that libvlc_media_player_get_chapter_count() and libvlc_media_player_get_full_chapter_descriptions() only work after the video started playing, despite the media itself being parsed().

The project I'm working on requires the chapter list to be visible to the user before the video starts playing such that they can start playing the video at a specific chapter directly.

Is that possible or do I have to extract the chapter information from the media upfront through some other means?

Thanks,
Marc

Re: libvlc_media_player_get_chapter_count() returns the correct value only after the player is started

Posted: 31 Aug 2021 05:24
by mfkl
You're better off retrieving the info from other means. I found a workaround using libvlc, but it's really ugly, I don't recommend. Here's some C# that you could translate to python.

Code: Select all

class Program { static MediaPlayer mp; static async Task Main(string[] args) { Core.Initialize(); using var libVLC = new LibVLC(enableDebugLogs: true); using var media = new Media(libVLC, new Uri("Hino dos Aventureiros.mp4")); media.AddOption(":start-paused"); media.AddOption(":no-video"); mp = new MediaPlayer(media); mp.Playing += Mp_Playing; mp.Play(); Console.ReadKey(); } private static void Mp_Playing(object sender, EventArgs e) { var chapterCount = mp.ChapterCount; var chapterDescription = mp.ChapterDescription(0); } }

Re: libvlc_media_player_get_chapter_count() returns the correct value only after the player is started

Posted: 31 Aug 2021 09:34
by mss555
Thanks for the prompt response! Yes, it makes more sense to read the chapter info through other means then. I'll do that.