You are not logged in.

jl-krp

Intermediate

  • "jl-krp" started this thread

Posts: 154

Location: Bath

Occupation: Panographer - hobby and commercial

  • Send private message

1

Tuesday, September 17th 2013, 8:17pm

mute - on/off button in scenes

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

Alexey Tkachenko

Professional

Posts: 770

Location: Russian Federation

Occupation: Interpreting, Building virtual tours

  • Send private message

2

Tuesday, September 17th 2013, 8:26pm

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..?
Regards,

Alexey

jl-krp

Intermediate

  • "jl-krp" started this thread

Posts: 154

Location: Bath

Occupation: Panographer - hobby and commercial

  • Send private message

3

Tuesday, September 17th 2013, 8:33pm

mute button in scenes

Yes that is what I'd like to do
JL

Alexey Tkachenko

Professional

Posts: 770

Location: Russian Federation

Occupation: Interpreting, Building virtual tours

  • Send private message

4

Tuesday, September 17th 2013, 8:40pm

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?
Regards,

Alexey

jl-krp

Intermediate

  • "jl-krp" started this thread

Posts: 154

Location: Bath

Occupation: Panographer - hobby and commercial

  • Send private message

5

Tuesday, September 17th 2013, 9:07pm

whole or part

I expect your whole solution will have much useful info, so yes please!

JL

Alexey Tkachenko

Professional

Posts: 770

Location: Russian Federation

Occupation: Interpreting, Building virtual tours

  • Send private message

6

Tuesday, September 17th 2013, 9:44pm

Okay, I'm not a proger though, but my solution worked and that's enough *smile*

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:

Source code

1
<scene name="first_pano" title="Entrance" musictag="rock" > 


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:

Source code

1
<events name="music" keep="true" onnewpano="sound_check();" />


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":

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<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:

Source code

1
onstart="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:

Source code

1
2
3
4
5
6
7
onover="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 *tongue*

Sooo... the button gets the "current_music" value and stops or resumes exactly it.


I think, that's it *tongue* *tongue*
Regards,

Alexey

jl-krp

Intermediate

  • "jl-krp" started this thread

Posts: 154

Location: Bath

Occupation: Panographer - hobby and commercial

  • Send private message

7

Wednesday, September 18th 2013, 8:50am

Many Thanks!

Alexey
That is very generous of you!
I will study it and report back.

JL

Similar threads