LibVLCSharp not playing youtube videos

This forum is about all development around libVLC.
karnati8
New Cone
New Cone
Posts: 9
Joined: 03 Nov 2020 13:14

LibVLCSharp not playing youtube videos

Postby karnati8 » 03 Nov 2020 14:15

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);
}

}

mfkl
Developer
Developer
Posts: 740
Joined: 13 Jun 2017 10:41

Re: LibVLCSharp not playing youtube videos

Postby mfkl » 04 Nov 2020 03:46

Hi,

Please share your full code in a git repo (and especially the Youtube URL used).
https://mfkl.github.io

karnati8
New Cone
New Cone
Posts: 9
Joined: 03 Nov 2020 13:14

Re: LibVLCSharp not playing youtube videos

Postby karnati8 » 04 Nov 2020 08:05

Here is the full test project.

https://github.com/karnati8/Research

mfkl
Developer
Developer
Posts: 740
Joined: 13 Jun 2017 10:41

Re: LibVLCSharp not playing youtube videos

Postby mfkl » 04 Nov 2020 10:53

and especially the Youtube URL used
https://mfkl.github.io

karnati8
New Cone
New Cone
Posts: 9
Joined: 03 Nov 2020 13:14

Re: LibVLCSharp not playing youtube videos

Postby karnati8 » 04 Nov 2020 18:32

The url is in the code that I've shared.
Here it is anyway:
https://www.youtube.com/watch?v=dQw4w9WgXcQ

mfkl
Developer
Developer
Posts: 740
Joined: 13 Jun 2017 10:41

Re: LibVLCSharp not playing youtube videos

Postby mfkl » 09 Nov 2020 04:11

The url is in the code that I've shared.
Sorry, couldn't find it.

Code: Select all

http error: local stream 1 error: Cancellation (0x8) http error: local stream 1 error: Stream closed (0x5) lua error: Couldn't extract youtube video URL, please check for updates to this script
VLC 3.0.11 cannot play it. You can either update the lua script in your installation (replace your version with https://github.com/videolan/vlc-3.0/blo ... outube.lua) or wait for 3.0.12 which should fix this.
https://mfkl.github.io

karnati8
New Cone
New Cone
Posts: 9
Joined: 03 Nov 2020 13:14

Re: LibVLCSharp not playing youtube videos

Postby karnati8 » 09 Nov 2020 08:35

Thanks mfkl,
I have replaced the lua with this version before but it does not make a difference in my test app.

Just to be clear, although all youtube videos play very well inside VLC on my machine, NO youtube videos plays in my test app that I've shared above. It is not specific to this url. I can choose any youtube url, it won't play in my test app.

Have you had a chance to run my test app on your machine and run it with any youtube url? Can you see the problem?

mfkl
Developer
Developer
Posts: 740
Joined: 13 Jun 2017 10:41

Re: LibVLCSharp not playing youtube videos

Postby mfkl » 10 Nov 2020 04:52

Have you had a chance to run my test app on your machine and run it with any youtube url? Can you see the problem?
No, it doesn't build. Its missing files, try a clean clone and restore.

Code: Select all

error MSB3552: Resource file "Properties\Resources.resx" cannot be found.
https://mfkl.github.io

karnati8
New Cone
New Cone
Posts: 9
Joined: 03 Nov 2020 13:14

Re: LibVLCSharp not playing youtube videos

Postby karnati8 » 10 Nov 2020 08:51

Ah, I forgot the Properties folder. Added it. Please try again.

mfkl
Developer
Developer
Posts: 740
Joined: 13 Jun 2017 10:41

Re: LibVLCSharp not playing youtube videos

Postby mfkl » 10 Nov 2020 10:05

don't dispose of the mediaplayer or libvlc objects, it stops everything.

do enable verbose logs, otherwise you can't begin to troubleshoot the problem.

do use another youtube URL, OR update the lua script.

https://github.com/karnati8/Research/pull/1
https://mfkl.github.io

karnati8
New Cone
New Cone
Posts: 9
Joined: 03 Nov 2020 13:14

Re: LibVLCSharp not playing youtube videos

Postby karnati8 » 10 Nov 2020 13:05

Thank you mfkl! It works now. I've blindly used the documented example without thinking that the using would dispose the mediaplayer before it started to play the video.
Much appreciated.

JHustermeier
New Cone
New Cone
Posts: 1
Joined: 11 Nov 2020 06:38

Re: LibVLCSharp not playing youtube videos

Postby JHustermeier » 11 Nov 2020 06:45

I found a good Video explaining this for Windows: https://www.youtube.com/watch?v=dao90mUeeEI

My Problem: want to make it work on MAC OS,
can anyone tell me how to update the LUA Script on MAC OS?

A step by step would be really helpfull, for I think I could not manage it without.

Thanks a Lot in advance.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 11 guests