Jump to content


Photo

funkysoul's MP3 Player in Flash with XML Tutorials


  • Please log in to reply
26 replies to this topic

#1 cupaball

cupaball

    Young Padawan

  • Members
  • Pip
  • 25 posts
  • Location:Philly

Posted 19 August 2006 - 09:33 PM

I know it will be back up soon, hopefully this month.

But I really need this tut!! Can you post it or email it?

#2 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 23 August 2006 - 06:10 PM

as already mentioned in the news section Faken & the gang are taking care of that, and I also hope to see my tutorials up & running again soon

#3 boogooloo1

boogooloo1

    Young Padawan

  • Members
  • Pip
  • 116 posts

Posted 27 August 2006 - 04:56 PM

G'day again, funkysoul! I'm hoping you can help me with something:

I've got a version of your player up on http://www.ecliptic.com.au/ - I'm pretty happy with it! Anyway, I'm going to put a standalone version on Ecliptic's cd (I've figured out how to do it, using CD-EXTRA), so that when people put the audio cd into their computer, the flash player pops up. I'm planning to put lyrics in the text box in the middle of the player, rather than the info which is there now, but I need it to change to the next song's lyrics when the first song ends etc - is that possible? It'd need to be incorporated into the player, so that if you press the next button or previous button, the lyrics follow suit.

One more thing, if you don't mind! I've created a standalone version which is exactly the same as the one on the website, and I'd like to be able to launch it from the website player, so that users can continue browsing and keep the player open - how do you do that?

Your help is always much appreciated!

I've figured out the standalone thing (http://www.flashkit...._-836/index.php), but would still LOVE to hear about the lyrics idea - I'm sure I'm not the only person who'd find this useful!

Ok, I got the lyrics idea working from this thread - http://www.pixel2lif...p...271&hl=anim

I've changed it to open a separate lyrics swf for each song, which works great. However, here's my current problem:

I've got multiple swfs opening and closing using different links; for example, you click on "about" and the player opens an "about" swf. I've got this built into the link button:

on (release) {
loadMovieNum("about-text.swf", 1);
unloadMovie(lyricsHolder);
}

However, when you click on prev or next in the mp3 player, the lyrics show up again (because the lyricsHolder is told to change to the correct lyrics going by the xml) - is there some way, while I'm NOT on the "main" or "lyrics" page, to keep lyricsHolder from showing up even when you press the prev or next buttons?

Sorry about the long and complicated post!

===============

Posts merged, please use the edit and don't keep posting repeatedly thanks. :huh:

Edited by Donna, 28 August 2006 - 11:33 PM.


#4 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 29 August 2006 - 03:31 AM

hi mate

Just my thoughts on your question:

Instead of loading swf, what about putting the lyrics in the same xml as the playlist, and then style them with CSS (yes, it's possible to use CSS in flash)
Then create a movieclip which always shows the lyrics,but is opened via a separate button somewhere in the near of the player.

I'm at the moment on the airport, but as soon as I'm home, I will have a closer look at your request.

#5 boogooloo1

boogooloo1

    Young Padawan

  • Members
  • Pip
  • 116 posts

Posted 29 August 2006 - 03:58 AM

Thanks, funky! Even though I don't mind your idea, it'd be a second choice for me - anyway, see how you go!

:D

Oh, and I don't know much about CSS :)

#6 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 29 August 2006 - 05:14 PM

ok got it ;)

maintimeline, frame 1, Actions layer add following script on top of all the other actions:

var hideLyrics:Boolean;
Here we set a variable that works a switch if a button has been clicked that should not show lyrics. Boolean is just true/false. we dont' set yet a true / false..

Next move down to the fw and rev button actions.
and replace this line:
...
		_root.lyricsHolder.loadMovie(songlyrics[song_nr],lyricsHolder);	
...

with

if (hideLyrics == false){
		_root.lyricsHolder.loadMovie(songlyrics[song_nr],lyricsHolder);	
	}
A simple IF statement checking if the variable has a false value.

Next:
On your about, pics & www actions your code should look like this:

on (release) {
	hideLyrics = true;
loadMovieNum("about-text.swf", 1);
unloadMovie(lyricsHolder);
}
We set the variable to true, so that the lyricsholder isn't visible anymore.

on the home button you use the same code but replace true with false

Worked for me, have a try!

Have fun :P

#7 boogooloo1

boogooloo1

    Young Padawan

  • Members
  • Pip
  • 116 posts

Posted 29 August 2006 - 05:43 PM

ok got it :)

on the home button you use the same code but replace true with false

Worked for me, have a try!

Have fun :)

G'day funky,

As usual, you're a lifesaver! I really appreciate how quickly you got back to me!!!

Anyway, there was only one thing I needed to change, and that was the homepage bit - I had to create an extra empty movie called home-page.swf, and instead of:

on (release) {
	hideLyrics = true;
loadMovieNum("about-text.swf", 1);
unloadMovie(lyricsHolder);
}

...I put:

on (release) {
	hideLyrics = false;
loadMovieNum("home-page.swf", 1);
	_root.lyricsHolder.loadMovie(songlyrics[song_nr],lyricsHolder)
}

If I didn't do that, there was nothing on the "1" level to get rid of the previous swf, and the lyrics didn't show up again until you clicked next. This way, when you click "home", it gets rid of the previous swf (the about-text.swf for example), loads a blank one in it's place, and the lyrics pop up again!

YAY! It all works beautifully!!!! :P :dance: ;)

THANK YOU!!!!! :winner:

#8 boogooloo1

boogooloo1

    Young Padawan

  • Members
  • Pip
  • 116 posts

Posted 29 August 2006 - 05:57 PM

Oh, and I also need to put:

hideLyrics = false;

...under the:

var hideLyrics:Boolean;

...in the actions, so that when the main swf opens, the fw and rev buttons work properly.

;)

#9 boogooloo1

boogooloo1

    Young Padawan

  • Members
  • Pip
  • 116 posts

Posted 29 August 2006 - 06:06 PM

Oh, and one more thing - I put:

_root.lyricsHolder.loadMovie(songlyrics[song_nr],lyricsHolder);


...on the play button. I did this because my www buttonn has this code:

on (release) {
		hideLyrics = true;
 getURL("http://www.ecliptic.com.au/");
 unloadMovie(lyricsHolder);
 stopallsounds();
}

...instead of the usual stuff. This means that if you click on the www link, all sounds go off, so I wanted the lyrics to pop up again if the user came back to the standalone player (from the web version) and pressed play again.

I'm getting pretty decent at this stuff!

;)

#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 29 August 2006 - 06:34 PM

yep sorry, forgot to post that... :winner:
I'm awake for more then 30hrs... Think should get some sleep

Let me know when you done! ;) And dont forget to send me a CD :P

Edited by funkysoul, 29 August 2006 - 06:34 PM.


#11 boogooloo1

boogooloo1

    Young Padawan

  • Members
  • Pip
  • 116 posts

Posted 29 August 2006 - 06:37 PM

Will do - thanks again!

;)

#12 boogooloo1

boogooloo1

    Young Padawan

  • Members
  • Pip
  • 116 posts

Posted 03 September 2006 - 06:24 PM

I'm back!! :rolleyes:

I've been trying to get the player to work while using motion tweening, very unsuccessfully so far. I want it to be hidden, and to slide out when you click on a link. The problem is, when you motion tween, it seems to group the controls somehow, and they no longer respond to the actionscript.

Any ideas?

;)

#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 04 September 2006 - 04:22 AM

put the mp3 player in a separate movieclip..

#14 boogooloo1

boogooloo1

    Young Padawan

  • Members
  • Pip
  • 116 posts

Posted 06 September 2006 - 09:40 PM

Ok, I got the tweeing working - thanks Funky!

I have another issue, due to my version of this which is going to be on my cd. I'd like to include the lyrics in the main swf, by creating another text field and adding to my XML. The XML could open an external text file or I could add the lyrics into the XML.

Here's what I've tried so far:

stop();
playlist = new XML();
playlist.ignoreWhite = true;
playlist.onLoad = function(success) {
	if (success) {
		_global.songname = [];
		_global.songband = [];
		_global.songlyrics = [];
		_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.songlyrics[i] = playlist.firstChild.childNodes[i].attributes.lyrics;
			_global.songfile[i] = playlist.firstChild.childNodes[i].attributes.file;
			// trace(songname[i]+"  "+songfile[i]+" "+songband[i]+"  "+songlyrics+");
		}
	}
	_root.createEmptyMovieClip("sound_mc", 1);
	_global.song_nr = random(0);
		_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr], songlyrics[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;
	timeDisplay_txt.text = min+":"+sec;
}
MovieClip.prototype.songStarter = function(file, name, band, lyrics) {
	if (this.sound_obj) {
		this.sound_obj.stop();
		delete this.sound_obj;
	}
	this.sound_obj = new Sound(this);
	this.sound_obj.loadSound(file, true);
	this.onEnterFrame = function() {
		if (this.sound_obj.position>0) {
			delete this.onEnterFrame;
			this._parent.display_txt.text = name+" / "+band;
			this._parent.lyrics_box.text=lyrics;
			timeInterval = setInterval(timer, 1000, this.sound_obj);
		} else {
			this._parent.display_txt.text = "loading...";
		}
	};
	this.sound_obj.onSoundComplete = function() {
		clearInterval(timeInterval);
		this._parent.timeDisplay_txt.text = "00:00";
		(song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
		_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr], songlyrics[song_nr]);
	};
	this._parent.volume1.dragger.onPress = function() {
		startDrag(this, true, 0, this._y, this._parent.volBG._width, this._y);
		this.onEnterFrame = function() {
			var p = (this._x/this._parent.volBG._width)*100;
			this._parent._parent.sound_mc.sound_obj.setVolume(p);
		};
	};
	this._parent.volume1.dragger.onRelease = function() {
		delete this.onEnterFrame;
		stopDrag();
	};
	this._parent.volume1.dragger.onReleaseOutside = function() {
		stopDrag();
	};
};
btn_play.onRelease = function() {
	if (pause == true){ // no comment....
		this._parent.sound_mc.sound_obj.start(posiP) // start sound from the previously saved position
	}
	else {
	clearInterval(timeInterval);
	_root.timeDisplay_txt.text = "00:00";
	this._parent.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr], songlyrics[song_nr]);
	}
};
btn_pause.onRelease = function() { //pause button function
	this._parent.sound_mc.sound_obj.stop(); //stop the current sound
	posiP = _root.sound_mc.sound_obj.position / 1000; // save the current position in a new variable and divide by 1000 (ms -> sec)
	pause = true;//set the variable pause to true
}
btn_fw.onRelease = function() {
	clearInterval(timeInterval);
	this._parent.timeDisplay_txt.text = "00:00";
	(song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
	_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr], songlyrics[song_nr]);
};
btn_rev.onRelease = function() {
	clearInterval(timeInterval);
	this._parent.timeDisplay_txt.text = "00:00";
	(song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr--;
	_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr], songlyrics[song_nr]);
};
playlist.load("playlist.xml");

Sorry about the long post! As you can see, I've created another text box called "lyrics_box", and I've added to my XML thus:

<song name ="Xxxxx" band ="Xxxxx" file="Xxxxx.mp3" lyrics="Xxxxx.txt" />

...for the external .txt file with the lyrics, or:

<song name ="Xxxxx" band ="Xxxxx" file="Xxxxx.mp3" lyrics="These are my lyrics etc" />

Have I done the XML right? The text box is currently just showing "undefined", so I'm off somewhere...

:D

#15 boogooloo1

boogooloo1

    Young Padawan

  • Members
  • Pip
  • 116 posts

Posted 07 September 2006 - 10:22 AM

Bump! I can get my album pressed once I solve this!

;)

#16 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 07 September 2006 - 11:34 AM

sorry mate no time to review that today.. I would rather go for the solution with the lyrics in the xml file..

#17 Ben

Ben

    P2L Jedi Master

  • Publishing Betazoids
  • PipPipPipPip
  • 1,366 posts
  • Gender:Male
  • Location:VIC, Australia

Posted 07 September 2006 - 04:44 PM

You'd have to modify your xml file a little to get that working. The loading the text file would be:
<song name ="Xxxxx" band ="Xxxxx" file="Xxxxx.mp3" lyrics="Xxxxx.txt" ext="true" />
And the other:
<song name ="Xxxxx" band ="Xxxxx" file="Xxxxx.mp3" lyrics="Xxxxx" ext="false" />
Then, add another _global variable:
_global.songext = [];
...
_global.songext[i] = playlist.firstChild.childNodes[i].attributes.ext;
Then, create an if statement around the part where it loads the txt:
if(songext[song_nr] == "true") {
//load the text file here
} else {
//set the text box content to songlyrics[song_nr]
}


#18 boogooloo1

boogooloo1

    Young Padawan

  • Members
  • Pip
  • 116 posts

Posted 07 September 2006 - 05:55 PM

G'day mate,

Thanks for your reply! Unfortunately, I'm not quite getting it - I've tried guessing how to put it together, but it's not working. Would you mind being more specific? Sorry to bother you!

:blink:

#19 boogooloo1

boogooloo1

    Young Padawan

  • Members
  • Pip
  • 116 posts

Posted 07 September 2006 - 06:05 PM

sorry mate no time to review that today.. I would rather go for the solution with the lyrics in the xml file..


No probs, funky - you've done so much already, I can hardly object! :blink:

I can't get the lyrics in the xml file to work either.

;)

#20 boogooloo1

boogooloo1

    Young Padawan

  • Members
  • Pip
  • 116 posts

Posted 08 September 2006 - 12:25 AM

Oh, well, I've tried everything I can think of, so I'll just wait for a kind P2L kind soul to rescue me!

:)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users