我通过视频范围停止了视频,并使用标记从视频结尾开始播放视频,因为我面临的问题是,当我刷新页面代码工作正常时。
我没有刷新它不工作即。视频不是暂停。
下面是我的代码:
MediaElement('player1', {
success: function (me) {
var flag = true;
var me = document.getElementById('player1');
me.play();
me.addEventListener('timeupdate', function () {
if (flag) {
if (this.currentTime > 4.10234 && this.currentTime < 4.451111) {
this.pause();
flag = false
}
}
document.getElementById('time').innerHTML = me.currentTime;
}, false);
document.getElementById('playmode')['onclick'] = function () {
if (me.paused) me.play();
else me.pause();
};
}
});
答案 0 :(得分:0)
从[]
中删除onclick
,
document.getElementById('playmode').onclick = function () {
if (me.paused) me.play();
else me.pause();
};
请勿reassign
me
变量
success: function (me) {// me is your player here
var flag = true;
//var me = document.getElementById('player1'); //remove this line
me.play();
me.addEventListener('timeupdate', function () {
if (flag) {
if (this.currentTime > 4.10234 && this.currentTime < 4.451111) {
this.pause();
flag = false
}
}
document.getElementById('time').innerHTML = me.currentTime;
}, false);
document.getElementById('playmode').onclick = function () {
if (me.paused) me.play();
else me.pause();
};