I cannot get a youtube video to play with LibVLCSharp. I followed the documented example but it still doesn't work. I have a checkbox on my form (chkYouTube) with which I indicate that the url is a youtube url.
Any other links work fine (which uses the else part of the if statement below).
At one stage I could get it going outside of my control, but even that I could not do again.
_mp.Play() returns true but MediaPlayer.IsPlaying is false
videoView2 just shows blank. No errors.
private async void btnGo_Click(object sender, EventArgs e)
{
if (chkYouTube.Checked)
{
using (LibVLC _libVLC = new LibVLC("--preferred-resolution=240"))
{
Media media = new Media(_libVLC, txtURL.Text.Trim(), FromType.FromLocation);
await media.Parse(MediaParseOptions.ParseNetwork);
using (MediaPlayer _mp = new MediaPlayer(media.SubItems.First()))
{
videoView2.MediaPlayer = _mp;
videoView2.Visible = true;
videoView2.BringToFront();
var r = _mp.Play();
}
}
}
else
{
LibVLC _libVLC = new LibVLC("--preferred-resolution=240");
Media media = new Media(_libVLC, txtURL.Text.Trim(), FromType.FromLocation);
MediaPlayer _mp = new MediaPlayer(_libVLC);
_mp.EncounteredError += _mp_EncounteredError;
videoView2.MediaPlayer = _mp;
videoView2.Visible = true;
videoView2.BringToFront();
_mp.Play(media);
}
}