VL.CEF: Autoplay youtube video not working?

I am trying to do a simple way of playing a youtube video and getting it back as a Stride Texture. One simple way is to use VL.CEF and render the Stride texture.

I convert the URL of the youtube video from something like:

https://www.youtube.com/watch?v=AzzYgu9Ns-w

into this:

https://www.youtube.com/embed/AzzYgu9Ns-w?autoplay=1&loop=1&rel=0&controls=0&fs=0&iv_load_policy=3

If I click on it in a browser it opens fullscreen and autoplays and loops. It also tries to hide some of the player UI.

But for some reason it wont autoplay in VL.CEF.

Anybody know why this might happen and how I might convince CEF to play the video?

youtube_vl.CEF.vl (11.9 KB)

Only one observation: firefox doesn’t auto play your link either - maybe there’s some privacy setting involved?

Okay, weird. It autoplays in Chrome and Brave and I thought CEF was based on Chromium?

I’ll add it as an issue in Github, since I think its quite a limitation if it is restricting something that it shouldn’t.

Search for --autoplay-policy=no-user-gesture-required (& CEF)

Okay, I see this in the CEF Bitbucket:

So the question would be, how can I pass that argument to Chromium that is inside CEF?

Right, I learned a lot about autoplay :)

This was pretty interesting. Didn’t know there was a media engagement score (just open about://media-engagement in any chrome-based browser).

Okay, so it seems like CEF/Chromium needs some sort of user interaction unless you start it with commandline arguments.

So the question would be if VL.CEF can somehow start chromium with that commandline parameter and since CEF is often used with no user interaction possible, if it shouldn’t be the default?

Seems like this is the way to do it in CEF:

You can put “command_line->AppendSwitchWithValue("autoplay-policy", "no-user-gesture-required");“ inside OnBeforeCommandLineProcessing,I verified it and it succeeded.

Maybe this can be exposed in VL.CEF similar to how you can SetAudioMuted.

image

@Elias Do you think that is feasible?

Yeah okay, so you can get it to work with my example above if you add “&mute=1” as an argument to the URL. It then autoplays the video, which would be fine.

Now the issue seems that CEF can’t actually play youtube videos properly. It plays like the first frame, then another frame like 2 seconds later and then just gives up.

https://recordit.co/EKWdyUCIXD

So I guess that is the bigger issue.

Any ideas why it would struggle with that?

Maybe a codec issue?
Afaik youtube is using VP9.
You should be able to check the supported codecs loading this site: https://html5test.com

Okay, seems like enabling Shared Texture fixes it. Strange that something like https://www.testufo.com/ runs at around 50fps even with Shared Texture off (and around 100fps with it on), but for a Youtube video it runs at like 3 frames total. Can’t even put it in fps, since it literally will render around 3 frames and then stop.

Weird.

Well if it’s a web kiosk I’ve would suggest to use C# UWP instead. I made few apps a month ago without that much issues… you can even block the urls with some navigation starting event… They have this webview2 that uses chromium… The only problem there is to remove window header, but that also possible to suppress…

@antokhio I am only using the texture and ideally the sound of the playing youtube videos. There is no user interaction, so I need the videos to autoplay in fullscreen. Youtube videos are just an alternative source to playing videos from files in our application.

It’s basically working okay now with shared texture enabled, but I have to start the videos with mute=1 so they autoplay. If I could get CEF to set the autoplay policy, which apparently is possible with a command line argument, I guess it would work fine. But I have not seen a way to pass that argument using VL.CEF.

Sorry for replying so late. It should’ve been possible to pass that command line argument to vvvv.exe itself, for example vvvv.exe --autoplay-policy=no-user-gesture-required should do the trick, since we currently pass all arguments to CEF itself.

In any case, upcoming builds of VL.CEF will add this flag internally as you suggested so there will be no need to pass it manually and your example should just work.

2 Likes