2013-08-29 71 views

回答

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代碼並監聽更新。如何從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