Problems with Volume Control for Flash MP3 Player

This is a discussion on "Problems with Volume Control for Flash MP3 Player" within the Flash & Multimedia Forum section. This forum, and the thread "Problems with Volume Control for Flash MP3 Player are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Flash & Multimedia Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 15th, 2007, 16:31
Junior Member
Join Date: Aug 2007
Location: Haverhill
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Problems with Volume Control for Flash MP3 Player

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.
Attached Files
File Type: zip musicplayer3.zip (6.58 MB, 9 views)
Reply With Quote

  #2 (permalink)  
Old Aug 15th, 2007, 20:07
Multimedia Specialist
Join Date: Apr 2007
Location: Arizona
Age: 25
Posts: 666
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Sgaspar11
Re: Problems with Volume Control for Flash MP3 Player

It's not letting me download the file, but here is some code for my volume slider that I use for our streaming video player...

Cross check it with this and see if you come up with anything! The only different should be mine is embedded withing another movieclip, so the Entire Slider bar for everything, then the individual slider bar for the volume controls.
Code: Select all
var myVolPerc = 100 / my_c.volumeMC.bg._width;
my_c.volumeMC.butt.onPress = function() { 
 startDrag(this, false, 0, -2, this._parent.bg._width - this._width,  -2);
 this.onEnterFrame = function() {
  audio_sound.setVolume(this._x * myVolPerc);
  this._parent.meter._width = this._x + 1;
 }
}
Last Blog Entry: Yay!? (Oct 8th, 2007)
Reply With Quote
  #3 (permalink)  
Old Aug 16th, 2007, 08:47
Junior Member
Join Date: Aug 2007
Location: Haverhill
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problems with Volume Control for Flash MP3 Player

Hi Sgaspar11,

Thanks for your post,

As far as I can tell the control for both of our sliders appear to be almost identical. The only difference I can see is the
Code: Select all
this._parent.meter._width = this._x + 1;
 }
Line in yours which I'm not entirely sure what it is for.
Reply With Quote
  #4 (permalink)  
Old Aug 16th, 2007, 09:39
Junior Member
Join Date: Aug 2007
Location: Haverhill
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problems with Volume Control for Flash MP3 Player

I think I've tracked down one error that is preventing my desired functionality. In the volume control section of the code.
Code: Select all
//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;
};
I believe but I could be wrong that the line
Code: Select all
delete this.onEnterFrame;
is causing the volume_mc object to be ignored when the next call to my playSong function is called. As such the song file created by playSong will default to the normal volume.

However if I remove this line then the mute button ceases to function. I believe because the actual calls by the mute button are being over ridden by the value supplied by the volume_mc object.
Reply With Quote
Reply

Tags
flash, mp3 player, volume control

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to control a swf player in an iframe? Any Smart Takers? javaminiac JavaScript Forum 0 Jul 30th, 2007 00:35
main timeline volume control? edd_jedi Flash & Multimedia Forum 1 Jun 14th, 2007 20:40
FLV Player Actionscript problems kalli21 Flash & Multimedia Forum 2 May 2nd, 2007 00:44
Adobe unveils Flash video control acrikey Flash & Multimedia Forum 0 Apr 16th, 2007 15:20
Embeded Mp3 player problems Zaine7673 Web Page Design 2 Dec 17th, 2006 13:29


All times are GMT. The time now is 15:08.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43