如何使用libvlcsharp读取DVD播放器的标题和每个标题的章节



我正在开发一台c#dvd播放器。我使用libvlcsharp,在指定标题和章节时可以从磁盘播放视频。问题是我需要知道一个标题/章节的列表,用户可以从中选择。我试过使用Media.Passe,它显示它已经被解析,但曲目列表和其他信息是空的。

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

有没有任何方法可以使用libvlcsharp来获取这些信息,或者我是否被迫使用命令行ffmpeg来检索这些信息?

媒体播放器上有一些属性和方法可能会提供您需要的信息。它不在媒体轨道上。

/// <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)

如果需要的话,libvlcsharp单元测试有一些示例用法。

最新更新