2013-08-29 4 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; 
}); 

이 JS 스 니펫을 UIWebView 또는 WKWebView에 추가하고 업데이트를 수신합니다. 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