I have this scene which autoplays a video, but from what I understand, it is against Chrome’s regulations to autoplay sound: PlayCanvas | HTML5 Game Engine
I have started a new scene with a play button in order to get sound, tweaking the video texture js, but can’t seem to get the video to play at all:
I’ve tried to follow this: PlayCanvas | HTML5 Game Engine and searched the forums.
Many thanks in advance for any assistance.
There are several issues with the scene and code:
- The video DOM wasn’t added to the document so it never plays
- The videoTextureBtn doesn’t fire the ‘tv:play’ event so the uiElement script never sets the video texture on the UI elememt
- The UI was set to group type so it doesn’t render anything. It needs to be set to the image type
- I don’t think video.play() can be called without user input. It needs autoplay to be set to true
I fixed up the scene in this project here: https://playcanvas.com/editor/scene/1151251
Thank you SO much! I’ve recreated the scene here: https://playcanvas.com/editor/scene/1151439
It’s strange because, although it’s working, the videotextureBtn script attached to the Root doesn’t contain the added TV Screen material attribute which I thought it needed? Your scene has it, but your script doesn’t… I take it this is not needed?
Screenshot from your scene ID 1151251:
Screenshot from my new scene ID 1151439:
All the best,
The uiElement.js applies the video texture to the UI element so it doesn’t need the material.
I forgot to parse the videoBtn so it’s still has the old attributes in the editor.