VideoTexture does not play without user interaction, even if muted

Hello, I’m moving from Three.js to Babylon because I need to project a video (without audio) from a spotlight.
Everything work fine, except that the video does not play without user interaction, because of the usual message “play() failed because the user didn’t interact with the document…”

In Three.js I’m used to use directly the html element, as a reference for the video, so it’s enough to add “muted” in the properties of the video tag to play any video without user interaction.

I’ve read in the docs, and it seem that I should be able to manage the VideoTexture.video property as a html element,
so I’ve set “myVideoTexture.video.muted = true”,
before to use it in my spotlight,
but unfortunately it does not help, I still get the error that “play() failed because the user didn’t interact with the document…”

Is there a way to solve this, and have video autoplay in Babylon?
Many thanks!!

Welcome to the community !!!

It should work automatically this is weird and might be a bug.

Could you share a playground with a repro ?

And is this working for you https://playground.babylonjs.com/#ZMCFYA#167

1 Like

Many thanks sebavan, for your kind reply.
Yes, the playground demo is working!
I’ve seen that you’ve put the properties directly in the VideoTexture object, I’ll try to do the same

1 Like

Yes, It did the trick!
Really many thanks!
P.S. What are the 3 “undefined” properties? I can’t read about them in the docs

2 Likes

You can find their descriptions in the API reference: VideoTexture | Babylon.js Documentation (babylonjs.com)

In this case they are generateMipMaps, invertY, and samplingMode. Since they’re optional parameters of the constructor, by leaving them undefined, the VideoTexture will use the default values. But @sebavan needed to put something there, or else he wouldn’t have been able to pass in the settings object, which is the 7th parameter.

PS: Welcome to the Babylon community :slight_smile: We’re thrilled to have you here. I’d love to hear more about your experience switching to Babylon.js - if you’re willing to share your thoughts, shoot me a PM.

3 Likes

Sure, I will
For sure with Babylon my code is much shorter, and it’s much a structured Framework than Three, but I’d have a couple of general questions about post processing.
How can I send you a PM (sorry but I’m a real dummy on this forum…:slight_smile: ?

2 Likes

There are no dumb questions, would be great if you post them publicly so that the entire community can learn from the answers, we can address potential issues and @PirateJC can improve the Doc, yes I always volunteer him for the doc cause I know he likes it :wink:

3 Likes

We’re always happy to answer questions! (Seriously, they’re like fun puzzles to solve :smiley: )