Jump to content


Photo

MP3 Player with XML - Scrub bar Navigation


  • Please log in to reply
2 replies to this topic

#1 Nofilicity

Nofilicity

    Young Padawan

  • Members
  • Pip
  • 2 posts

Posted 22 October 2007 - 04:54 PM

Now, I don't know if there has been a tutorial for this already, but I'm guessing not..so here goes:

Ok, this is based on funkysoul's XML mp3 player tutorial. We are going to be adding a function that will allow the user to jump to whatever part of the song that they want.

First, you must MAKE SURE YOUR SCRUB BAR IS ALIGNED AT THE VERY LEFT!
Like so:
<img src="http://img507.images...arightbn3.gif">

Its actually not much code at all:

Assuming your load\scrub bar is instance named "loader", insert this is in the actionscript frame's actionscript.

loader.onRelease = function() {
		if(_root.loader._xmouse < 0) {
		xmouse = -1 * _root.loader._xmouse;
	} else {
		xmouse = _root.loader._xmouse;
	}
		this._parent.sound_mc.sound_obj.start(xmouse*1.2);
	}
Now for the explanation.
loader.onRelease = function() {
Simply says that when the user releases their mouse after click on the scrub bar, we want to call this function.
if(_root.loader._xmouse < 0) {
		xmouse = -1 * _root.loader._xmouse;
	} else {
		xmouse = _root.loader._xmouse;
	}
Checks if the mouses relative position to the scrub bar is negative, if so, it makes it positive. Otherwise it remains the same.
this._parent.sound_mc.sound_obj.start(xmouse*1.2);
This tells the mp3 player to begin playing at that position.

See, very easy! :)

Edited by Nofilicity, 22 October 2007 - 04:55 PM.


#2 miyakojimadan

miyakojimadan

    Young Padawan

  • Members
  • Pip
  • 1 posts

Posted 22 January 2010 - 06:56 AM

[quote name='Nofilicity' date='Oct 23 2007, 06:54 AM' post='239097']

loader.onRelease = function() {
		if(_root.loader._xmouse < 0) {
		xmouse = -1 * _root.loader._xmouse;
	} else {
		xmouse = _root.loader._xmouse;
	}
		this._parent.sound_mc.sound_obj.start(xmouse*1.2);
	}

Where exactly should this be placed in the actionscript?

#3 maxshelor

maxshelor

    Young Padawan

  • Members
  • Pip
  • 1 posts

Posted 17 November 2010 - 01:03 AM

Thanks for this. I’ve been dissecting code trying to find a good way to make a mp3 player and this is awesome. However I’m still a newb to as3 and for some reason when I press pause and then play, the sound starts a few seconds earlier then when I paused it. Could this be because my .fla assets, like the tbar, etc. are different sizes? And I haven’t even touched the buffering code, yet for some reason my player loads the whole mp3 before it even plays. Any ideas, explanations, suggestions would be greatly appreciated. Thanks again!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users