You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

loki

Trainee

  • "loki" started this thread

Posts: 72

Location: Berlin

  • Send private message

1

Wednesday, June 23rd 2021, 8:48pm

Paused audio resumes automatically on refocusing browser tour tab in Firefox and Chrome on Win10

Hi all,

my paused sound resumes when using ATL+TAB to get back into the browser tour tab.

Sound plays/streams by onclick on "play hotspot", then gets paused by clicking on "pause hotspot", then I use ALT+TAB to switch to another program, then use ALT+TAB again to get back to the browser tour tab and the problem occurs:
Most of the times (not always), the paused sound resumes automatically without any other user interaction.
Is it possible the browser audio focusing may cause this in Chrome and Firefox?

I tried both streamsound and playsound, tried autopause and autounlock true/false without success.

Maybe a manual autopause action could be a workaround: Once the vtour looses focus, pause the sound and switch play to pause button, but I'm not sure how to achieve this.

Right now I use this rather dirty code:

Source code

1
2
<hotspot name="snd1play" ... enabled="true" visible="true" onclick="destroysound(s2); streamsound(s1, 's1.mp3|s1.webm', false, 1, stopallsounds();); set(hotspot[snd1pause].visible,true); set(hotspot[snd1play].visible,false);" />
<hotspot name="snd1pause" ... enabled="true" visible="false" onclick="pauseallsounds(); set(hotspot[snd1play].visible,true); set(hotspot[snd1pause].visible,false); set(hotspot[snd1play].onclick, togglesound(s1); set(hotspot[snd1pause].visible,true); set(hotspot[snd1play].visible,false); );" />


Could someone share a hint please?

Thank you!
loki

light_line

Intermediate

Posts: 168

Occupation: krpano freelancer || creating ideas & coding them || krpano developer

  • Send private message

2

Friday, July 23rd 2021, 2:20pm

Hi,

This can be a temporary solution:
Save audio playing status in a variable every time you change it.
Then set the latest status of the audio on the "window.onfocus" event.

I hope this helps you.

Hamid

loki

Trainee

  • "loki" started this thread

Posts: 72

Location: Berlin

  • Send private message

3

Thursday, November 18th 2021, 12:09am

Thank you very much Hamid for sending me into the right direction.

With soundinterface setting
autopause="true"

below code works to prevent previously paused sound to automatically resume playing on loosing and then focussing the window/tab again:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
<action name="listentofocuschange" type="Javascript" autorun="onstart">
	<![CDATA[
		document.addEventListener("visibilitychange", event => {
		if (document.visibilityState == "visible") {
				krpano.call('trace(getfocus));');
				krpano.call('if(audio === null, pauseallsounds(););')			
			} else {
				krpano.call('trace(lostfocus));')
			}
		})		 
	]]>
</action>


... with "audio" being my helper var.


Also with autopause="false" this bug happens @Klaus.

Best,
Max

4

Thursday, November 18th 2021, 2:32pm

Hi,

sorry, but I don't understand what you mean or why this is a bug?

Automatically pausing and resuming the sounds when the browser window gets hidden or shown is the intended behavior of the autopause setting.

So far I understand you don't want to the sounds to resume, why?

Best regards,
Klaus

loki

Trainee

  • "loki" started this thread

Posts: 72

Location: Berlin

  • Send private message

5

Thursday, November 18th 2021, 3:31pm

Hi Klaus,

sorry for the confusion.

It seems like the autopause="true" setting overwrites the "pauseallsounds();"-action. Even with autopause="true", I expected that audio, which gets paused by the user would still be paused if the user changes tabs and comes back to the tour-tab. The previously paused audio (e.g. onclick audio-hotspot) would then resume unexpectedly, probably because autopause thinks a previously paused audio needs to resume on focussing the tour-tab again, which is misleading.
Interestingly, the same happens with autopause="false".


Bug behaviour step by step:

For autopause="true":

1: Start sound using streamsound(name, ......);
sound starts as expected

2: Pause sound using pauseallsounds();
sound pauses as expected

3: Switch tab/hide browser (Chrome)
tour looses focus, sound still paused as expected

4: Switch back to tour-tab
tour gets focus, paused audio resumes without user interaction unexpectedly



The same happens for autopause="false":

1: Start sound using streamsound(name, ......);
sound starts as expected

2: Pause sound using pauseallsounds();
sound pauses as expected

3: Switch tab/hide browser (Chrome)
tour looses focus, sound still paused as expected

4: Switch back to tour-tab
tour gets focus, paused audio resumes without user interaction unexpectedly



I can create a test later.


Best,
Max

6

Tuesday, November 23rd 2021, 10:55am

Hi,

right, this was not working.

There was a bug in howler.js related to streamsound() usage, in this case the pause state is not correctly tracked.
This will be fixed in the next release.

Best regards,
Klaus

7

Thursday, August 18th 2022, 8:21pm

Hello,


I have the same problem with all the tours created with Panotour (I have installed latest versions of both PTP and krpano).

Is there any quick fix for this issue?

Best regards,

Lukas