Skip to content

Commit 526dc99

Browse files
committed
ContentSoundManager upgraded
1 parent e891f8e commit 526dc99

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

contents/soundControll/ContentSoundManager.as

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ package contents.soundControll
2121
private static var lastPlayingMusic:String ;
2222

2323
private static var lastMusicVolume:Number ;
24+
25+
private static var muted:Boolean = false ;
2426

2527
/**2 sound id to swap musics smoothly*/
2628
private static var currentSoundId:uint,
@@ -59,7 +61,7 @@ package contents.soundControll
5961
var soundPose:Number = SoundPlayer.getPlayedPrecent(currentSoundId);
6062
pauseMusic();
6163
SoundMixer.stopAll();
62-
SoundPlayer.addSound(lastPlayingMusic,currentSoundId,true,lastMusicVolume);
64+
SoundPlayer.addSound(lastPlayingMusic,currentSoundId,true,muted?0:lastMusicVolume);
6365
if(firstSoundPlaying)
6466
{
6567
startMusic(soundPose);
@@ -75,10 +77,11 @@ package contents.soundControll
7577
else
7678
{
7779
SaffronLogger.log("soundPose : "+soundPlayingFrom);
78-
SoundPlayer.play(currentSoundId,true,true,soundPlayingFrom);
7980
}
81+
SoundPlayer.play(currentSoundId,true,true,soundPlayingFrom);
8082
lastMusicState.data.state = true ;
8183
lastMusicState.flush();
84+
if(muted)SoundPlayer.volumeContril(currentSoundId,0);
8285
}
8386

8487
public static function pauseMusic():void
@@ -90,17 +93,19 @@ package contents.soundControll
9093

9194
public static function muteMusic():void
9295
{
96+
muted = true ;
9397
SoundPlayer.volumeContril(currentSoundId,0);
9498
}
9599

96100
public static function unMuteMusit():void
97101
{
102+
muted = false
98103
SoundPlayer.volumeContril(currentSoundId,1);
99104
}
100105

101106
public static function changeVolume(volume:Number):void
102107
{
103-
SoundPlayer.volumeContril(currentSoundId,volume);
108+
SoundPlayer.volumeContril(currentSoundId,muted?0:volume);
104109
}
105110

106111
/**This will change the current playing music ( not tested yet )*/
@@ -115,7 +120,7 @@ package contents.soundControll
115120
volume = Contents.homePage.musicVolume ;
116121
}
117122
lastMusicVolume = volume ;
118-
if(musicURL=='' || lastPlayingMusic == musicURL)
123+
if(muted==false && (musicURL=='' || lastPlayingMusic == musicURL))
119124
{
120125
SaffronLogger.log("Music is duplicated on ContentSoundManager.changeMainMusic : "+musicURL);
121126
SoundPlayer.volumeContril(currentSoundId,volume);
@@ -128,13 +133,15 @@ package contents.soundControll
128133
SaffronLogger.log("Pause the sound : "+currentSoundId);
129134
SoundPlayer.pause(currentSoundId);
130135
SaffronLogger.log("Add the sound : "+otherSoundId);
131-
SoundPlayer.addSound(musicURL,otherSoundId,true,volume);
136+
SoundPlayer.addSound(musicURL,otherSoundId,true,muted?0:volume);
132137
if(lastPlayingMusic==null || musicWasPlaying)
133138
{
134139
SaffronLogger.log("lastPlayingMusic : "+lastPlayingMusic);
135140
SaffronLogger.log("musicWasPlaying : "+musicWasPlaying);
136141
SoundPlayer.play(otherSoundId);
142+
137143
}
144+
if(muted)SoundPlayer.volumeContril(currentSoundId,0);
138145

139146
lastPlayingMusic = musicURL ;
140147

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy