2012-06-12 18 views
5

का उपयोग कर मैं एक वीडियो टैग का उपयोग और बाँध का उपयोग कर इसे बाध्यकारी या .इसके रहते दोनों ही मामलों में यह .Below काम नहीं कर रहा हूँ के लिए बाध्य करने में असमर्थ मेरी कोड बजे कुछ गलत और उसे पकड़ने के लिए सक्षम नहीं कर रहा हो सकता है।वीडियो घटनाओं Jquery

  <video width="videoWidth" 
      height="videoHeight" 
      poster="../Poster/poster.png" 
      id="videoId" 
      controls="controls" 
      muted="true"  
      seeking="true" 
      paused="true" > 

      <source src="../video/trailer.mp4" type="video/mp4"/>    
      <source src="../video/trailer.ogv" type="video/ogv"/> 
      <source src="../video/trailer.webm" type="video/webm"/> 
       Your browser does not support the video tag. 
      </video> 

यहाँ जे एस फ़ाइल घटनाओं बंधन के लिए शामिल है।

$("#videoId").bind('ended',function() { 
      alert("Entered"); 
     }); 

अद्यतन

मैं पिछले जे एस और अब मैं त्रुटि इवेंट पर stucked सभी वीडियो Events.Now के लिए अपने काम की जहां घटना घटना के आधार पर सक्रिय कर देगा अद्यतन करने रहा हो code.May जबकि लेखन मैं गलत हूँ कोड लेकिन त्रुटि घटना नहीं working.Below मेरी जे एस

$(document).ready(function(){ 
     $("#videoId").bind('play',function() { 
      alert("Play"); 
     }); 

     $("#videoId").bind('canplay',function() { 
      alert("Can Play"); 
     }); 

     $("#videoId").bind('empited',function() { 
      alert("Empited"); 
     }); 

     $("#videoId").bind('ended',function() { 
      alert("Ended"); 
     }); 

     $("#videoId").bind('loadstart',function() { 
      alert("Load Start"); 
     }); 

     $("#videoId").bind('pause',function() { 
      alert("Pause"); 
     }); 

     $("#videoId").bind('playing',function() { 
      alert("Playing"); 
     }); 

     $("#videoId").bind('progress',function() { 
      alert("Progress"); 
     }); 

     $("#videoId").bind('suspend',function() { 
      alert("Suspend"); 
     }); 

     $("#videoId").bind('volumechange',function() { 
      alert("Volume"); 
     }); 

     $("#videoId").bind('waiting',function() { 
      alert("waiting"); 
     }); 
     $("#videoId").bind('error',function(e,ui) { 
      switch (e.target.error.code) { 
      case e.target.error.MEDIA_ERR_ABORTED: 
       alert('You aborted the video playback.'); 
       break; 
      case e.target.error.MEDIA_ERR_NETWORK: 
       alert('A network error caused the video download to fail part-way.'); 
       break; 
      case e.target.error.MEDIA_ERR_DECODE: 
       alert('The video playback was aborted due to a corruption problem or because the video used features your browser did not support.'); 
       break; 
      case e.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED: 
       alert('The video could not be loaded, either because the server or network failed or because the format is not supported.'); 
       break; 
      default: 
       alert('An unknown error occurred.'); 
       break; 
      } 
      //alert("Error Code : "+event.target.error.code); 
     }); 

     }); 

कंसोल में 'जाओ' हो रही है है।

+0

यही काम करना चाहिए पर त्रुटि वस्तु में सभी वस्तुओं को सूचित करेंगे। क्या आपका कोड एक डोम तैयार इवेंट हैंडलर में चल रहा है? –

+0

कंसोल में कोई त्रुटि? – Neil

+0

हां इसके काम डोम तैयार हैंडलर में है। –

उत्तर

1

उपयोग करके देखें:।

$ ("# VIDEOID") बाँध ('त्रुटि', समारोह (ई, यूआई) {... यहाँ समारोह ...}, सच);

यह कम से कम अपने त्रुटि हैंडलर फेंक चाहिए, लेकिन त्रुटि शायद उच्च propogation की है। अगला कदम वास्तविक त्रुटि को इंगित करेगा। इस कड़ी की मदद करनी चाहिए:

https://developer.mozilla.org/en-US/docs/Web/API/EventTarget.addEventListener

3

इस वीडियो तत्व

$("video").on("error", function(err) { 
    for (var i in err.currentTarget.error) { 
     alert(i + ": " + err.currentTarget.error[i]); 
    } 
});