I've tried all the solutions given in this post "https://github.com/aframevr/aframe/issues/316#issuecomment-170182397" and other similar posts but none of them work.
What I want is to play a video with sound when a user clicks on the video.
I have this glitch below created but it only works if I add the "muted" attribute to the video tag.
https://glitch.com/~grey-acoustic-swordfish
Do you have any ideas to fix this?
Safari doesn't allow autoplay for videos with audio:
A element can use the play() method to automatically play without user gestures only when it contains no audio tracks or has its muted property set to true
You have to start playing the video on user gesture if you want audio. I added video.play()
to your a 2D button handler below:
<button onclick="playVideo();">Play Video</button>
function playVideo() {
var vid = document.querySelector('#video');
vid.muted = false;
vid.play();
}