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 :

    Scene_2

    Thanks for your help. *smile*

  • 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

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!