我在浏览器中有一个嵌入式媒体播放器,由 javascript 控制以处理所有 mediaChange 事件。代码看起来像
mediaChangeHandler: function(media) {
if (media && this.offset && !this.offsetJumpPerformed) {
if (parseFloat(media.duration) > this.offset) {
pos = parseInt(pos);
this.getPlayer().controls.currentPosition = pos;
alert("jump to position: " + this.getPlayer().controls.currentPosition);
this.play();
this.offsetJumpPerformed = true;
alert("currentPosition:" + this.getPlayer().controls.currentPosition);
}
}
}
第一个警报表明 currentPosition 是我想要的位置。但是,第二个警报会得到比我设置的值少几秒钟的 currentPosition。
有谁知道为什么?我试过用谷歌搜索,但没有发现任何有用的东西。谢谢!