移动Safari浏览器HTML5视频全屏检测寻求和寻求事件
问题描述:
有什么办法可以绑定到并检测查询和查询事件,而视频播放全屏和用户擦洗到另一个视频位置。移动Safari浏览器HTML5视频全屏检测寻求和寻求事件
在桌面上Safari浏览器中的嵌入式视频标签中正常工作。谢谢!
答
我已经使用小JS片段: var lastTimePosition = 0;
$("video").on("timeupdate", function(){
//Time difference between last event handled and current position
var diff = Math.abs(this.currentTime - lastTimePosition);
//If difference more that 1 second, handle event (on iOS Safari this event handles 3 times per second. You can increase this parameter to be sure it will handle only on manual seeking
if (diff > 1) {
window.location = "video://currentTime:" + this.currentTime;
console.log("Time:" + this.currentTime);
}
lastTimePosition = this.currentTime;
});
在您的UIWebView或WKWebView中添加此JS代码并监听更新。如何从JS中的OBJ-C回调见
的UIWebView:How to invoke Objective C method from Javascript and send back data to Javascript in iOS?
WKWebView:http://www.joshuakehn.com/2014/10/29/using-javascript-with-wkwebview-in-ios-8.html