Jump to content


Photo

MP3 Player Part I+II addon


  • Please log in to reply
47 replies to this topic

#1 funkysoul

funkysoul

    The Funky Stuff

  • Publishing Betazoids
  • PipPipPipPip
  • 2,307 posts
  • Gender:Male
  • Location:Zurich, Switzerland
  • Interests:Music: HIM, HIM, HIM, Cafe del Mar, Linkin Park, Fort Minor, Coldplay, Eric Jordan<br />Sports: Snowboarding, KiteSurfing, Extreme Sports<br />Computer: Flash, After Effects, Actionscript

Posted 30 September 2005 - 10:17 AM

ok, since I received a lot of requests from people having problem, using the mp3 player when it's not in the main timeline. I come up with this solution.
Follow every step, otherwise it will not work:

1. Remove the actionscript from the mc, and put it your main timeline
2. Give the MC where the mp3 player is in an instancename mine is "player"
3. copy and paste this code:
I basically replaced every _root.parent with _level0.player.. (meaning: my MC called player is loaded into level0 of flash, so I address it with _level0.player)

Any questions you may have, drop a message :tiphat:

Cheers
Funkysoul

stop();
playlist = new XML();
playlist.ignoreWhite = true;
playlist.onLoad = function(success) {
	if (success) {
  _global.songname = [];
  _global.songband = [];
  _global.songfile = [];
  for (var i = 0; i<playlist.firstChild.childNodes.length; i++) {
 	 _global.songname[i] = playlist.firstChild.childNodes[i].attributes.name;
 	 _global.songband[i] = playlist.firstChild.childNodes[i].attributes.band;
 	 _global.songfile[i] = playlist.firstChild.childNodes[i].attributes.file;
 	 // trace(songname[i]+"  "+songfile[i]+" "+songband[i]);
  }
	}
	_level0.player.createEmptyMovieClip("sound_mc", 1);
	_global.song_nr = random(songfile.length);
	_level0.player.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
function timer(sound_obj) {
	time = sound_obj.position/1000;
	min = Math.floor(time/60);
	min = (min<10) ? "0"+min : min;
	sec = Math.floor(time%60);
	sec = (sec<10) ? "0"+sec : sec;
	_level0.player.timeDisplay_txt.text = min+":"+sec;
}
MovieClip.prototype.songStarter = function(file, name, band) {
	if (_level0.player.sound_obj) {
  _level0.player.sound_obj.stop();
  delete _level0.player.sound_obj;
	}
	_level0.player.sound_obj = new Sound(this);
	_level0.player.sound_obj.loadSound(file, true);
	_level0.player.onEnterFrame = function() {
  if (_level0.player.sound_obj.position>0) {
 	 delete _level0.player.onEnterFrame;
 	 _level0.player.display_txt.text = name+" / "+band;
 	 timeInterval = setInterval(timer, 1000, _level0.player.sound_obj);
  } else {
 	 _level0.player.display_txt.text = "loading...";
  }
	};
	_level0.player.sound_obj.onSoundComplete = function() {
  clearInterval(timeInterval);
  _level0.player.timeDisplay_txt.text = "00:00";
  (song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
  _level0.player.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
	};
	_level0.player.volume1.dragger.onPress = function() {
  startDrag(this, true, 0, this._y, this._parent.volBG._width, this._y);
  _level0.player.onEnterFrame = function() {
 	 var p = (_level0.player.volume1.dragger._x/_level0.player.volume1.volBG._width)*100;
 	 trace(p)
 	 this.sound_obj.setVolume(p);
  };
	};
	_level0.player.volume1.dragger.onRelease = function() {
  delete this.onEnterFrame;
  stopDrag();
	};
	_level0.player.volume1.dragger.onReleaseOutside = function() {
  stopDrag();
	};
};
_level0.player.btn_play.onRelease = function() {
	clearInterval(timeInterval);
	_level0.player.timeDisplay_txt.text = "00:00";
	_level0.player.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
_level0.player.btn_stop.onRelease = function() {
	clearInterval(timeInterval);
	_level0.player.timeDisplay_txt.text = "00:00";
	_level0.player.sound_obj.stop();
};
_level0.player.btn_fw.onRelease = function() {
	clearInterval(timeInterval);
	_level0.player.timeDisplay_txt.text = "00:00";
	(song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
	_level0.player.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
_level0.player.btn_rev.onRelease = function() {
	clearInterval(timeInterval);
	_level0.player.timeDisplay_txt.text = "00:00";
	(song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr--;
	_level0.player.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
playlist.load("playlist.xml");


#2 Jens

Jens

    Young Padawan

  • Members
  • Pip
  • 3 posts

Posted 18 October 2005 - 06:13 AM

Hey there

I tried this, but only the Stop button works again... The scrolling text and timer still doesn't work and the volume bar works but when I use it a screen comes up with all sorts of numbers that change when you change the volume.

Can you help me? I've added you on MSN :(

EDIT: Just noticed this is for Part I & II only... Sorry! Could you edit the code for Part III too please? I tried myself, but I'm getting a non-functional mp3 player :P

Edited by Jens, 18 October 2005 - 07:19 AM.


#3 funkysoul

funkysoul

    The Funky Stuff

  • Publishing Betazoids
  • PipPipPipPip
  • 2,307 posts
  • Gender:Male
  • Location:Zurich, Switzerland
  • Interests:Music: HIM, HIM, HIM, Cafe del Mar, Linkin Park, Fort Minor, Coldplay, Eric Jordan<br />Sports: Snowboarding, KiteSurfing, Extreme Sports<br />Computer: Flash, After Effects, Actionscript

Posted 18 October 2005 - 11:24 AM

Jens, if you followed my instructions everything works properly.. read carefully through it.

#4 Jens

Jens

    Young Padawan

  • Members
  • Pip
  • 3 posts

Posted 18 October 2005 - 12:32 PM

Your code is for Part II... I'm using Part III, which also has the fader and scroller actionscript...

#5 funkysoul

funkysoul

    The Funky Stuff

  • Publishing Betazoids
  • PipPipPipPip
  • 2,307 posts
  • Gender:Male
  • Location:Zurich, Switzerland
  • Interests:Music: HIM, HIM, HIM, Cafe del Mar, Linkin Park, Fort Minor, Coldplay, Eric Jordan<br />Sports: Snowboarding, KiteSurfing, Extreme Sports<br />Computer: Flash, After Effects, Actionscript

Posted 18 October 2005 - 02:14 PM

the level targeting depends on where you're placing the movie!
again, doesn't matter if it's for part 1 or 2 or 3.. it's always the same theory.. point your actionscript to the right target!

If you really can't get it to work, then send me an email with your fla attached

#6 p, FRY

p, FRY

    Young Padawan

  • Members
  • Pip
  • 28 posts
  • Gender:Male
  • Location:australia

Posted 26 October 2005 - 02:11 AM

hey everyone, new member here.

first of all, excellent tutorials funky, the MP3 was a great help to me.

i ran into the problem you have mentioned here [my MP3 player is inside about 2 other movies] and i used this code on the instance of the movie itself to get it to work.


onClipEvent (load)
  {
    this._lockroot = true;
  }

just put that on the instance of the movie and it will work no matter where it is.

look forward to hanging around here.

#7 p, FRY

p, FRY

    Young Padawan

  • Members
  • Pip
  • 28 posts
  • Gender:Male
  • Location:australia

Posted 26 October 2005 - 03:44 AM

a question for you Funky:

i have uploaded all the files to my server but when i run the SWF of the actual website it wont load the MP3's. but if i run the SWF off my hard drive [pointing it to the MP3's on the server] it works fine.

any idea why the MP3's wont load when played from the online SWF?

thanks if you can help!

#8 funkysoul

funkysoul

    The Funky Stuff

  • Publishing Betazoids
  • PipPipPipPip
  • 2,307 posts
  • Gender:Male
  • Location:Zurich, Switzerland
  • Interests:Music: HIM, HIM, HIM, Cafe del Mar, Linkin Park, Fort Minor, Coldplay, Eric Jordan<br />Sports: Snowboarding, KiteSurfing, Extreme Sports<br />Computer: Flash, After Effects, Actionscript

Posted 26 October 2005 - 04:48 AM

well.. there are a few things that you need to check
1. Is the XML being correctly loaded? (is the path to the xml on the server correct)
2. Is the XML pointing to the correct path of the mp3's? (most commonly error)
3. Are you allowed to put mp3 files on your server (there a few hosters with restrictions)

If all this doesn't work then let me know.

Cheers
Funkysoul

Edited by funkysoul, 26 October 2005 - 05:40 AM.


#9 p, FRY

p, FRY

    Young Padawan

  • Members
  • Pip
  • 28 posts
  • Gender:Male
  • Location:australia

Posted 26 October 2005 - 05:15 AM

ahhh yes!

haha. you got it!

i didnt link the SWF to the online version of the XML. thankyou!

i was tearing my hair out!

#10 funkysoul

funkysoul

    The Funky Stuff

  • Publishing Betazoids
  • PipPipPipPip
  • 2,307 posts
  • Gender:Male
  • Location:Zurich, Switzerland
  • Interests:Music: HIM, HIM, HIM, Cafe del Mar, Linkin Park, Fort Minor, Coldplay, Eric Jordan<br />Sports: Snowboarding, KiteSurfing, Extreme Sports<br />Computer: Flash, After Effects, Actionscript

Posted 26 October 2005 - 05:40 AM

happy to help :ph34r:
Let me know your site to have a look at it ;)

Edited by funkysoul, 26 October 2005 - 05:41 AM.


#11 p, FRY

p, FRY

    Young Padawan

  • Members
  • Pip
  • 28 posts
  • Gender:Male
  • Location:australia

Posted 26 October 2005 - 07:12 AM

i've just got to do some small finishes to it, then ill send you a link :ph34r:

#12 DarkFighterX

DarkFighterX

    Young Padawan

  • Members
  • Pip
  • 4 posts

Posted 27 October 2005 - 01:49 PM

Hey, new to the forum.

First of all I have to say awesome tutorials Funky.

Every thing has been going great to making a mp3 player, but I have one issue about the volume control. I followed your tutorial exactly, I did every step to make the volume bacground down to the final code, but my dragger won't slide. It just wont move. I even tried redoing it 6 or 7 times, but nothing. If you can shed some light on my problem I would greatly appreciate it. If you want I can email you the fla and you can check it out

I'm using Studio MX 2004.

Also I was wondering if you knew the code to make a mute button?

#13 funkysoul

funkysoul

    The Funky Stuff

  • Publishing Betazoids
  • PipPipPipPip
  • 2,307 posts
  • Gender:Male
  • Location:Zurich, Switzerland
  • Interests:Music: HIM, HIM, HIM, Cafe del Mar, Linkin Park, Fort Minor, Coldplay, Eric Jordan<br />Sports: Snowboarding, KiteSurfing, Extreme Sports<br />Computer: Flash, After Effects, Actionscript

Posted 27 October 2005 - 01:59 PM

Hi there

Did you assign every mc an instance name, normally it works even if the boundings are not correct.

mute button? :)
create a "mute" button with the nice icon on it, press F8 to make a mc of it, give it an instance name like "mute_btn" and following actionscript:

mute_btn.onRelease = function(){
_level0.sound_mc.sound_obj.setVolume(0);
}

Edited by funkysoul, 27 October 2005 - 02:00 PM.


#14 DarkFighterX

DarkFighterX

    Young Padawan

  • Members
  • Pip
  • 4 posts

Posted 27 October 2005 - 02:05 PM

Yea I assigned every mc with the instance name you provided in your tutorial, but like I said nothing.

#15 funkysoul

funkysoul

    The Funky Stuff

  • Publishing Betazoids
  • PipPipPipPip
  • 2,307 posts
  • Gender:Male
  • Location:Zurich, Switzerland
  • Interests:Music: HIM, HIM, HIM, Cafe del Mar, Linkin Park, Fort Minor, Coldplay, Eric Jordan<br />Sports: Snowboarding, KiteSurfing, Extreme Sports<br />Computer: Flash, After Effects, Actionscript

Posted 27 October 2005 - 02:20 PM

is your player located inside of another movieclip?
does the hand cursor show up, when you move over the dragger?

Edited by funkysoul, 27 October 2005 - 02:21 PM.


#16 DarkFighterX

DarkFighterX

    Young Padawan

  • Members
  • Pip
  • 4 posts

Posted 27 October 2005 - 03:49 PM

is your player located inside of another movieclip?

No, I don't think so, the only mc I made are the one's for the volume control

does the hand cursor show up, when you move over the dragger?

No, no hand at all

Also I emailed you my fla

#17 DarkFighterX

DarkFighterX

    Young Padawan

  • Members
  • Pip
  • 4 posts

Posted 29 October 2005 - 03:34 PM

Thanks funkysoul, that did the trick B)

#18 p, FRY

p, FRY

    Young Padawan

  • Members
  • Pip
  • 28 posts
  • Gender:Male
  • Location:australia

Posted 17 January 2006 - 04:08 AM

well.. there are a few things that you need to check
1. Is the XML being correctly loaded? (is the path to the xml on the server correct)
2. Is the XML pointing to the correct path of the mp3's? (most commonly error)
3. Are you allowed to put mp3 files on your server (there a few hosters with restrictions)

If all this doesn't work then let me know.

Cheers
Funkysoul


i have made 2 sites for 2 different clients, and for no apparant reason all of a suddent the MP3 players wont play the songs.

i have done various updates to the SWF's but i havent touched the MP3 players for months and they were working fine. now when i got to it it just says "Loading...". from this i take it that it isnt finding the XML file.

i have checked and re-checked that the link inside Flash matches the path on the server.

even odder, is that when i run the file off my HD the songs play fine....crazyness

this one has me clueless. any help? cheers.

Edited by p, FRY, 17 January 2006 - 04:18 AM.


#19 funkysoul

funkysoul

    The Funky Stuff

  • Publishing Betazoids
  • PipPipPipPip
  • 2,307 posts
  • Gender:Male
  • Location:Zurich, Switzerland
  • Interests:Music: HIM, HIM, HIM, Cafe del Mar, Linkin Park, Fort Minor, Coldplay, Eric Jordan<br />Sports: Snowboarding, KiteSurfing, Extreme Sports<br />Computer: Flash, After Effects, Actionscript

Posted 17 January 2006 - 05:15 AM

Weird stuff mate.
I have my player on my site for about 8 months now, and never changed it, everything is running as on the first day.

Have you checked if you are exporting with "Access Network files" in the publishing panel?

#20 p, FRY

p, FRY

    Young Padawan

  • Members
  • Pip
  • 28 posts
  • Gender:Male
  • Location:australia

Posted 17 January 2006 - 06:07 AM

Weird stuff mate.
I have my player on my site for about 8 months now, and never changed it, everything is running as on the first day.

Have you checked if you are exporting with "Access Network files" in the publishing panel?


thanks, but i tried that and it had no change.

it still works just fine off the HD, but when i try it from the actual site it just says "waiting for yomamamusic.com.au...." and never seems to connect to the XML file and thus MP3's.

it seems more like a server problem than a Flash problem?

site in question is Yo Mama Music [go to artists>artists>"click to launch media player"]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users