**video标签在微信公众号上出现的一些问题**
1,在微信公众号Android和iOS 视频播放禁止放大
video标签上添加属性 video.attr('playsinline','true'); video.attr('x5-playsinline','true');
2,Android在微信端视频播放完之后推荐不相关的内容
···let isiOS = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // 判断是否是iOS if (!isiOS) { video.play(); setTimeout(() => { video.pause(); }, 100) }
监听播放进度条是否拖动 var video = document.querySelector('video'); var supposedCurrentTime = 0; var allowSeekTime = 1; // max allow seek time in seconds 监听当前的播放位置发送改变时触发。 video.addEventListener('timeupdate', function() { if (!video.seeking) { supposedCurrentTime = video.currentTime; } }); // prevent user from seeking 寻址中(Seeking)指的是用户在音频/视频中移动/跳跃到新的位置。 video.addEventListener('seeking', function() { var delta = video.currentTime - supposedCurrentTime; if (Math.abs(delta) > allowSeekTime) { console.log("Seeking is disabled"); video.currentTime = supposedCurrentTime; } }); // delete the following event handler if rewind is not required let isiOS = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) 监听视频播放完成 video.addEventListener('ended', function() { // reset state in order to allow for rewind supposedCurrentTime = 0; if (!isiOS) { video.play(); setTimeout(() => { video.pause(); }, 100) }
});
监听微信后退事件 window.addEventListener("popstate", function(e) { // _this.$router.go(0) }, false);
···