您提到的 wiki 链接已过时。此链接提供更多“最新”信息:https ://github.com/ZeBobo5/Vlc.DotNet/wiki/Getting-started#vlcdotnetforms
您还可以查看此示例以了解其工作原理:https ://github.com/ZeBobo5/Vlc.DotNet/tree/develop/src/Samples/Samples.WinForms.Minimal
关于身份验证,您可以使用 URL 中的凭据,例如rtsp://user:pass@.../
,但这被认为是一种不好的做法,并且会导致警告。
自 VLC 3.0 以来的新方法是使用 libvlc 对话框 API。使用 Vlc.DotNet,您可以通过实现IVlcDialogManager
. 您可以在此处查看示例实现(对于 WPF,但相同的逻辑适用于所有平台):https ://github.com/ZeBobo5/Vlc.DotNet/blob/develop/src/Samples/Samples.Wpf.Dialogs/MetroDialogManager 。CS
例如,您可以执行以下操作:
public class MyDialogManager : IVlcDialogManager
{
public async Task<LoginResult> DisplayLoginAsync(IntPtr userdata, IntPtr dialogId, string title, string text, string username, bool askstore,
CancellationToken cancellationToken)
{
return new LoginResult
{
Username = "username",
Password = "password",
StoreCredentials = false
};
}
public Task DisplayErrorAsync(IntPtr userdata, string title, string text)
{
// You could log errors here, or show them to the user
return Task.CompletedTask;
}
public async Task DisplayProgressAsync(IntPtr userdata, IntPtr dialogId, string title, string text, bool indeterminate, float position,
string cancelButton, CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
public void UpdateProgress(IntPtr userdata, IntPtr dialogId, float position, string text)
{
}
public async Task<QuestionAction?> DisplayQuestionAsync(IntPtr userdata, IntPtr dialogId, string title, string text, DialogQuestionType questionType,
string cancelButton, string action1Button, string action2Button, CancellationToken cancellationToken)
{
return Task.FromResult<QuestionAction?>(null);
}
}
像这样使用它:
mediaPlayer.Dialogs.UseDialogManager(new MyDialogManager(this));