PDA

View Full Version : Fully Dynamic XML MP3 Player v1.1



Voetsjoeba
November 30th, 2003, 03:50 PM
** VERSION 2: http://www.kirupaforum.com/forums/showthread.php?t=49368 **

Hello everybody :)

I just finished a project I started a while ago, a fully dynamic MP3 player (with preloader and time indication) with an XML playlist. You can see a working example of it here: http://users.pandora.be/voetsjoeba/Mp3.html ,and the playlist is located here: http://users.pandora.be/voetsjoeba/playlist.xml.

As I said, it is fully dynamic. That includes the fact that you only have to update the XML file with new values to add a song. It is written as a class that needs two parameters: an object containing the links to the elements of the interface, and the playlist array. Everything else goes fully automated.

I wanted to share it with you guys, and ask if you saw any bugs, or if you would like to see some features added. If so, let me know and I will implement them if I can. I was surprised at how easy this was actually.

*Stupid link parser :P

claudio
November 30th, 2003, 03:56 PM
Nice Voetsjoeba :)
You need to edit the first link cause its not opening correctly

Voetsjoeba
November 30th, 2003, 03:57 PM
Thanks :) Yeah I know, this forum parses the "," after the link along with it. Removed it :)

newhopekenny
December 1st, 2003, 05:49 AM
That's awesome, it answers my unanswered post:
http://www.kirupaforum.com/forums/showthread.php?threadid=39169

Now what about a pop-up list of all songs in the playlist, that allows users to click on songs and have them play? A "download this song" style link/button?.

And when are MP3s going to be able to stream AND pause, eh? That's what I can't wait to see, without having to create a SWF for each MP3 to play/pause while it isn't 100% loaded.

scotty
December 1st, 2003, 07:28 AM
great player Voetsjoeba:)

i noticed that once the sound is downloaded and it starts playing your play button stays in "play"-state (if you rollover it goes to "pause"-state, where i think it should be)

maybe it's an idea to add a volumecontrol?

scotty(-:

hamza84
December 1st, 2003, 01:25 PM
how about posing your .fla here so that everybody can learn :P

Voetsjoeba
December 1st, 2003, 01:25 PM
scotty -- Yeah, I noticed that, and I fixed it offline but I needed a chance to replace it online. Thanks for noticing :) I'm also about to add a volume slider :)

newhopekenny -- This player doesn't use sound SWFs. All you need to provide is a link to the MP3 file. I'm gonna see what I can do about the streaming ;)

Voetsjoeba
December 1st, 2003, 01:27 PM
Hamza48 -- Ok, here goes my code. Still a bit rough, I need to smoothen it a bit, but anyway.



mp3Player = function (playlist, interface) {
if (playlist[0] != undefined && interface != undefined) {
this.songIndex = 0;
this.sound = new Sound();
this.interface = interface;
this.playlist = playlist;
this.paused = 0;
// this.paused -- Paused at beginning, 1 or 0
this.dH = _root.createEmptyMovieClip("displayHandler", 1);
this.setInterface();
this.loadTrack();
} else {
trace("Invalid playlist array and/or interface object specified.");
}
};
mp3player.prototype.displayInfo = function() {
var tF = this.interface.info;
tF.text = this.songIndex+1+" "+this.playlist[this.songIndex].title+" - "+this.playlist[this.songIndex].artist;
};
mp3Player.prototype.disableControls = function(){
this.interface.playPause.enabled = false;
this.interface.stopButton.enabled = false;
}
mp3Player.prototype.enableControls = function(){
this.interface.playPause.enabled = true;
this.interface.stopButton.enabled = true;
}
mp3Player.prototype.pause = function() {
this.pausedPosition = this.sound.position;
this.sound.stop();
this.paused = 1;
delete this.dH.onEnterFrame;
};
mp3Player.prototype.loadTrack = function() {
var ref = this;
if(!this.paused) this.disableControls()
this.sound.loadSound(this.playlist[this.songIndex].locator, false);
mc = _root.createEmptyMovieClip("loader", 2);
mc.onEnterFrame = function() {
if (ref.sound.getBytesLoaded() == ref.sound.getBytesTotal() && ref.sound.getBytesTotal()>0) {
if (!ref.paused) {
ref.sound.start(0, 1);
ref.setInitialSlider(ref.sound.getVolume());
ref.displayProgress();
ref.enableControls()
ref.interface.playPause.gotoAndStop(4);
} else {
ref.sound.totalMinutes = Math.floor(Math.floor(ref.sound.duration/1000)/60);
ref.sound.totalSeconds = Math.floor(ref.sound.duration/1000)-(ref.sound.totalMinutes*60);
ref.sound.totalMinutes<10 ? ref.sound.totalMinutes="0"+ref.sound.totalMinutes : null;
ref.sound.totalSeconds<10 ? ref.sound.totalSeconds="0"+ref.sound.totalSeconds : null;
//--------------------------------------------
ref.interface.display.text = "00:00 "+ref.sound.totalMinutes+":"+ref.sound.totalSeconds;
}
delete this.onEnterFrame;
}
ref.interface.preloader._width = (ref.sound.getBytesLoaded()/ref.sound.getBytesTotal())*ref.interface.barWidth;
ref.interface.loadProgress.text = Math.round(ref.sound.getBytesLoaded()/1000)+" kB / "+Math.round(ref.sound.getBytesTotal()/1000)+" kB";
};
ref.displayInfo();
};
mp3Player.prototype.next = function() {
var ref = this.sound;
var thisref = this;
this.stopS();
this.songIndex++;
this.songIndex>this.playlist.length-1 ? this.songIndex=0 : null;
this.sound.loadSound(this.playlist[this.songIndex].locator, false);
this.displayInfo();
this.disableControls()
this.dH.onEnterFrame = function() {
if (ref.getBytesLoaded() == ref.getBytesTotal()) {
thisref.sound.setVolume(thisref.interface.vIndicat or.text);
thisref.sound.start(0, 1);
thisref.displayProgress();
thisref.paused = 0;
thisref.enableControls()
thisref.interface.playPause.gotoAndStop(4);
delete this.onEnterFrame
}
thisref.interface.preloader._width = (ref.getBytesLoaded()/ref.getBytesTotal())*thisref.interface.barWidth;
thisref.interface.loadProgress.text = Math.round(ref.getBytesLoaded()/1000)+" kb / "+Math.round(ref.getBytesTotal()/1000)+" kb";
};
};
mp3Player.prototype.previous = function() {
var ref = this.sound;
var thisref = this;
this.stopS();
this.songIndex--;
this.songIndex<0 ? this.songIndex=this.playlist.length-1 : null;
this.sound.loadSound(this.playlist[this.songIndex].locator, false);
this.displayInfo();
this.disableControls()
this.dH.onEnterFrame = function() {
if (ref.getBytesLoaded() == ref.getBytesTotal()) {
thisref.sound.setVolume(thisref.interface.vIndicat or.text);
thisref.sound.start(0, 1);
thisref.displayProgress();
thisref.paused = 0;
thisref.enableControls()
thisref.interface.playPause.gotoAndStop(4);
delete this.onEnterFrame
}
thisref.interface.preloader._width = (ref.getBytesLoaded()/ref.getBytesTotal())*thisref.interface.barWidth;
thisref.interface.loadProgress.text = Math.round(ref.getBytesLoaded()/1000)+" kb / "+Math.round(ref.getBytesTotal()/1000)+" kb";
};
};
mp3Player.prototype.stopS = function() {
this.sound.stop();
this.pausedPosition = 0;
delete this.dH.onEnterFrame;
this.sound.minutesPlaying = 0;
this.sound.secondsPlaying = 0;
this.sound.minutesPlaying<10 ? this.sound.minutesPlaying="0"+this.sound.minutesPlaying : null;
this.sound.secondsPlaying<10 ? this.sound.secondsPlaying="0"+this.sound.secondsPlaying : null;
this.interface.display.text = this.sound.minutesPlaying+":"+this.sound.secondsPlaying+" "+this.sound.totalMinutes+":"+this.sound.totalSeconds;
this.paused = 1;
};
mp3Player.prototype.resume = function() {
var ref = this;
this.sound.start(this.pausedPosition/1000, 1);
this.paused = 0;
this.displayProgress();
};
mp3Player.prototype.dragVolumeSlider = function() {
var ref = this;
var beginScale = this.interface.vSliderScale._y;
var endScale = beginScale-this.interface.vSliderScale._height;
this.interface.vSlider.onMouseMove = function() {
if (_root._ymouse>=Math.round(endScale) && _root._ymouse<=Math.round(beginScale)) {
this._y = _root._ymouse;
ref.interface.vIndicator.text = Math.round(Math.round(beginScale-this._y)/ref.interface.vSliderScale._height*100);
ref.sound.setVolume(ref.interface.vIndicator.text) ;
}
};
};
mp3Player.prototype.setInitialSlider = function(volume) {
var ref = this;
var beginScale = this.interface.vSliderScale._y;
var endScale = beginScale-this.interface.vSliderScale._height;
this.interface.vSlider._y = beginScale-(volume/100)*(beginScale-endScale);
this.interface.vIndicator.text = volume;
};
mp3Player.prototype.executeProgress = function() {
this.sound.minutesPlaying = Math.floor(Math.floor(this.sound.position/1000)/60);
this.sound.secondsPlaying = Math.floor(this.sound.position/1000)-(this.sound.minutesPlaying*60);
this.sound.minutesPlaying<10 ? this.sound.minutesPlaying="0"+this.sound.minutesPlaying : null;
this.sound.secondsPlaying<10 ? this.sound.secondsPlaying="0"+this.sound.secondsPlaying : null;
this.interface.display.text = this.sound.minutesPlaying+":"+this.sound.secondsPlaying+" "+this.sound.totalMinutes+":"+this.sound.totalSeconds;
if (this.sound.minutesPlaying == this.sound.totalMinutes && this.sound.secondsPlaying == this.sound.totalSeconds) {
this.next()
delete this.onEnterFrame;
}
};
mp3Player.prototype.displayProgress = function() {
var ref = this;
this.sound.totalMinutes = Math.floor(Math.floor(this.sound.duration/1000)/60);
this.sound.totalSeconds = Math.floor(this.sound.duration/1000)-(this.sound.totalMinutes*60);
this.sound.totalMinutes<10 ? this.sound.totalMinutes="0"+this.sound.totalMinutes : null;
this.sound.totalSeconds<10 ? this.sound.totalSeconds="0"+this.sound.totalSeconds : null;
this.dH.onEnterFrame = function() {
ref.executeProgress();
};
};
mp3Player.prototype.setInterface = function() {
var ref = this;
this.paused ? this.interface.playPause.gotoAndStop(1) : this.interface.playPause.gotoAndStop(4);
this.interface.playPause.onRollOut = function() {
ref.paused ? this.gotoAndStop(1) : this.gotoAndStop(4);
};
this.interface.playPause.onRollOver = function() {
ref.paused ? this.gotoAndStop(2) : this.gotoAndStop(5);
};
this.interface.playPause.onRelease = function() {
if (ref.paused) {
ref.resume();
this.gotoAndStop(5);
} else {
ref.pause();
this.gotoAndStop(2);
}
};
this.interface.stopButton.onRelease = function() {
ref.stopS();
ref.interface.playPause.gotoAndStop(1);
};
this.interface.nextButton.onRelease = function() {
ref.next();
};
this.interface.previousButton.onRelease = function() {
ref.previous();
};
this.interface.vSlider.onPress = function() {
ref.dragVolumeSlider();
};
this.interface.vSlider.onRelease = this.interface.vSlider.onReleaseOutside=function () {
delete ref.interface.vSlider.onMouseMove;
};
};
playerPlaylist = new Array();
listLoader_xml = new XML();
listLoader_xml.ignoreWhite = true;
listLoader_xml.onLoad = function() {
for (var i = 0; i<this.firstChild.childNodes.length; i++) {
playerPlaylist.push({title:this.firstChild.childNo des[i].attributes.title, artist:this.firstChild.childNodes[i].attributes.artist, locator:this.firstChild.childNodes[i].attributes.locator});
}
playerInterface = {previousButton:previousB, playPause:playPauseB, stopButton:stopB, nextButton:nextB, display:track, info:info, preloader:loadBar, barWidth:140, loadProgress:loadProgress, vSlider:slider, vSliderScale:slideScale, vIndicator:volumeInd};
test = new mp3Player(playerPlaylist, playerInterface);
};
listLoader_xml.load("playlist.xml");



*Updated the code and added a volume slider
*Updated code to v1.1

Voetsjoeba
December 1st, 2003, 01:29 PM
And here's the FLA ...

*Updated to v1.1, see later post
*Original file to be downloaded here (http://users.pandora.be/voetsjoeba/kirupa/mp3Backup.fla)
*First update here (http://users.pandora.be/voetsjoeba/kirupa/v1.fla)

V2 Coming Soon !

Voetsjoeba
December 1st, 2003, 01:31 PM
And the XML file :)

lunatic
December 1st, 2003, 01:45 PM
:stunned: :beer: :thumb:

hamza84
December 1st, 2003, 02:39 PM
WHOA! thats some long *** code. Hope i figure out what is what. Thanx a bunch. I'm sure every one will benefit

hga77
December 1st, 2003, 04:21 PM
What can I say...Amazing stuff Voetsjoeba :)

Extra feature:

Maybe you can implement the Forward and Rewind buttons so that, onMouseDown (pressing the button without release) would cause the song to skip (ie. "fast forward" or "fast rewind" a song).

newhopekenny
December 2nd, 2003, 10:21 AM
My dirty wet dream is to be able to stream MP3s in flash...so if you get it work Voetsjoeba, I will sell you my soul. Don't think it's possible at all in MX 2004 or lower, but perhaps the next generation of Flash will allow for such things.

The FF/RR button could just be a function that is called during an onPress event, and while running could just increment the time by a few seconds until the user lets up on the button.

I have one question, though. Why'd you do this? (commented out the parts I wasn't talking about):


var thisref = this;
// this.stopS();
// this.songIndex++;
// this.songIndex>this.playlist.length-1 ? this.songIndex=0 : null;
// this.sound.loadSound(this.playlist[this.songIndex].locator, false);
// this.displayInfo();
// this.dH.onEnterFrame = function() {
if (ref.getBytesLoaded() == ref.getBytesTotal()) {
thisref.sound.start(0, 1);
thisref.displayProgress();
thisref.paused = 0;
thisref.interface.playPause.gotoAndStop(4);
...and so on


Why create a local variable for "this" Why not just use this.whatever?

Voetsjoeba
December 2nd, 2003, 01:04 PM
newhopekenny -- Streaming brings a lot more difficulties, such as the position property that always keeps increasing instead of resetting and such. I'll look what I can do though. The code you posted: I'm doing that because I don't want those statements to be executed before it has completely loaded :)

I've updated the code to fix a bug, and added a volume slider. So here's the new fla too:

newhopekenny
December 2nd, 2003, 01:31 PM
I'm well-aware of the limitations of streaming, that's why I can't wait for it to be done with some control (like position) instead of just stop/play.

hamza84
December 2nd, 2003, 02:59 PM
Hey Voetsjoeba, I couldn;t understand the

delete this.dH.onEnterFrame;

in the pause function. Could you explain it?

Voetsjoeba
December 3rd, 2003, 07:23 AM
this.dH is a movieclip of which the onEnterFrame handler is used to show the progress of the playing in the textbox. When we pause, we don't want the counting to continue so we delete the onEnterFrame handler of this.dH :)

andrthad
December 3rd, 2003, 02:49 PM
Hey Voets,

Great code. I thought I knew actionscript pretty good... For some reason when I click on your example I don't get anything to play. The Play/Pause button just flashes.

As far as streaming can't you just use



Sound.loadSound("myMP3.mp3", "true");


Maybe everyone is referring to the difficulty in keeping track of the position because the duration keeps growing??

Voetsjoeba
December 3rd, 2003, 02:54 PM
andrthad -- That happens when you don't specify an interface object:



//...
listLoader_xml.onLoad = function() {
for (var i = 0; i<this.firstChild.childNodes.length; i++) {
playerPlaylist.push({title:this.firstChild.childNo des[i].attributes.title, artist:this.firstChild.childNodes[i].attributes.artist, locator:this.firstChild.childNodes[i].attributes.locator});
}
playerInterface = {previousButton:previousB, playPause:playPauseB, stopButton:stopB, nextButton:nextB, display:track, info:info, preloader:loadBar, barWidth:140, loadProgress:loadProgress, vSlider:slider, vSliderScale:slideScale, vIndicator:volumeInd};
test = new mp3Player(playerPlaylist, playerInterface);
};
//...

Voetsjoeba
December 4th, 2003, 10:07 AM
Oh sorry, I didn't realize you were talking about the online player. That's weird indeed. Oh I know ! I've cutted and pasted the code here, accidentally saved, exported and placed online :P

luthan
December 5th, 2003, 11:10 AM
im testing out your mp3 player and it is pretty **** awesome
but for some reason, my songs play a bit slower than they are supposed to.
is there something that can be done in the code to control the speed of playback?

monotypic
December 5th, 2003, 12:45 PM
Voet: thank you soo much for sharing this with us! you've just made my day.

Voetsjoeba
December 5th, 2003, 03:23 PM
Luthan -- No, I don't think so. Are you working on a slow computer ? It was working fine on my old lady, 500MHz Celeron 96 MB RAM.

Monotypic -- Glad I could make your day ! :beam:

luthan
December 5th, 2003, 04:27 PM
no im running a p3 here at work and at home i got p4
and both are doing it
could it be that my flash site slows it down somehow?

luthan
December 5th, 2003, 04:57 PM
actually i figured it out
i was converting my mp3s to smaller bit/sec rate instead of sampling rate

minimalistik
December 8th, 2003, 04:25 PM
man thanks for the fla and xml files voetsjoeba! :)

i wanted to create one for so long.... thanks newyz.

minimalistik
December 8th, 2003, 08:31 PM
voetsjoeba, could you instead link the buttons to tracks imported into the fla file instead of having to use an external link like a url?

if so, how can you link the tracks to the buttons and still have all other aspects of the player working.

jacko33
December 20th, 2003, 10:25 PM
Hey mate

First excellent player simple but yet excellent.

Now I have found one bug in the player pretty big one in a way. When the mp3 is loading and you presss the pause button then play again BEFORE the sound file has finished downloading the player skips to the next track and starts loading the next track.

Is their a way to disable the button when a track is loading?

Again Excellent player

Regs
Jacko

Voetsjoeba
December 21st, 2003, 04:27 AM
Thank you jacko33 :)

I have checked the bug you reported, but it didn't skip tracks for me. However, it did stop preloading, and that's a bug too of course. Thank you for noticing ! :)

jacko33
December 21st, 2003, 08:08 AM
Hey Voetsjoeba

Just a follow on from the last bug when I have tested on a modem I find if I press the pause button then the play button it stops preloading as you stated andall the track names cycling throug fast in a loop like their is looping also the play pause button keeps flicking between pause play.

I will try and screen capture it for u so you can see it.

It also happens with the example page you have supplied.

Have a merrry christmas mate

Regs,
Jacko

Voetsjoeba
December 21st, 2003, 08:49 AM
Thanks, have a merry christmas too =)

I'll look after the bug, I would've done it earlier but Flash crashed and I didn't feel like firing it up again :P I think I'll fix this by disabling the controls while it's preloading ... Yeah, that's what I'm gonna do.

*double-clicks Macromedia Flash MX 2004.lnk*

jacko33
December 21st, 2003, 09:06 AM
Yeah I think that is the easiest, but I think it would still be cool to have the skip track buttons active so people can skip tracks they hate and don't have to waste bandwidth on tracks they think bite.

Anyway I have to do some last minute christmas shopping.

happy xmas everyone.

Regs,
Jacko

Digitalosophy
December 21st, 2003, 02:26 PM
gr8 job votes!

Digitalosophy
December 21st, 2003, 02:26 PM
gr8 job votes!

Voetsjoeba
December 22nd, 2003, 03:05 AM
Thanks digitalosophy :)

I still haven't uploaded the swf with the bug fixed ...

spikeyspike76
December 22nd, 2003, 02:07 PM
Wow, it's excellent. The best I've done was a 'classic' stream, for a website's jukebox. The only suggestion I have (It's a cool one, not too hard to make) would be to have a seek bar. Can just make it by placing a little moive/draggable box on the load bar. You already have all the variables for the time elapsed, and total time, right?

onClipEvent(enterFrame){
_x=_root.bar._x + int(_root.elapsedtime / _root.totaltime / _root.bar._width)
}

Or define a function on the first frame, if you want. It makes it good 'n interactive.

The volume bar; when I drag it one pixel the sound often changes by two, are you sure it's 100 pixels high? Not a big deal; just saying. If I were doing this I'd eliminate the anti-aliasing on the buttons (not the movie quality), by making their coordinates integers. I guess that's my design scheme, though, not a bug or anything.

Sands of Morocco!

Voetsjoeba
December 22nd, 2003, 02:28 PM
Yeah, I could add that pretty fast. I'm wondering how you can tell the sound increases by exactly 2 :P I honestly don't know what size that volume slider is anymore, but it sure doesn't bother me. :)

andersom
December 22nd, 2003, 06:44 PM
Hey Voetsjoeba,

A great job on the mp3 player... thumb:
But could it be possible to make the mp3 player as in the top right corner as they did on this site?
http://turnbox.com/loose/turnbox_flash.html

and maybe with a drop down menu that way you can fit the player in any spot:) :

Andreas

jacko33
December 22nd, 2003, 08:46 PM
Hey Anderson

Like the example trying to get the same result too.

Regs,
Jacko33

spikeyspike76
December 22nd, 2003, 10:03 PM
Originally posted by Voetsjoeba
Yeah, I could add that pretty fast. I'm wondering how you can tell the sound increases by exactly 2 :P I honestly don't know what size that volume slider is anymore, but it sure doesn't bother me. :)

. . . there's a variable next to it . . .

crazysniper22
December 22nd, 2003, 10:54 PM
Originally posted by andersom

and maybe with a drop down menu that way you can fit the player in any spot:) :

Andreas

are you talking about this player here?? http://www.awamusic.com/index_main.html

great job voetsjoeba!!! even though i don't understand actionscript!

Voetsjoeba
December 23rd, 2003, 05:53 AM
Originally posted by andersom
Hey Voetsjoeba,

A great job on the mp3 player... thumb:
But could it be possible to make the mp3 player as in the top right corner as they did on this site?
http://turnbox.com/loose/turnbox_flash.html

and maybe with a drop down menu that way you can fit the player in any spot:) :

Andreas

Yes it is, all I'd have to add is a dropdown list of the songs. Not that hard, since I've already got an array with every data in it. Just a for loop that places it in the dropdown menu, no big deal.

andersom
December 23rd, 2003, 06:49 AM
Hello Voetsjoeba,

That would be very handy... but i noticed when you come on the site of Turnbox.com, the music starts after a few seconds when it's loaded a small part of the song. Would this be possible in your player?
Thanx for your reply.

CoDe-ReD
December 27th, 2003, 06:37 AM
Wow dude you rock! I really really reaaaaaaaaaaaaaaaaally like this one. Very Nice! I am currently adding some visuals to the mp3 player. I'm trying to make a real one. You know such a pocket thingy. I got one too, really neat stuff. I'll post when it's done.

BTW I hope you don't mind that I'm modifying your brilliant masterpiece Voetsjoeba?

Voetsjoeba
December 27th, 2003, 12:20 PM
Originally posted by CoDe-ReD
Wow dude you rock! I really really reaaaaaaaaaaaaaaaaally like this one. Very Nice! I am currently adding some visuals to the mp3 player. I'm trying to make a real one. You know such a pocket thingy. I got one too, really neat stuff. I'll post when it's done.

BTW I hope you don't mind that I'm modifying your brilliant masterpiece Voetsjoeba?

Not at all, free for all use. Glad you like it :)

CoDe-ReD
December 27th, 2003, 02:48 PM
So here is a little screenshot of the design. It is still on my harddrive cuz I can't find a suitable hosting site that will host MP3 files for me. I'll have a look @ that tomorrow after I've installed my new CPU cooler (Coolermaster Aero 7+, WIND POWER MWAHAHHAHAHAHA :evil: ) So anyways back to the screenshot:

CoDe-ReD
December 28th, 2003, 02:40 PM
Well it's done. Hope you like it:

LINK (http://www32.brinkster.com/b3site/flash/content/mp3player/player.html)

BTW about the streaming part... Maybe you can use something like that the mp3 file starts playing if bytesloaded = (totalbytes/6)? So that it loads a small part of the song and then starts to play the song and when the song is playing it loads the rest of the song. Would that be an idea?

CoDe-ReD
December 28th, 2003, 04:10 PM
Raaaaah!!! They removed my MP3 files! Can someone please give me a good webspace hosting adress where I can host mp3 files?

minimalistik
December 28th, 2003, 05:54 PM
mp3.com.au

CoDe-ReD
December 28th, 2003, 07:12 PM
I'll try to upload them to my home account some time later.

Ronaldino
January 3rd, 2004, 04:50 PM
Wow this is really great!!

But is there any way to make the Volume slider slide horizontally instead of vertically?!?

I hate vertical volume slider,...so ugly

minimalistik
January 4th, 2004, 03:17 AM
rotate it 90 degrees?

Voetsjoeba
January 4th, 2004, 03:39 AM
The actual sliding is done through actionscript. You'll have to mess with the prototype function to slide ;)

Ronaldino
January 4th, 2004, 03:25 PM
I would,..except there is one little problem,..

Can you point out where the script that controls the slider is located? Maybe i can swap it out with scripts for a horizontal slider.



i'm an idiot :beer:

jacko33
January 4th, 2004, 06:04 PM
Hey Voetsjoebe

Hope you had a great xmas and new year have you had a chance to look at fixing the bug I reported last year.

Some of the suggests here are pretty cool and would be wicked to implement to.

Regs,
Jacko

CoDe-ReD
January 5th, 2004, 10:22 AM
Het Voetsjoeba, I've been messing around with this loading stuff. I can't figure this out: I want my MP3 to play when 1/6 of the whole song is loaded. So if I have a song that is 6MB and I'm loading the song it should start playing after 1MB has been loaded. Can I do this?

CoDe-ReD
January 5th, 2004, 03:20 PM
Well I've finally finished it. You can view it here:

LINK (http://members.home.nl/a.kreijveldloo/mp3/player2.html)

Hope you can help me with that loading problem Voetsjoeba.

THNX 4 you great MP3 player!!

riveroaks
January 6th, 2004, 05:02 PM
Hey Voetsjoeba I asked this same question in one of my posts in which I was given a link to your thread. My question is the same as one asked earlier but I didn't understand the answer. You declared "ref" as a local reference to "this". Why. You said you didn't want it to execute until it was done loading but isn't saying ref.getBytesLoaded() the same in your case as saying this.getBytesLoaded()? I just don't understand what the difference is. And also thanks for posting your hard work, the logic in your player has helped me with mine :)

riveroaks
January 6th, 2004, 06:22 PM
nm Voetsjoeba I just saw it. I don't know why it didn't occur to me earlier. But please tell me if im wrong...but I think I understand now. Since this is relative, and you want "this" to always point towards the mp3Player object you have to make it a variable so that the path is correct from wherever your movieclip is.

Voetsjoeba
January 7th, 2004, 08:10 AM
Wow, so many new questions !


Originally posted by CoDe-ReD
Well it's done. Hope you like it:

LINK (http://www32.brinkster.com/b3site/flash/content/mp3player/player.html)

BTW about the streaming part... Maybe you can use something like that the mp3 file starts playing if bytesloaded = (totalbytes/6)? So that it loads a small part of the song and then starts to play the song and when the song is playing it loads the rest of the song. Would that be an idea?

That would be possible, yes, but if a user's connection isn't fast enough, it could happen that Flash wants to continue playing a song but it hasn't been downloaded yet, and that could seriously mess up the functioning of the player.


Originally posted by Ronaldino
Can you point out where the script that controls the slider is located? Maybe i can swap it out with scripts for a horizontal slider.

Sure:


mp3Player.prototype.dragVolumeSlider = function() {
var ref = this;
var beginScale = this.interface.vSliderScale._y;
var endScale = beginScale-this.interface.vSliderScale._height;
this.interface.vSlider.onMouseMove = function() {
if (_root._ymouse>=Math.round(endScale) && _root._ymouse<=Math.round(beginScale)) {
this._y = _root._ymouse;
ref.interface.vIndicator.text = Math.round(Math.round(beginScale-this._y)/ref.interface.vSliderScale._height*100);
ref.sound.setVolume(ref.interface.vIndicator.text) ;
}
};
};

and


mp3Player.prototype.setInitialSlider = function(volume) {
var beginScale = this.interface.vSliderScale._y;
var endScale = beginScale-this.interface.vSliderScale._height;
this.interface.vSlider._y = beginScale-(volume/100)*(beginScale-endScale);
this.interface.vIndicator.text = volume;
};


If you need help making the slider horizontal, feel free to ask ;)


Originally posted by jacko33
Hey Voetsjoeba

Hope you had a great xmas and new year have you had a chance to look at fixing the bug I reported last year.

Some of the suggests here are pretty cool and would be wicked to implement to.

Regs,
Jacko


Sorry, yes, I fixed that problem but I didn't upload the fix yet ... I think. I should do that.


Originally posted by riveroaks
Hey Voetsjoeba I asked this same question in one of my posts in which I was given a link to your thread. My question is the same as one asked earlier but I didn't understand the answer. You declared "ref" as a local reference to "this". Why. You said you didn't want it to execute until it was done loading but isn't saying ref.getBytesLoaded() the same in your case as saying this.getBytesLoaded()? I just don't understand what the difference is. And also thanks for posting your hard work, the logic in your player has helped me with mine


I used ref(erence) as a variable to make targetting easier. I used it because I use the onEnterFrame handler of several movieclips; If I'd use this inside the handlers, I'd be targetting the movieclip, while I need to target the instance of the Mp3Player class from which this function is executed. That's what ref targets: this. I can't use this inside the onEnterFrame handler, that's why I used ref as a reference to the Mp3Player instance.


Originally posted by riveroaks
nm Voetsjoeba I just saw it. I don't know why it didn't occur to me earlier. But please tell me if im wrong...but I think I understand now. Since this is relative, and you want "this" to always point towards the mp3Player object you have to make it a variable so that the path is correct from wherever your movieclip is.

Lol, I should read the entire thread before starting to answer :P Yes, that is correct :)

andersom
January 7th, 2004, 09:50 AM
Hey Voets,

You said you can make the mp3 player streaming, but only if the peops have a fast connection...

Would it be possible to make a button in the mp3 player. where the visitor can switch between streaming and no streaming?

Andreas!:hair:

Voetsjoeba
January 7th, 2004, 12:11 PM
Originally posted by andersom
Hey Voets,

You said you can make the mp3 player streaming, but only if the peops have a fast connection...

Would it be possible to make a button in the mp3 player. where the visitor can switch between streaming and no streaming?

Andreas!:hair:

Making it streaming would complicate the whole functioning of the player. It's not easy to code a streaming mp3 player with this functionality. There are complications to streaming audio such as the sound.position property which keeps increasing instead of restarting. I'd have to mess with suctracting already played time, and things like that. It gets really messy and buggy, that's why I prefer to make it non-streaming.

CoDe-ReD
January 8th, 2004, 10:47 AM
but you could kinda fake it by letting it play when 1/3 of the song is loaded or something. That would be cool. What do I need to change in the code?

Voetsjoeba
January 8th, 2004, 01:34 PM
You would need to change the if(getBytesLoaded() == getBytesTotal()) to if(getBytesLoaded() >= getBytesTotal()/3), and call in some new movies to have the loadbar continue growing when 1/3 of the total has been reached.

jacko33
January 12th, 2004, 03:17 AM
Hey Voetsjoeba

Jacko here wondering if you are going to post up any new versions of the player?

Cannot wait to see it.

Regards,
David

ez_stylin
January 30th, 2004, 02:14 PM
what about other file types... like *.wma? how would you use this player to load em? is it possible?

Voetsjoeba
January 30th, 2004, 02:47 PM
I don't think Flash can read wma files.

APDesign
February 4th, 2004, 03:17 AM
While messing around with this I noticed that this wasn't working.



this.paused = 1;
// this.paused -- Paused at beginning, 1 or 0


I was trying to make it so you could browse through the track with the forward/backward buttons but only load the song on demand (via the play button) I couldn't get that to work, so I settled for just setting it to pause at the start... I don't know why it wouldn't work for me unless I somehow forgot to replace some of the original code, can anyone confirm/deny this?

Voetsjoeba
February 4th, 2004, 07:33 AM
APDesign -- It could be possible that I forgot the pausing at the beginning possibility. I've updated the player, let me know if you're still having problems with this version.

MP3Player v1.1:

jacko33
February 4th, 2004, 07:41 PM
Hey Voetsjoeba

Will I have a had a play around with the player it appears to have all the bugs fixed BUT Big V don't hate me but I have found two new ones :)

1. Ok first when you load the swf the first song loads but doesn't play you have to press the play button to get the player started. (This can be fixed with a little actionscript)

2. When you have the first song playing and skip track it loads prefect and plays but the track timer stays set on zero. But if you press pause then play it fixes and displays the timer counting up.

Apart from that nearly the prefect player

Keep up the good work

Jacko

Voetsjoeba
February 5th, 2004, 04:17 PM
The first is because it is set to paused at start - if you have to click play, then it's working as it should :)

The other one appears to have been tougher than I thought ... probably because I haven't been working with this player for some time.

I think it's time for v2.

APDesign
February 9th, 2004, 04:09 PM
Ok, a couple more questions (sorry!) One REALLY weird question: When I say info.embedFonts=true; to embedFonts into the info text field, the text gets HUGE for no apparent reason. It works fine for every other text field though, any ideas?

And one other question that you don't have to answer if its too much to ask. Do you know if there is any way to make it NOT load a track when it starts up? (I don't want it to eat up 2 MB every time someone visits the page if they don't intend to listen to the music.) Thanks a heck of a lot for your help and for this awesome MP3 player!

Voetsjoeba
February 9th, 2004, 04:16 PM
I have no idea about your textfield, sorry. That has never happened to me before.

Well, yeah, I couldn't implement everything in there. Somebody wants this, and somebody else wants another thing. I'm working on version 2 of this player at the moment, which should be streaming (if I get it to work, streaming audio in Flash is quite annoying to work with), and has a lot of features and settings.

jacko33
February 9th, 2004, 06:44 PM
I think it is 3 cheers for voetsjoeba because the player does everything I need it to

Jacko

ez_stylin
February 10th, 2004, 01:11 AM
EXCELLENT STUFF Voetsjoeba !!!

so i decided to put visuals on it... HERE, (http://www10.brinkster.com/illkross/AT/MP3_2.html) u can check the online mp3 player.

Now im having problems too like those mentioned by others (mp3 loading when skipped, track numbers, yada yada..). so i was wondering if u could check it out (the online mp3 player (http://www10.brinkster.com/illkross/AT/MP3_2.html)) to see the problem.

Also, HERE, (http://www10.brinkster.com/illkross/AT/MP3Player_v1.1.txt) is the current code i have on there, in case you want to look at it and see which ones i have to change.

Another, HERE, (http://www10.brinkster.com/illkross/AT/localplaylist.xml) is the xml file with the songs (in case u wanna check it too). Sometimes the song doesnt load at all, and sometimes it shows full bar loaded but the display shows 0kb/xkb. im pretty sure the mp3 links are fine coz iv tried them all in Windows Media Player...

iv read the whole thread... but somehow i think im lost. if its not too much to ask, could you point out the things i should tweak, or better if u can put up something that i could just swap in...

AWESOME Player!

ez_stylin
February 10th, 2004, 01:13 AM
...on the playlist, only track 20 plays. at least on my pc. but i havent tried it on other computers

Edited: i switch track 20 to 1 so we can play that one first since its the only one i got to work

kirupa
February 10th, 2004, 01:15 AM
I am not sure if I mentioned this earlier voets, but this is absolutely fantastic! :)

Voetsjoeba
February 10th, 2004, 03:09 PM
Thanks Kirupa :)

ez_stylin' - That interface looks really cool ! I know this thread might be getting confusing - I think I've messed up with several versions. That's why I've started v2.

ez_stylin
February 11th, 2004, 12:32 PM
thanx. but is it working ok?

Voetsjoeba
February 11th, 2004, 01:02 PM
Which version ?

ez_stylin
February 11th, 2004, 04:01 PM
oh... the one im workin on or made, and yeah sure the v2..? u finishd it?

Voetsjoeba
February 12th, 2004, 03:15 PM
Lol, no. I'm still workin' on it. I'm very busy lately, and I hardly find time to work on it. I'll post it when it's done.

ez_stylin
February 12th, 2004, 05:56 PM
kk... no hurry... same here.. busy at school nowadays

imported_mucho
March 1st, 2004, 06:52 PM
just found this....
great stuff!
the guys from flashfourm.DE aren't as close as useful / nice as the the peeps from kirupa...

rock on!

mucho

Condor182
March 3rd, 2004, 01:55 PM
First of all, let me say very very nice Mp3 Player.
Tip my hat to you! :cowboy:

And now my question, is there a way that I could use the .swf songs instead of .mp3 songs for the mp3 player?
Thanks!

Voetsjoeba
March 4th, 2004, 03:34 PM
v2 released ! Check out the FMX 2004 forum.

tayfunde
September 17th, 2004, 05:47 AM
hey Voetsjoeba
i was searching for an tutorial for n streaming audio player..but i ound nothing...and now i found your player....
im trying thsi WE to understand the code...but this would be hard..because im new into actionscript...
but ill do my best...
very very nice player!!!
u rock!

Voetsjoeba
September 17th, 2004, 03:02 PM
Thanks :) Be sure to check out v3 too ;)

netrix
September 18th, 2004, 09:32 AM
are u working on a streaming version??? version 3 = streaming???... that would be so nice!

Voetsjoeba
September 18th, 2004, 11:06 AM
Both v2 and v3 are streaming and available.

netrix
September 18th, 2004, 06:25 PM
v3 is out?? when ?? where???

paddy.
September 18th, 2004, 06:28 PM
Try Voets' homepage.

paddy.
September 18th, 2004, 06:31 PM
Unless it looks exactly like V.2 then I don't see it. Voets, care to step in and clarify this?

netrix
September 18th, 2004, 07:54 PM
lol... moments later i posted i went to his site and saw the info but thanks anyways.

:link:

Voetsjoeba
September 19th, 2004, 07:43 AM
Here's the link, for anyone who can't find it: http://www.voetsjoeba.com/lab.php?i=16

netrix
September 20th, 2004, 02:55 PM
hey Voetsjoeba i was playing with ur player and modified a bit... but tried to put the whole player inside a new movieclip and then i can't seem to find the as to update the new location of the volume indicator... everything else its just fine, and its been recognized as a movie clip but i can't drag it in any diractions... also i put everything inside a movie clip for various reasons being one to try to drag the whole player around, but if i tried to drag it around i will lose the whole functionality of the buttons... how can i overcome that????????? btw i'm using v2 and it rocks!!

:link:

Voetsjoeba
September 20th, 2004, 04:10 PM
You gotta check your paths to make sure everything is still working. Check the code part above the XML load.

netrix
September 20th, 2004, 06:41 PM
You gotta check your paths to make sure everything is still working. Check the code part above the XML load.

that's what i did... i changed them all and everything works ok exept the volume indicator, everything was working ok until i put the whole thing inside a movie clip... i'm goona check them again just in case!

netrix
September 20th, 2004, 06:49 PM
what about the drag thing?? and btw if i wanted to triger a movie clip once the music loads, where do i put the code to do it??

netrix
September 21st, 2004, 07:36 PM
can u help me Voetsjoeba???? please!!!

Magnum_357
November 26th, 2004, 10:40 AM
Here is a cool mp3 player that uses xml list
took me a while to get it working.It has all the functions
you would want in a streaming mp3 player.




mp3player (http://mgamerz.com/SKINNED PLAYER.html)

netrix
January 4th, 2005, 01:39 PM
hello everyone:

can anyone tell me if there's a way to preload a song while you are hearing one?... for example its posible to load song #4 while hearing song #3???? thanks in advance and happy new year!

pravyn
January 13th, 2005, 03:12 PM
VoetsBoeba,
its a fantastic mp3 player with XML playlist, but I see that it is writting the .mp3 files to the user's local machine "
C:\Documents and Settings\z666850\Local Settings\Temporary Internet Files
" is it possible to restrict this bit ???

that would be fantastic.. will cover copyrights issues and infringement over our media files..
thanks in advance

lunatic
January 13th, 2005, 03:22 PM
I think you want the streaming player on Voetsjoeba's website:

http://www.voetsjoeba.com/lab.php?i=8

:hr:

Voetsjoeba
January 13th, 2005, 03:50 PM
Or this one, v3 :beam:
http://www.voetsjoeba.com/lab.php?i=16

lunatic
January 13th, 2005, 03:51 PM
Or this one, v3 :beam:
http://www.voetsjoeba.com/lab.php?i=16

Does that one stream? I wasn't sure.

FlashPlaya
January 13th, 2005, 05:30 PM
Yeah it looks like it does....:thumb:

Voetsjoeba
January 14th, 2005, 02:16 PM
Yup, I made it streaming only because all I got were requests to create a streaming player ... so there ya go :)

lunatic
January 14th, 2005, 04:18 PM
see, I knew there was a reason you ruled

:thumb:

Apegrope
February 2nd, 2005, 11:24 AM
I have Flash MX 2004. How come everytime I export the movie I get 10 errors telling me there's "No method with the name 'Delegate'"?

I didn't change anything in the movie or the AS file.

bliss1422
February 10th, 2005, 12:06 AM
I have Flash MX 2004. How come everytime I export the movie I get 10 errors telling me there's "No method with the name 'Delegate'"?

I didn't change anything in the movie or the AS file.

I'm having the same issue looks like its trying to load some special actionscript we don't have ...

Grafdude
March 10th, 2005, 02:22 PM
The links are broken! Where can I download this mp3 player?

andersom
March 11th, 2005, 06:48 AM
http://downloads.voetsjoeba.com/?1099254425

hope that helps!

tobijas20
June 11th, 2005, 08:44 AM
Is there any way to put loop option in this script. For example: I like song No1. and I don't want automatically to download next song?

Something like checkbox maybe?

MrWallace
July 12th, 2005, 02:14 PM
Okay, first of all, all three players are great and I'm sure the 4th version will be great as well!

Secondly, I know I'm coming in late on this topic but I just started researching music players for Flash and now here I am!

I do have an issue though (I know what your thinking Voets: "Oh great! Another one!"). When I edit the XML script to play my music files (mp3's) they play back extremely fast when I test the player in Flash (I'm using the 2nd version of the player).

Any ideas?

wo1olf
August 12th, 2005, 11:43 AM
It's cool what you did, but is there a way to do exactily the same thing with video files (mpeg, or flv) instead of mp3?

Voetsjoeba
August 12th, 2005, 12:20 PM
No, sorry.

Alain Raap
August 16th, 2005, 05:15 PM
Hi all,

I made a same sort of really working jukebox with XML playlists, you can find it at this site (http://members.chello.nl/a.raap1/jukebox.html )
You can use it with a streaming server (FlashCom) or a webserver. I have a Flashcom server online in the evening, you can connect to IP-address
213.46.26.43 in the Connect screen and you get a lot of music :mu:
If someone is interested I can put the sources (Flash MX) here on the site.

webmask
September 14th, 2005, 10:32 PM
this is interesting.. good job voetsjeoba

LostBear
September 15th, 2005, 09:21 AM
ooooo yes please.....make sources available. thx!!

Alain Raap
September 15th, 2005, 02:45 PM
ooooo yes please.....make sources available. thx!!

Where can I post them, is there a download section here on kirupa?
My FlashCom server is working again and can be found at 213.46.26.54 (in the Connect window type this address and click Connect)!

Alain

evildrummer
May 1st, 2006, 10:09 AM
The links at the beggining are broken, could someone post a tutorial on how to do this, cause I need one for a site, and I have never built a player before.

jonybigude
May 2nd, 2006, 07:37 AM
so, is there a source or a tutorial or what? :}

simplistik
May 2nd, 2006, 07:55 AM
he switched servers... I feel like I've posted this link a thousand times
http://www.voetsjoeba.com/tempsite/lab/12/xml-mp3-player-v3

noobie
May 16th, 2006, 06:15 PM
Hey voetsjoeba! I downloaded the v3's source to try it out but it keeps generating this error.
There is no method with the name 'Delegate' Any idea? :kir:

BDore
June 30th, 2006, 03:35 PM
Hey simplistik, that link you posted is also broken...

konstrain
June 21st, 2007, 07:16 AM
jus go to the domain and search for the tuts

http://www.voetsjoeba.com/