Hello
I can make panos with audio and the useful mute button.
But I cannot get this to appear in scenes - advice appreciated!
Regards
JL
mute - on/off button in scenes
-
-
Hi! Do you mean that you have multiple sounds in a VT and mute button should mute corresponding sound depending on what sound is currently playing? Or..?
-
Yes that is what I'd like to do
JL -
I've done this in two of my VTs with great number of panos and several music files for various scenes.
Have you managed the proper sound switching between the scenes and need only sound mute button or you need the whole solution?
-
I expect your whole solution will have much useful info, so yes please!
JL
-
Okay, I'm not a proger though, but my solution worked and that's enough
Let's say we have a tour where 10 panos have sound "rock", one pano has sound "blues" and one "folk".
I intoduced musictags within the scene node:
That'll help us to define what music to play.
Now we need to have an 'onnewpano' event which will trigger the 'sound_check' action:
While checking the music we have to trace the two conditions:
a) what music must be played on the new scene. Above we intoduced the "musictag" which helps us define the music.
b) if this music is shared among several panos, then we must know if the music has already been triggered and is now being played or is this the first time this very sound must be played.As our "rock" music is played in 10 panos, let's intoduce the "rock_music" variable which will be set to "running" or "notrunning" depending on the conditions.
So now we can create an action called "sound_check":
Code
Display More<action name="sound_check"> if(rock_music == notrunning, if(scene[get(xml.scene)].musictag == rock, playsound(rock, '%SWFPATH%/sound/rock.mp3',0);set(current_music,rock);set(rock_music, running); );); ifnot(scene[get(xml.scene)].musictag == rock, stopsound(rock);set(rock_music, notrunning); ); if(scene[get(xml.scene)].musictag == blues, wait(0.1);playsound(blues, '%SWFPATH%/sound/blues.mp3',0);set(current_music,blues); , stopsound(blues); ); if(scene[get(xml.scene)].musictag == folk, wait(0.1);playsound(folk, '%SWFPATH%/sound/folk.mp3',0);set(current_music,folk); , stopsound(folk); );
In the very beginning of the tour I started the sound immediately by:
Codeonstart="loadscene(get(scene[0].name));playsound (rock,'%SWFPATH%/sound/rock.mp3',0);set(rock_music, running);wait(blend);">
So,now we have to create the button code to mute the sound. In the "sound_check();" action we have the "current_music" variable. This will help us to define what sound will be muted.
I preferred to make the two methods for sound muting: in Flash it is "soft" - the sound interface is just tweened in volume to 0 in couple of seconds and the sound actually never stops playing. This is good when a user want to turn on the sound and it appears gradually to the full volume and doesn't hurt ears. In html5 it's not possible, so we must just stop the current sound.Here is the needed code for the button:
Codeonover="onoverA();" onoverA="showtext('Mute');" onoverB="showtext('Sound on');" onclick="onclickA();" onclickA="if(device.flash, tween(plugin[soundinterface].volume,0,2,EaseOutSine), pausesound(get(current_music)));set(onclick, onclickB(););set(onover, onoverB(););set(crop,'375|0|25|25');set(onovercrop,'375|25|25|25');" onclickB="if(device.flash, tween(plugin[soundinterface].volume,0.5,2,EaseOutSine),resumesound(get(current_music)));set(onclick, onclickA(););set(onover, onoverA(););set(crop,'350|0|25|25');set(onovercrop,'350|25|25|25');" />
Nevermind the crop and onovercrop values, yours are different anyway
Sooo... the button gets the "current_music" value and stops or resumes exactly it.
I think, that's it
-
Alexey
That is very generous of you!
I will study it and report back.JL
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!