Created
August 4, 2012 00:08
-
-
Save wilmoore/3252894 to your computer and use it in GitHub Desktop.
HTML5 Video Playback Error Handling POC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p><video src="tgif.vid" autoplay controls onerror="failed(event)"></video></p> | |
<p><a href="tgif.vid">Download the video file</a>.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function failed(e) { | |
// video playback failed - show a message saying why | |
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; | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is absolutely beatiful!