Sie sind nicht angemeldet.

1

Donnerstag, 30. März 2023, 12:42

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

Fortgeschrittener

Beiträge: 310

Wohnort: Belgium

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

  • Nachricht senden

2

Donnerstag, 30. März 2023, 13:25

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)

Quellcode

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

Freitag, 31. März 2023, 04:04

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)

Quellcode

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

Freitag, 31. März 2023, 13:17


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!