簡體   English   中英

Javascript-如何檢查電影是否完成? 同時使用jQuery和其他第三方庫?

[英]Javascript - how do i check if the movie is finished? while using jQuery and other third party libraries?

我現在有一些第三方庫和使用Javascript的jQuery,我需要檢測是否正在播放任何視頻並以事件偵聽器結尾。

我嘗試了以下操作,但不起作用:

$(document).ready(function() {
    if(InitialiseDocReadyScripts()) {
        console.log('Initialised Document Ready Scripts Successfully');
    } else {
        console.log('Failed to Initialise Document Ready Scripts');
    }

  var play_video = document.getElementById('mediaplayer');
  play_video.onended = function(e) {
    console.log('>>> Playing finished: ', e);
  };

});

檢查當前播放時間是否==視頻的長度==

 play_video.onended = function(e) {
    if(this.currentTime == this.duration) {
        console.log('video end');
    }
 };

currentTimeduration是html5視頻的屬性: http : //www.w3schools.com/tags/ref_av_dom.asp

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM