본문 바로가기

컴터/html5

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

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
/*
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