Jump to content


can't play position of the song after pause


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

#1 Mike Truong

    Young Padawan

  • Members
  • Pip
  • 7 posts

Posted 30 June 2007 - 09:35 AM

Mike

Hi, i can pause it but when i replay it. It wont play the same pause position. Any idea, please help...
thankx

My code:


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 = random(songfile.length);
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};

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

// Sound 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(1);


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

// 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(2);
};

// 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() {
clearInterval(timeInterval);
this._parent.timeDisplay_txt.text = "00:00/00:00";
this._parent.sound_mc.sound_obj.stop();
this._parent.equalizer.gotoAndStop(2);
};

// Play button Function
btn_play.onRelease = function() {
if(pause==true) {
this._parent.sound_mc.sound_obj.start(posiP)
} 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(1);
}
};

// Pause button Function
btn_pause.onRelease = function() {
this._parent.sound_mc.sound_obj.stop();
posiP = this._parent.sound_mc.sound_obj.position/1000;
pause = false;
this._parent.equalizer.gotoAndStop(2);
};

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

#2 Pax

    P2L Jedi

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

Posted 30 June 2007 - 09:50 AM

// Pause button Function
btn_pause.onRelease = function() {
this._parent.sound_mc.sound_obj.stop();
posiP = this._parent.sound_mc.sound_obj.position/1000;
pause = false;
this._parent.equalizer.gotoAndStop(2);
};

change:
pause = false;

to

pause = true;

#3 Mike Truong

    Young Padawan

  • Members
  • Pip
  • 7 posts

Posted 30 June 2007 - 09:58 AM

View PostPax, on Jun 30 2007, 07:50 AM, said:

// Pause button Function
btn_pause.onRelease = function() {
this._parent.sound_mc.sound_obj.stop();
posiP = this._parent.sound_mc.sound_obj.position/1000;
pause = false;
this._parent.equalizer.gotoAndStop(2);
};

change:
pause = false;

to

pause = true;






I still have the same problem after changing to pause=true, please advise

#4 Pax

    P2L Jedi

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

Posted 30 June 2007 - 04:41 PM

Is it replaying from the start of the song or from a different spot?

#5 Mike Truong

    Young Padawan

  • Members
  • Pip
  • 7 posts

Posted 30 June 2007 - 05:56 PM

View PostPax, on Jun 30 2007, 02:41 PM, said:

Is it replaying from the start of the song or from a different spot?






it doesn't play at all when i press on play button. No sound......

Edited by Mike Truong, 30 June 2007 - 05:57 PM.


#6 Ben

    P2L Jedi Master

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

Posted 30 June 2007 - 07:20 PM

Try tracing the value of posiP when you click the pause button.

#7 Mike Truong

    Young Padawan

  • Members
  • Pip
  • 7 posts

Posted 30 June 2007 - 09:28 PM

View PostBen, on Jun 30 2007, 05:20 PM, said:

Try tracing the value of posiP when you click the pause button.





i did the trace function on posiP it return the time of pause. I also use trace on Play button and it return the same time but it's just no sound, doesn't play the sound. Thank you for help me out. I think this could the problem but not sure...


this._parent.sound_mc.sound_obj.stop(); // will auto delete the sound????? Do you think so?

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

Edited by Mike Truong, 30 June 2007 - 09:30 PM.


#8 Pax

    P2L Jedi

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

Posted 30 June 2007 - 10:35 PM

Is there a stopAllSounds() being called anywhere? What code was changed between your mp3 player and funkysoul's original code?

#9 Mike Truong

    Young Padawan

  • Members
  • Pip
  • 7 posts

Posted 01 July 2007 - 12:26 PM

View PostPax, on Jun 30 2007, 08:35 PM, said:

Is there a stopAllSounds() being called anywhere? What code was changed between your mp3 player and funkysoul's original code?




No there isn't StopAllSounds() being called. I use trace() function on the play button right after

if(paused = true) {
trace(this._parent.sound_mc.sound_obj.start(pausedtime));
}

it returned "undefine". Funny thing is that it can pause but I can't press play again. Song doesn't start where it saved. Any ideas???? Please help...

Mike





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users