Jump to content


it won't play after pausing the music


  • You cannot reply to this topic
2 replies to this topic

#1 Mike Truong

    Young Padawan

  • Members
  • Pip
  • 7 posts

Posted 04 July 2007 - 03:53 PM

Hi, is it something wrong with this code? Everything work fine accept when and press pause button, I can't press play again. It doesn't play the save position of the songs. Please help me out.



thank u




stop();
title_txt.autoSize = "left";
timeDisplay_txt.autoSize = "left";

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]);
}
}
_root.createEmptyMovieClip("sound_mc", 1);
_global.song_nr = (0);
playing = true;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};

// Song Duration Time
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;
};

// Song Timer
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;
};

// Song Starter
MovieClip.prototype.songStarter = function(file, name, band) {
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.sound_obj.setVolume(0);
//trace(CurrentVolume);
this._parent.equalizer.gotoAndStop("eqstart");

// Text Title
this.onEnterFrame = function() {
if (this.sound_obj.position < this.sound_obj.duration) {
delete this.onEnterFrame;
this._parent.title_txt.text = name+" - "+band;
timeInterval = setInterval(timer, 1000, this.sound_obj);
} else {
this._parent.title_txt.text = "loading song...";
}
};

// Loading Sound Function
this.sound_obj.onSoundComplete = function() {
clearInterval(timeInterval);
this._parent.timeDisplay_txt.text = "00:00/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]);
this._parent.equalizer.gotoAndStop("eqstop");
};

// Volume Dragger
this._parent.volume1.dragger.onPress = function() {
startDrag(this, true, 0, this._y, this._parent.dragger_bar._width, this._y);
this.onEnterFrame = function() {
var p = (this._x/this._parent.dragger_bar._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();
};
};

// Stop button Function
btn_stop.onRelease = function() {
pause = false;
clearInterval(timeInterval);
this._parent.timeDisplay_txt.text = "00:00/00:00";
this._parent.sound_mc.sound_obj.stop();
this._parent.equalizer.gotoAndStop("eqstop");
};

// Pause button Function
btn_pause.onRelease = function() {
this._parent.sound_mc.sound_obj.stop();
pausedtime = _root.sound_mc.sound_obj.position/1000;
pause = true;
this._parent.equalizer.gotoAndStop("eqstop");
};

// Play button Function
btn_play.onRelease = function() {
if(pause == true) {
this._parent.sound_mc.sound_obj.start(pausedtime);
pause = false;
playing = true;
} else {
clearInterval(timeInterval);
_root.timeDisplay_txt.text = "00:00/00:00";
this._parent.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
this._parent.equalizer.gotoAndStop("eqstart");
playing = true;
}
};

playlist.load("playlist.xml");
setInterval(duration,100);

#2 Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 04 July 2007 - 07:30 PM

This is the 3rd copy of the same problem from you. Stop spamming the forums please. I asked you a question in one of the other posts that you haven't answered yet. Go find that post and answer the question, then maybe I'll have enough information to help.

#3 Ben

    P2L Jedi Master

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

Posted 05 July 2007 - 02:51 AM

No offense, but what I suggest is that you learn how to code actionscript instead of copy and pasting, that way you can make your own music player and avoid these problems.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users