Funkysoul i got a bit of prob!
i implented as said
Pause Button
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
}
then i changed paly button
btn_play.onRelease = function() {
if (pause == true){ // no comment....
this._parent.sound_mc.sound_obj.start(posiP) // start sound from the previously saved position
}
else {
clearInterval(timeInterval);
_root.timeDisplay_txt.text = "00:00";
this._parent.sound_mc.songStarter(songfile[song_nr], songname[song_nr]);
}
};
There r two conditions tht can happen!
Condition 1
If i play the song and press stop...the song stops...If i press play again the song will play again frm the start
Condition 2
Suppose my song is playing and suddenly i press Pause...the song will pause itself
after some time i press play again...the song will continue frm where it was paused.
Here comes the problem Now wen i want to listen to the song frm the start i press stop button...the song will stop
to listen to it again i press Play...instead of playing frm the start it plays frm where i stopped......It is like if u press pause once the stop button will start to act like pause button!!
Here is the complete code i use
stop();
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;
}
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);
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;
stopDrag();
};
this._parent.volume1.dragger.onReleaseOutside = function() {
stopDrag();
};
}
btn_play.onRelease = function() {
if (pause == true){ // no comment....
this._parent.sound_mc.sound_obj.start(posiP) // start sound from the previously saved position
}
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();
}
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");
Edited by Amrik, 09 May 2006 - 09:15 AM.