You are not logged in.

1

Thursday, March 30th 2023, 12:42pm

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*

kme

Intermediate

Posts: 264

Location: Belgium

Occupation: Long time coder, product manager and 3D enthousiast

  • Send private message

2

Thursday, March 30th 2023, 1:25pm

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)

Source code

1
2
3
4
5
<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

3

Friday, March 31st 2023, 4:04am

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)

Source code

1
playsound(bgsound, "sound.mp3");



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*

4

Friday, March 31st 2023, 1:17pm


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!

Similar threads