html5 비디오 코덱 지원 여부 스크립트

컴터/html5 2010. 8. 15. 19:34
/*
mpeg4 : canPlayType('video/mp4; codecs="mp4v.20.8"')
h264 : canPlayType('video/mp4; codecs="avc1.42E01E"')
webm : canPlayType('video/webm; codecs="vp8"')
ogg : canPlayType('video/ogg; codecs="theora"')

리턴값이 probably, maybe -> 둘 중 하나면 지원한다
*/

function supportsH264Ogg() {//h264 나 theora 지원여부 체크
var obj = document.querySelector("#video");
var ogg = obj.canPlayType('video/ogg; codecs="theora"');
var h264 = obj.canPlayType('video/mp4; codecs="avc1.42E01E"');
var oggSup = false;
var h264Sup = false;

if(ogg=='probably' || ogg=='maybe'){
oggSup = true;
}

if(h264=='probably' || h264=='maybe'){
h264Sup = true;
}

if(h264Sup==true || oggSup==true){
return true;
}else{
return false;
}
}

function notSupport(v){
if(supportsH264Ogg()==false){
alert('둘다 지원안함');
}
			}
 
$(function(){
notSupport('V000449207');
});



참고 : http://diveintohtml5.org/detect.html


Trackbacks 1 : Comments 0

Write a comment