How do I debug my own video because at the moment no alert is appearing. I am using IE9 and the player is jwplayer. Am I missing something or have I put the javascript code for debugging in wrong place because I tried to put it below and above the jwplayer element. Am I suppose to see the alert when I click on play or is it suppose to appear straight away?
<div id="myElement">Loading the player...</div>
<?php echo 'This is the videoPath '.$dbVideoFile; ?>
<script type="text/javascript">
jwplayer("myElement").setup({
file: "<?php echo $dbVideoFile; ?>",
});
var myvid = document.getElementById('myElement');
if (myvid.error) {
switch (myvid.error.code) {
case MEDIA_ERR_ABORTED:
alert("You stopped the video.");
break;
case MEDIA_ERR_NETWORK:
alert("Network error - please try again later.");
break;
case MEDIA_ERR_DECODE:
alert("Video is broken..");
break;
case MEDIA_ERR_SRC_NOT_SUPPORTED:
alert("Sorry, your browser can't play this video.");
break;
}
}
</script>
First of all you’re trying to get error from div element instead of video, second thing you’re trying to do that instantly when code is loaded – jwplayer runs probably on page/document load or at least with some timeout and in that particular moment there is no player yet. You should attach callback function to onError jwplayer event and then try to find what is wrong. Also
MediaErrorcode constants are not defined in global scope, they are bound toMediaErrorobject, so you should use for exampleMediaError.MEDIA_ERR_ABORTEDinstead of justMEDIA_ERR_ABORTEDsee documentation for jwplayer events