Global audio on/off button

  • This isn't a question but I thought it might help other amateur coders. I spent hours trying to work this out by reading others' threads and the documentation https://krpano.com/plugins/soundinterface/#actions .

    My tour featured audio commentary for each of the 11 scenes and I wanted a global button to turn it on/off rather than for each scene.

    I found the soundinterface plugin and added the necessary code near the top of my xml page

    Code
    <plugin name="soundinterface" url="%SWFPATH%/plugins/soundinterface.swf" alturl="%SWFPATH%/plugins/soundinterface.js" volume="1.0" preload="true"/>

    I then started each scene as follows:

    Code
    <scene name="scene_1" title="1" onstart="" thumburl="panos/1.tiles/thumb.jpg" onstart="stopallsounds();playsound(auto,sounds/1.mp3);" >

    First I tried it without stopallsounds(); and they played on top of each other. This simply stops whatever is playing before loading the new audio file.

    I then needed a global button and that was the bit I struggled with. Eventually I found this example being used on a thread:

    Code
    <plugin name="sound-off" url="hotspots/nav-s-off.png"   style="button" devices="!iphone+!ipad" x="+200" onhover="showtext(Commentary OFF, buttonstyle);" visible="true" onclick="set(plugin[soundinterface].mute,true);set(plugin[sound-off].visible,false); set(plugin[sound-on].visible,true); "/>
    	<plugin name="sound-on" url="hotspots/nav-s.png"   style="button" devices="!iphone+!ipad" x="+200" onhover="showtext(Commentary ON, buttonstyle);" visible="false" onclick="set(plugin[soundinterface].mute,false);set(plugin[sound-on].visible,false); set(plugin[sound-off].visible,true); "/>

    I just thought it might help someone else to see this and wanted to give something to this group for a change *squint*

  • Have a problem in the Global audio on/off button with attribute
    "mute"

    In Flash working and on the simulator iPad also work, but in iPad the sound
    not disabled.

  • Hi,

    thanks for the report, I see the problem - the mute internally works by setting the volume of all sounds to 0 - but on iPhone and iPad it's not possible to change the sound volume, there the code is ignored by Safari - there only the user itself can change the sound volume level by the volume buttons...

    I will change that in the next release and pause the sounds when muting them on iPhone/iPad,

    best regards,
    Klaus

Participate now!

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