Created
October 19, 2010 15:55
-
-
Save fillano/634427 to your computer and use it in GitHub Desktop.
play a m4v or ogg video in different browser and see the status of video object
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
<!DOCTYPE html> | |
<html lang="zh-TW"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf8"> | |
</head> | |
<body> | |
<video id="player" src="crockonjs-1.m4v" controls poster="vlcsnap-00001.png"></video> | |
<!--<video id="player" src="Apollo_15_liftoff_from_inside_LM.ogg" controls></video>--> | |
<div id="panel"></panel> | |
</body> | |
</html> | |
<script> | |
(function(window, undefined) { | |
var player = document.getElementById('player'), | |
map = ['error','src','currentSrc','poster','videoWidth','videoHeight','networkState','readyState','preload','buffered','played','seekable','seeking','currentTime','startTime','duration','paused','defaultPlaybackRate','playbackRate','ended','autoplay','loop','controls','volume','muted']; | |
alert(player.canPlayType('video/x-m4v')); | |
window.setInterval(function(){ | |
var str = ''; | |
for(var i=0, j=map.length; i<j; i++) { | |
if(window.console) console.log(map[i]+'-'+player[map[i]]); | |
if(undefined!==player[map[i]] && player[map[i]]!==null && player[map[i]].toString().indexOf('TimeRanges')>-1) { | |
if(player[map[i]].length > 0) { | |
str += map[i] + ' : ' + '<div style="border: dotted 1px #336699">\n'; | |
for(var m=0,n=player[map[i]].length; m<n; m++) { | |
str += 'timerange['+m+']: {start:'+player[map[i]].start(m) +',end:'+ player[map[i]].end(m)+'}<br>\n'; | |
} | |
str += '</div>'; | |
continue; | |
} | |
str += 'nothing<br>\n'; | |
continue; | |
} | |
if(undefined!==player[map[i]] && player[map[i]]!==null && player[map[i]].toString().indexOf('MediaError')>-1) { | |
str += 'ErrorCode : ' + player[map[i]].code + '<br>\n'; | |
} | |
str += map[i] + ' : ' + player[map[i]] + '<br>\n'; | |
} | |
document.getElementById('panel').innerHTML = str; | |
}, 1000); | |
})(window); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment