You are not logged in.

1

Wednesday, July 2nd 2014, 4:57pm

Disable Background Sound into a Scene

Hi,

Here is my project :

Scene_1 and Scene_2.

Scene_1 has playsound(backgroundsound).

I'd like to laod the Scene_1 with the "backgroundsound" On. This point is OK.

I'd like to go to Scene_2 and from this scene go back to Scene_1. This point is OK.

Now when I'm in Scene_1, I'd like to turn"backgroundsound" to OFF. This point is DOWN.

So I need to laod a Scene AND disable his Background soundHow can I do this ? *confused*

Here is my code :

Scene_1 :

Quoted

<scene name="Scene_1" title="Scène N°1" onstart="" thumburl="panos/3.tiles/thumb.jpg" lat="48.840388" lng="2.473697" heading="0.0" >

<view hlookat="-247.956" vlookat="0.000" fovtype="MFOV" fov="96.644" maxpixelzoom="5.0" fovmin="70" fovmax="140" limitview="range" vlookatmin="-28.719" vlookatmax="28.719" />

<preview url="panos/3.tiles/preview.jpg" />

<image>
<cube url="panos/3.tiles/pano_%s.jpg" />
<mobile>
<cube url="panos/3.tiles/mobile_%s.jpg" />
</mobile>
</image>

<!-- load the soundinterface plugin -->
<plugin name="soundinterface" url="soundinterface.swf" alturl="soundinterface.js" rootpath="" preload="true" keep="false" mute="false" />

<!-- Diffuser un Son en arrière plan -->
<events name="currentpano" onnewpano="playsound(bgsnd, 'ding_dong_merrily_on_high.mp3|ding_dong_merrily_on_high.ogg', 0);" onremovepano="stopsound(bgsnd);" keep="false"/>

<!-- button to pause the sound: -->
<plugin name="snd" url="soundonoff.png" align="rightbottom" x="270" y="90" alpha="1" scale="1" zorder="-1" onhover="showtext(Son ON/OFF,info-bulle)" onout="tween(alpha,1);" crop="0|0|50|50" onloaded="if(ismobile,set(scale,1));" onclick="pausesoundtoggle(bgsnd); switch(crop, 0|0|50|50, 0|50|50|50);"/>

<hotspot name="GoScene_2" url="icone.png" ath="48.241" atv="-2.693" scale="1" zorder="-1" onclick="loadscene(Scene_2);" />

</scene>
Scene_2

Quoted

<scene name="Scene_2" title="Scène N°2" onstart="" thumburl="panos/3.tiles/thumb.jpg" lat="48.840388" lng="2.473697" heading="0.0" >

<view hlookat="-247.956" vlookat="0.000" fovtype="MFOV" fov="96.644" maxpixelzoom="5.0" fovmin="70" fovmax="140" limitview="range" vlookatmin="-28.719" vlookatmax="28.719" />

<preview url="panos/3.tiles/preview.jpg" />

<image>
<cube url="panos/3.tiles/pano_%s.jpg" />
<mobile>
<cube url="panos/3.tiles/mobile_%s.jpg" />
</mobile>

</image>

<hotspot name="GoScene_1" url="icone.png" ath="48.241" atv="-2.693" scale="1" zorder="-1" onclick="loadscene(Scene_1);" />

</scene>
Thanks for your help. *smile*

2

Thursday, July 3rd 2014, 10:47am

Hi,

you would need to remember/store the state of the sound in this case in some custom variable.

e.g. first create and set a variable in the krpano onstart event:
<krpano ... onstart="set(sound_is_on,true); ...">

then inside your scene in the onnewpano pano event check the state of that variable:
<events name="currentpano" onnewpano="if(sound_is_on, playsound(bgsnd,
'ding_dong_merrily_on_high.mp3|ding_dong_merrily_on_high.ogg', 0));"
onremovepano="stopsound(bgsnd);" keep="false"/>


In the sound button code check that state too and also change it on click:
<plugin name="snd" url="soundonoff.png" align="rightbottom" x="270" y="90" alpha="1" scale="1" zorder="-1" onhover="showtext(Son ON/OFF,info-bulle)" onout="tween(alpha,1);" crop="0|0|50|50" onloaded="if(sound_is_on == false, set(crop, 0|50|50|50)); if(ismobile,set(scale,1));" onclick="pausesoundtoggle(bgsnd); switch(sound_is_on); switch(crop, 0|0|50|50, 0|50|50|50);" />

Best regards,
Klaus