【问题标题】:Mobile Safari HTML5 Video Fullscreen detect seeking and seeked eventsMobile Safari HTML5 Video Fullscreen 检测搜索和搜索事件
【发布时间】:2013-08-29 16:32:28
【问题描述】:

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

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

【问题讨论】:

    标签: mobile video safari fullscreen seek


    【解决方案1】:

    我用过小JS sn-p: 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 sn-p 并监听更新。如何从 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

    【讨论】:

      猜你喜欢
      • 2012-06-13
      • 2011-07-31
      • 2019-08-07
      • 1970-01-01
      • 1970-01-01
      • 2012-03-13
      • 1970-01-01
      • 1970-01-01
      • 2011-02-27
      相关资源
      最近更新 更多