Sie sind nicht angemeldet.

Lieber Besucher, herzlich willkommen bei: krpano.com Forum. Falls dies Ihr erster Besuch auf dieser Seite ist, lesen Sie sich bitte die Hilfe durch. Dort wird Ihnen die Bedienung dieser Seite näher erläutert. Darüber hinaus sollten Sie sich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutzen Sie das Registrierungsformular, um sich zu registrieren oder informieren Sie sich ausführlich über den Registrierungsvorgang. Falls Sie sich bereits zu einem früheren Zeitpunkt registriert haben, können Sie sich hier anmelden.

1

Donnerstag, 23. März 2023, 13:15

How can I play a sound only the first time I view a scene?

I have a tour with 20 scenes. Each scene has a specific background-sound (something like an explanation...). I only want to hear the sound for each scene when viewing it the first time. This was working up to ver. 1.20, after updating to ver. 1.21 now the sound is playing every time I open the same scene again. Is there any change in the soundinterface? Is there any easy way to change this?
I'm not a coding-profi, so it would be great if somebody could help me...
Thnx

2

Donnerstag, 23. März 2023, 15:54

You need to set a variable for each scene in the onstart-event of the scene:

onstart="sound_scene_1();"

<action name="sound_scene_1">
if(scene_sound_1 !== 1,playsound(...the sounddfile you want to play...);set(scene_sound_1,1));
</action>

And this for every scene. You could it also automate for each scene, but that would need a little coding-experience on your site ;-))

Tuur

Erleuchteter

Beiträge: 3 839

Wohnort: Netherlands

Beruf: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Nachricht senden

3

Freitag, 24. März 2023, 00:49

I would try something like:
Action cow..
scn= xml.scene;

If(!scn.soundplayed, playsound(blablatomato);
scn.soundplayed = true;
);

blablatomato could be the scenes audiotit="%VIEWER%/sounds/scene_14".mp3.. etc see https://krpano.com/plugins/soundinterface/#playsound

Not to forget to call the cow action onnewscene(!)

.. but i've been playing balls and beers tonight so i might be wrong..

..EDIT:
I was wrong..

this should work when you call te sounds 'scene_1.mp3 etc..:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
	<events name="dosound" keep="true" onnewscene="DoSound();" /> 
	<action name="DoSound">
		tween(plugin[soundinterface].volume, 0,1,,stopallsounds();
			snd = '%VIEWER%/sounds/' + xml.scene +'.mp3';
			sp = *scene[*xml.scene].played;
			if(!sp,
				playsound(scsound,*snd);
				tween(plugin[soundinterface].volume, 1);
				scene[*xml.scene].played = true; 
			);
		);
	</action>
	
	<plugin name="soundinterface" keep="true"
			url="%VIEWER%/plugins/soundinterface.js"
			preload="true"
			rootpath=""
			volume="1.0"
			mute="false"
			panningmodel="simple"
			worldscale="1.0"
			autopause="true"
			autounlock="true"
			/>


Hope it helps,

Tuur *thumbsup*

Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von »Tuur« (24. März 2023, 10:35)


4

Mittwoch, 29. März 2023, 19:45

Now that´s what I call elegant!

I use something very similar to check automatically which sounds should be played for each scene. But your version is way more efficient *thumbup*

Tuur

Erleuchteter

Beiträge: 3 839

Wohnort: Netherlands

Beruf: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Nachricht senden

5

Donnerstag, 30. März 2023, 00:18

Hi Nupsi,

thanks for the compliment!

Tuur *thumbsup*

6

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

Hi Nupsi, Hi Tuur,
Thanks a lot for your help. Sorry for the late ansewer, but I was a bit ill the last days. Finaly I did Tuurs solution, and what should I say? PERFECT SUPER AND REALLY ELEGANT!!!
Have a nice weekend and thanks so much....
Thomas