How to use libvlcsharp to read titles and chapters per title for a DVD player

255 Views Asked by At

I'm working on a c# dvd player. I'm using libvlcsharp and am able to play video from the disk when specifying the title and chapter. The problem is I need to know a list of titles/chapters that are available to have the user pick from. I've tried using the Media.Parse on it and it shows that it has been parsed, but the track list and other information is empty.

    _mediaPlayer.Media = new Media(_libVLC, new Uri(@"dvd:///e:"));
    await _mediaPlayer.Media.Parse(MediaParseOptions.ParseLocal);
    MessageBox.Show(_mediaPlayer.Media.Tracks.GetLength(0).ToString());

Is there any way to use libvlcsharp to get this information or am I forced to shell out to a command line ffmpeg to retrieve it?

1

There are 1 best solutions below

0
mfkl On

There are a few properties and method on the mediaplayer that likely provide the info you need. It is not in the media tracks.

/// <summary>
/// Get the description of available titles.
/// </summary>
public TrackDescription[] TitleDescription

/// <summary>
/// Get the full description of available chapters.
/// </summary>
/// <param name="titleIndex">Index of the title to query for chapters (uses current title if set to -1)</param>
/// <returns>Array of chapter descriptions.</returns>
public ChapterDescription[] FullChapterDescriptions(int titleIndex = -1)

/// <summary>
/// Get the description of available chapters for specific title.
/// </summary>
/// <param name="titleIndex">selected title</param>
/// <returns>chapter descriptions</returns>
public TrackDescription[] ChapterDescription(int titleIndex)

The libvlcsharp unit tests have some example usage, if you need.