Noch nicht viel geschrieben
ich habe hier ein mp3 player und der soll wenn das lied zu ende ist wieder von vorne losgehen kann mir jemand sagen was ich ändern muss damit es sich wiederholt
danke schon mal im vorraus
Code:
class Mp3player {
public var sound:Sound;
public var soundFile:String;
private var isPlaying:Boolean = false;
private var sVolume:Number = 0;
private var interval:Number;
function Mp3player(soundFile:String) {
this.soundFile = soundFile;
streamSound(soundFile);
}
function streamSound(soundFile):Void {
var sound:Sound = new Sound();
var ref = this;
sound.onLoad = function() {
ref.pos(sound);
};
sound.onSoundComplete = function() {
isPlaying = false;
streamSound(soundFile);
};
sound.loadSound(soundFile, true);
sound.setVolume(sVolume);
_root.player.sPre_mc.onEnterFrame = function() {
var sGesamt:Number = sound.getBytesTotal();
var sGeladen:Number = sound.getBytesLoaded();
var sProzent:Number = Math.ceil(sGeladen/sGesamt*100);
this.gotoAndStop(sProzent);
if (sProzent == 15) {
ref.playSong(sound);
}
if (sProzent == 100) {
ref.playSong(sound);
this.gotoAndStop(1);
delete this.onEnterFrame;
}
};
}
function transVolume(sound):Void {
if (sound.getVolume()<100) {
sound.setVolume(sound.getVolume()+1);
} else {
clearInterval(interval);
}
}
function pos(sound):Void {
_root.player.sPos_mc.onEnterFrame = function() {
var sPosition:Number = int(sound.position);
var sDuration:Number = int(sound.duration);
var sWo:Number = Math.round(sPosition/(sDuration/100));
this.gotoAndStop(sWo);
if (sPosition == sDuration) {
this.gotoAndStop(1);
delete this.onEnterFrame;
}
};
}
function playSong(sound):Void {
gui(sound);
if (!isPlaying) {
sound.start(0);
interval = setInterval(transVolume, 200, sound);
isPlaying = true;
}
}
function gui(sound) {
_root.player.btn.onRelease = function() {
if (this._parent.txt._currentframe == 1) {
sound.stop();
this._parent.txt.gotoAndStop(2);
} else {
sound.start();
this._parent.txt.gotoAndStop(1);
}
};
}
}
danke schon mal im vorraus