layar sinema layar sinema - 1 year ago 188
jQuery Question

Jquery - Video JS error event GET/POST

First I'm using html5 video to embed my video, everything works fine when I handle error if video cannot played with this :

$('video source').last().on('error', function() {
alert('error play movie');

but on Video JS is not working at all,
The working on video JS is event on play like this :

var myPlayer = videojs('myvideo');
myPlayer.on("play", function(){
alert('play movie');

So, what event for error on video JS? Thanks anyway.
Im trying to put my GET function to error event VIDEO JS

$.get("<?= $host; ?>play.php?token=test");

Answer Source

You could add an handler on the error event fired by the player like this:

var myPlayer = videojs('myvideo').on('error', function() {
    console.log('The following error occurred:', this.error());

I don't know if you need the details of the error but note that:

  • the details of the error are not passed alongs with the event (so no param in the handler function)
  • you must use this.error() to get error details as described in the documentation
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download