1

当视频全屏播放并且用户擦洗到另一个视频位置时,是否有任何方法可以绑定并检测搜索和搜索事件。

在桌面上 Safari 的嵌入式视频标签中工作正常。谢谢!

4

1 回答 1

0

我使用了小的 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 片段并监听更新。How to get callbacks in Obj-C from JS see
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

于 2015-09-16T11:59:56.583 回答