自定义滑块AS3声音搜索

时间:2015-06-08 08:13:58

标签: javascript jquery actionscript-3 flash

我制作了一个自定义滑块,一切似乎都很好,但我正在尝试使用this.mySlider.sliderTrack.mouseX

中的width:1000px位置创建一个搜索功能以使滑块移动

我只需要帮助弄清楚如何使mouseX成为新的channel.position

var newPercent = this.mySlider.sliderTrack.mouseX = playbackPercent; snd.play(newPercent)

var sliderKnob = this.mySlider.sliderKnob;
var sliderTrack = this.mySlider.sliderTrack;
var estimatedLength:int = Math.ceil(snd.length / (snd.bytesLoaded / snd.bytesTotal)); 
var playbackPercent:uint =  Math.round(100 * (channel.position / estimatedLength));
sliderKnob.x = playbackPercent;

1 个答案:

答案 0 :(得分:1)

您可以获得搜索位置与总长度之间的比率

var newPercent = this.mySlider.sliderTrack.mouseX  / 1000 /// 1000 px for your case
var totalDurationOfMedia = 3232 /// This comes from metadata, total length of the media
var whereToSeek = newPercent * totalDurationOfMedia
mediaPlayer.seek(whereToSeek);