Archive / Javascript / MediaEmbed

아직 완성 안됐음. WMV만 플레이 됨. 사파리 지원 안함

HTML

<div>
	<a href="iig_main_x/img/iigEnglishClass.wmv" 
	onclick="mediaEmbed(this); return false;">
		<img src="iig_main_x/img/iigEnglishClass.jpg" alt="">
	</a>
</div>

JS

function mediaEmbed(el) {
	var data = el.href;

	var exploded = data.split(".");
	var ext = exploded[exploded.length - 1];
	var type, clsid;
	if (ext == "wmv") {
		//type = "video/x-ms-wmv";
		type = "application/x-mplayer2";
		clsid = "CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6";	// WMP
	}

	var img = el.getElementsByTagName("img").item(0);
	var width = img.offsetWidth;
	var height = img.offsetHeight;

	var html;
	if(window.ActiveXObject) {
		html = '<object classid="' + clsid;
	} else {
		html = '<object type="' + type + '" data="' + data;
	}
	html += '" width="' + width + '" height="' + height + '">';
	html += '<param name="URL" value="' + data + '" />';
	html += '<param name="AutoStart" value="true" />';
	html += '<param name="uiMode" value="mini" />';
	html += '</object>';

	el.parentNode.innerHTML = html;
}

참고용 (IE 전용)

function embedQuickTime(data, width, height, container) {
	html = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="' + width + '" height="' + height + '">';
	html += '<param name="src" value="' + data + '" />';
	html += '<param name="autoplay" value="true" />';
	html += '<param name="resize" value="true" />';
	html += '</object>';

	container.innerHTML = html;
}
function embedWMP(data, width, height, container, play) {
	if (play == "stop")
		auto_start = "false";
	else
		auto_start = "true";
	html = '<object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="' + width + '" height="' + height + '">';
	html += '<param name="URL" value="' + data + '" />';
	html += '<param name="AutoStart" value="' + auto_start + '" />';
	html += '<param name="uiMode" value="mini" />';
	html += '</object>';

	container.innerHTML = html;
}
Page last modified on May 27, 2009, at 09:06 AM

Powered by PmWiki