Reputation: 449
I'm new to using the VLC on C# winforms. I installed or added a vlcControl on my C# Project using Vlc.DotNet.Forms.dll
. Below is the guide on how did I install the vlcControl on my Project:
https://github.com/ZeBobo5/Vlc.DotNet/wiki/Using-Vlc.DotNet-in-WinForms
I also tested my RTSP video on my installed VLC player and it's working and I have the RTSP link.
I would like to know how can I play the RTSP on my added vlcControl? Also my RTSP has authentication.
Upvotes: 4
Views: 13819
Reputation: 3979
The wiki link you mentionned is outdated. This link provides more "up-to-date" info : https://github.com/ZeBobo5/Vlc.DotNet/wiki/Getting-started#vlcdotnetforms
You can also look at this sample to see how it works : https://github.com/ZeBobo5/Vlc.DotNet/tree/develop/src/Samples/Samples.WinForms.Minimal
Regarding authentication, you could use the credentials in the URL, like rtsp://user:pass@.../
, but this is considered a bad practice and will result in a warning.
The new way since VLC 3.0 is to use the libvlc dialog API.
With Vlc.DotNet, you use that by implementing IVlcDialogManager
. You can see an example implementation here (for WPF, but the same logic applies to all platforms): https://github.com/ZeBobo5/Vlc.DotNet/blob/develop/src/Samples/Samples.Wpf.Dialogs/MetroDialogManager.cs
For example, you could do something like:
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);
}
}
Use it like this:
mediaPlayer.Dialogs.UseDialogManager(new MyDialogManager(this));
Upvotes: 2
Reputation: 2159
"rtsp://192.168.1.62:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif&user=admin&password=xxx"
).Upvotes: 1