vue移动端video禁止快进
参考文章:https://blog.csdn.net/qq_37300451/article/details/80852684
参考上文做出功能后,发现视频在暂停后,再次播放时,不是从上次暂停的位置开始播放,后来折腾了一天,发现不是代码的问题,是视频的问题,视频有个关键帧距离的概念,后来用 狸窝视频转换器 重新导出了一个视频,定位就准确了
具体参考文章:
https://www.cnblogs.com/luoeeyang/p/9765506.html
感谢上面两位大佬提供的帮助。
后面还有个功能,用户暂停或者退出页面后,下次进入页面,直接从上次离开的地方开始播放,也遇到一些坑,后来查阅资料,使用 timeupdate 解决了问题
that.localTime = that.localTime ? that.localTime : Number(window.localStorage.getItem(`remTime_${this.videoId}`));
if (that.localTime > 0) { // 自动跳转到上次播放位置
var setTimeFlag = 1; // 用于安卓监听timeupdate,currentTime只赋值一次
var ua = navigator.userAgent;
if(ua.indexOf("iPhone") > -1 || ua.indexOf("iOS") > -1){
// ios
vd.currentTime = that.localTime;
}else{
// 安卓
vd.addEventListener("timeupdate", function(){
if(setTimeFlag == 1){
vd.currentTime = that.localTime;
setTimeFlag = 2;
}
});
}
}
因为被坑惨了,所以整理了一下,希望对有需要的朋友产生一些帮助