Hi,
I'm currently trying to develop a Flash MP3 Player that can be embedded into a website.
Every thing is working correctly apart from the volume control part of it.
You'll find attached to this post a zipped file containing The flash files, some sample music MP3s, an
XML file and action script files. This was the easiest way for me to make my current attempt available to you.
Here is the chunk of code that I believe is not working as intended.
- Code: Select all
//Mute Button
mute.onRollOver = function()
{
if(this._currentframe == 1)this.gotoAndStop('onOver');
else this.gotoAndStop('offOver');
}
mute.onRollOut = mute.onReleaseOutside = function()
{
if(this._currentframe == 10)this.gotoAndStop('on');
else this.gotoAndStop('off');
}
mute.onRelease = function()
{
if(this._currentframe == 10) //if not currently muted
{
this.gotoAndStop('offOver'); //change icon to the muted over state
this._parent.s.setVolume(0); //set the volume of the currently playing MP3 to 0
muteOn = 1; //set muteOn to 1 so player can remember that the MP3 has been muted
}
else //if currently muted
{
this.gotoAndStop('onOver'); //change icon to the not muted over state
this._parent.s.setVolume(Math.floor(volume_mc.slider_mc._x/1.8)); //set the volume to as set by the volume slider
muteOn = 0; //set muteOn to 0 so player can remember that the MP3 is not muted
}
}
//Play the MP3 File
function playSong():Void
{
s = new Sound(); //create a new MP3 sound object s
s.onSoundComplete = playSong; //when the MP3 finishes playing run this function again to play the next MP3
if(muteOn == 1) //if muted
{
mute.gotoAndStop('off'); //set mute button to muted view
s.setVolume(0); //ensure volume of MP3 is set to 0
}
else
{
mute.gotoAndStop('on'); //set mute button to not muted view
s.setVolume(Math.floor(volume_mc.slider_mc._x/1.8)); //set volume of MP3 to level determined by volume slider
}
if(cps == sa.length - 1) //if currently playing song is the last in the sa array
{
cps = 0; //set next currently playing song to the first in the array
s.loadSound(sa[cps].earl, true);//load/play the MP3 with streaming option
}
else
{
s.loadSound(sa[++cps].earl, true);//load/play the next MP3 with streaming option
}
artistInfo.text = sa[cps].artist; //set the displayed artist info to that contained in song object
trackInfo.text = sa[cps].track; //set the displayed track info to that containd in song object
}
//Volume Slider Control
volume_mc.slider_mc.onPress = function() {
this.startDrag(false, 0, this._y, 180, this._y);
this.onEnterFrame = function() {
/*----The volume slider track is 180px long; we want the value for "volume"
to be an integer between 0 and 100, so divide the slider _x position by 1.8----*/
s.setVolume(Math.floor(this._x/1.8));
};
};
volume_mc.slider_mc.onRelease = function() {
this.stopDrag();
delete this.onEnterFrame;
};
Ideally I want the player to maintain the current volume level when it starts the next song, however at the present time it resets it to the maximum. If not mute if muted it holds it at mute and will not allow the volume to be unmuted on the current song.
I'm sure I'm missing something obvious any help will be greatly appreciated.