我制作了一个自定义滑块,一切似乎都很好,但我正在尝试使用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;
答案 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);