Jump to content


Funkysoul's MP3 Player


  • You cannot reply to this topic
1 reply to this topic

#1 Amrik

    Young Padawan

  • Members
  • Pip
  • 43 posts

Posted 24 December 2007 - 05:56 AM

Hi,
I have created an mp3 player based on the 3 tutorials written by funkysoul.... everything was going on good until i uploaded the files onto my web

http://anusorn.saiya...g/wheew/Player/ << Here's the link to the player

As you can see when u press the play button the [time elapsed/total duration]
yea the total duration is also on the move it should not be moving it should be stayin still showin how ling the song is :yodasearch:

Here is the code I'm using...i just cant seem to fix it :)
Anybody Capable Of Helpin Please do!
Thanks
stop();
timeDisplay_txt.autoSize = "left";
toolTip._visible = false;
play_mc._visible = false;
pause_mc._visible = false;
stop_mc._visible = false;
next_mc._visible = false;
prev_mc._visible = false;
playlist = new XML();
playlist.ignoreWhite=true;
playlist.onLoad = function (success) {
if(success) {

_global.songname = [];
_global.songfile = [];
for (var i=0; i<playlist.firstChild.childNodes.length; i++) {

_global.songname[i] = playlist.firstChild.childNodes[i].attributes.name;
_global.songfile[i] = playlist.firstChild.childNodes[i].attributes.file;
}
}
_root.createEmptyMovieClip("sound_mc",1);
_global.song_nr = (0); 
}


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+"/"+totalDuration;
}
function duration (){
	timed = _root.sound_mc.sound_obj.duration/1000;
	mind = Math.floor(timed/60);
	mind = (mind<10) ? "0"+mind : mind;
	secd = Math.floor(timed%60);
	secd = (secd<10) ? "0"+secd : secd;
	totalDuration = mind+":"+secd;
}
MovieClip.prototype.songStarter = function (file, name) {
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; 
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]);
}
this._parent.volume1.dragger.onPress = function() {
startDrag(this, true, 0, this._y, this._parent.volBG._width, this._y);
_root.toolTip._visible = true;
setInterval(100);
function draggableTip(){
_root.toolTip._x = _root._xmouse;
}
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;
_root.toolTip._visible = false;
stopDrag();
};
this._parent.volume1.dragger.onReleaseOutside = function() {
_root.toolTip._visible = false;
	stopDrag();
};

};
function soundStatus(){
	var amountLoaded = _root.sound_mc.sound_obj.getBytesLoaded() / _root.sound_mc.sound_obj.getBytesTotal();
	_root.loader.loadBar._width = amountLoaded * 260;
	duration = _root.sound_mc.sound_obj.duration;
	position = _root.sound_mc.sound_obj.position;
	_root.playHead._x = position / duration * 272 + 5;
}


btn_play.onRelease = function() {
if (pause == true){ 
this._parent.sound_mc.sound_obj.start(posiP) 
}
else {
clearInterval(timeInterval);
_root.timeDisplay_txt.text = "00:00";
this._parent.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
}
};
btn_stop.onRelease = function() {
clearInterval(timeInterval);
this._parent.timeDisplay_txt.text="00:00";
this._parent.sound_mc.sound_obj.stop(); 
pause = false;
}
btn_next.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]);
}
btn_prev.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])
}
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
}
playlist.load("playlist.xml");
setInterval(duration,100);
setInterval(soundStatus,100);


#2 flamereaper

    Young Padawan

  • Members
  • Pip
  • 65 posts
  • Gender:Male
  • Location:UK

Posted 09 January 2008 - 12:42 PM

Ok well the reason that the duration is not staying still is because its displaying the duration of the file as its streamed in, so at the start when the whole song hasnt loaded, the duration is smaller, if you leave it for a while, the song loads in and the duration text stops at the songs duration.

sadly i dont have the time to look through the code and offer a sollution to this, my only sugestion would be to display a loading display untill the entire song is loaded, then start the duration text.

but hey at least i have pointed out whats going on. hopefully that will help a bit.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users