How to fix : play() failed because the user didn't interact with the document first?

  • I created a background music that automatically plays when the page loads but sometimes it can't play and gives me an error like this "Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first. https://goo.gl/xX8pDD" How to fix it? this site always plays background music without error, I don't know how they do it , example : https://techvr360.com/demo/hongduc_v5/vi_tour/index.html

    *thumbup* Woody *thumbup* KEEP MOVING FORWARD *thumbup*

  • That site is not playing any sound either if you don't interact with the pano.

    I would put something in a mousedown event.

    something like (untested)

    Code
    <events name="ondownevent" ondown="playbackgroundsound()" /> 
    
    
    <action name="playbackgroundsound" >
    playsound(bgsound, "sound.mp3");
    </action name>


    I'm not a fan of playing sound in the backgroudn tho. If a site does that, my response is to close it.
    I believe it is more common / user friendly to ask to enable background sound and start playing if the answer is yes.

    gr,
    Kristof

  • Thank you very much for your help. Let me try it , Hope it work *love*

    *thumbup* Woody *thumbup* KEEP MOVING FORWARD *thumbup*


  • I'm not a fan of playing sound in the backgroudn tho. If a site does that, my response is to close it.
    I believe it is more common / user friendly to ask to enable background sound and start playing if the answer is yes.

    Same here. It should be. Probibited by all browsers. Don't do that music s**t please!

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!