Results 1 to 2 of 2
-
March 4th, 2012, 04:46 PM #13Registered User
postsAs3 equalizer & volume control help needed!
I was wondering if somebody could help me adding an equalizer and volume control for the following code.
Code://number that is redefined when the pause button is hit var stopPoint:Number = 1; //a true or false value that is used to check whether the sound is currently playing var isPlaying:Boolean; //think of the soundchannel as a speaker system and the sound as an mp3 player var soundChannel:SoundChannel = new SoundChannel(); var sound:Sound = new Sound(new URLRequest("demo.mp3")); //you should set the xstop and xplay values to match the instance names of your stop button and play/pause buttons xstop.addEventListener(MouseEvent.CLICK, clickStop); xplay.addEventListener(MouseEvent.CLICK, clickPlayPause); soundChannel = sound.play(); isPlaying = true; function clickPlayPause(evt:MouseEvent) { if (isPlaying) { stopPoint = soundChannel.position; xplay.gotoAndStop(2); soundChannel.stop(); isPlaying = false; } else { soundChannel = sound.play(stopPoint); isPlaying = true; xplay.gotoAndStop(1); } } function clickStop(evt:MouseEvent) { if (isPlaying) { soundChannel.stop(); isPlaying = false; } }
-
March 4th, 2012, 08:40 PM #23Registered User
postsOk i managed to create the volume control, but is not working, can somebody help me with it.
Here is my code.
//number that is redefined when the pause button is hit
var stopPoint:Number = 1;
//a true or false value that is used to check whether the sound is currently playing
var isPlaying:Boolean;
//think of the soundchannel as a speaker system and the sound as an mp3 player
var soundChannel:SoundChannel = new SoundChannel();
var sound:Sound = new Sound(new URLRequest("http://176.9.42.221:8000/;"));
//you should set the xstop and xplay values to match the instance names of your stop button and play/pause buttons
xstop.addEventListener(MouseEvent.CLICK, clickStop);
xplay.addEventListener(MouseEvent.CLICK, clickPlayPause);
soundChannel = sound.play();
isPlaying = true;
function clickPlayPause(evt:MouseEvent) {
if (isPlaying) {
stopPoint = soundChannel.position;
xplay.gotoAndStop(2);
soundChannel.stop();
isPlaying = false;
} else {
soundChannel = sound.play(stopPoint);
isPlaying = true;
xplay.gotoAndStop(1);
}
}
function clickStop(evt:MouseEvent) {
if (isPlaying) {
soundChannel.stop();
isPlaying = false;
}
}
//Volume Control//
var volumeLevel = soundChannel.soundTransform;
var newLevel:Number = volumeSlider.sliderKnob.x / 100;
volumeLevel.volume = newLevel;
soundChannel.soundTransform = volumeLevel;

Reply With Quote

Bookmarks