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
How can I play a sound only the first time I view a scene?
-
-
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 ;-))
-
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/#playsoundNot 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..:
Code
Display More<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
-
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
-
Hi Nupsi,
thanks for the compliment!
Tuur
-
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
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!