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

This forum is about all development around libVLC.
mss555
New Cone
New Cone
Posts: 2
Joined: 30 Aug 2021 21:12

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

Postby mss555 » 30 Aug 2021 21:29

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

mfkl
Developer
Developer
Posts: 739
Joined: 13 Jun 2017 10:41

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

Postby mfkl » 31 Aug 2021 05:24

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); } }
https://mfkl.github.io

mss555
New Cone
New Cone
Posts: 2
Joined: 30 Aug 2021 21:12

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

Postby mss555 » 31 Aug 2021 09:34

Thanks for the prompt response! Yes, it makes more sense to read the chapter info through other means then. I'll do that.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 24 guests