function supports_video() {
return !!document.createElement('video').canPlayType;
}
/* Mac, iPhone 에서만 지원하는 유료 코덱
* MPEG-4 컨테이너의 H.264 베이스라인 비디오와 AAC LC 오디오 지원
* return string : "probably" - 지원, "maybe" - 아마도, "" - 미지원
*/
function supports_h264_baseline_video() {
if (!supports_video()) { return false; }
var v = document.createElement('video');
return v.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"');
}
/* firefox 와 같은 오픈소스 브라우저가 지원하는 코덱
* ogg 컨테이너와 Theora 비디오와 Vorbis 오디오를 지원
*/
function supports_ogg_theora_video() {
if (!supports_video()) { return false; }
var v = document.createElement('video');
return v.canPlayType('video/ogg; codecs="theora, vorbis"');
}
/* Chrome, firefox, Opera 와 같은 오픈소스 브라우저가 지원하는 오픈소스 코덱
* WebM 컨테이너와 vp8 비디오와 Vorbis 오디오를 지원
*/
function supports_webm_video() {
if (!supports_video()) { return false; }
var v = document.createElement('video');
return v.canPlayType('video/webm; codecs="vp8, vorbis"');
}
if (supports_h264_baseline_video() == 'probably') {
alert("html5 video H.264 supported");
} else {
alert("html5 video H.264 not supported");
}
if (supports_ogg_theora_video() == 'probably') {
alert("html5 video theora supported");
} else {
alert("html5 video theora not supported");
}
if (supports_webm_video() == 'probably') {
alert("html5 video vp8 supported");
} else {
alert("html5 video vp8 not supported");
}