0
我正在構建自定義音頻播放器。整個事情驅動MediaPlayback組件。我有一個隨着歌曲進程而移動的洗刷器。我希望能夠點擊並擦除它。目前我已設置爲將playheadTime設置爲等於拖動滑塊的百分比距離乘以播放組件的總時間。在釋放滑塊後,我會追蹤播放頭時間,它似乎很好,但我無法讓它繼續播放。以下是控制器中的代碼:Flash AS2:設置MediaPlayback組件的playheadTime
var totalDistance = bar_mc._width - slider_mc._width;
var wasPlaying = false;
this.onEnterFrame = function(){
var tTime = this._parent._parent._parent.music_mp3.totalTime;
var cTime = this._parent._parent._parent.music_mp3.playheadTime;
var percDone = cTime/tTime;
slider_mc._x = percDone * totalDistance;
}
slider_mc.onPress = function(){
wasPlaying = this._parent._parent._parent._parent.music_mp3.playing;
this._parent._parent._parent._parent.music_mp3.pause();
this.startDrag(false,0,0,totalDistance,0);
delete this._parent.onEnterFrame;
this.onEnterFrame = function(){
this._parent._parent._parent._parent.music_mp3.playheadTime = this._x/totalDistance * this._parent._parent._parent._parent.music_mp3.totalTime;
}
}
slider_mc.onRelease = slider_mc.onReleaseOutside = function(){
this.stopDrag();
if(wasPlaying){
this._parent._parent._parent._parent.music_mp3.play();
trace(this._parent._parent._parent._parent.music_mp3.playheadTime);
}
this._parent.onEnterFrame = function(){
var tTime = this._parent._parent._parent._parent.music_mp3.totalTime;
var cTime = this._parent._parent._parent._parent.music_mp3.playheadTime;
var percDone = cTime/tTime;
slider_mc._x = percDone * totalDistance;
}
}