๐ป Programming/Javascript
[Javascript / ์๋ฐ์คํฌ๋ฆฝํธ] ๊ฐ์ข #20 - Multimedia ( ๋ฉํฐ๋ฏธ๋์ด, ์์ , ๋์์ )
JavaScript์ navigator ๊ฐ์ฒด๋ plugins ๊ฐ์ฒด๋ฅผ ์์์ผ๋ก ๊ฐ๊ณ ์์ต๋๋ค. ์ด ๊ฐ์ฒด๋ ๋ฐฐ์ด์ ๊ตฌ์กฐ๋ฅผ ๊ฐ์ง๊ณ ์๋๋ฐ ๋ธ๋ผ์ฐ์ ์ ์ค์น๋์ด์๋ ํ๋ฌ๊ทธ์ธ๋ง๋ค ๊ฐ๊ฐ ํ๋์ ์ํธ๋ฆฌ ํฌ์ธํธ๋ฅผ ๊ฐ์ง๊ณ ์์ต๋๋ค. navigator.plugins ๊ฐ์ฒด๋ Netscape, Firefox ๊ทธ๋ฆฌ๊ณ Mozilla ์์๋ง ์ง์ํฉ๋๋ค.
์๋ ์์ ๋ ๋ธ๋ผ์ฐ์ ์ ์ค์น๋์ด์๋ ํ๋ฌ๊ทธ์ธ๋ค์ ๋ชฉ๋ก์ ๋ชจ๋ ์ถ๋ ฅํ๋ ์์ ์ ๋๋ค.
<html>
<head>
<title>List of Plug-Ins</title>
</head>
<body>
<table border="1">
<tr>
<th>Plug-in Name</th>
<th>Filename</th>
<th>Description</th>
</tr>
<script language="JavaScript" type="text/javascript">
for (i=0; i<navigator.plugins.length; i++) {
document.write("<tr><td>");
document.write(navigator.plugins[i].name);
document.write("</td><td>");
document.write(navigator.plugins[i].filename);
document.write("</td><td>");
document.write(navigator.plugins[i].description);
document.write("</td></tr>");
}
</script>
</table>
</body>
</html>
|
ํ๋ฌ๊ทธ์ธ ๊ฒ์ฌ
๊ฐ ํ๋ฌ๊ทธ์ธ์ ๋ฐฐ์ด์ ํ๋์ ์ํธ๋ฆฌ๋ฅผ ๊ฐ์ง๊ณ ์์ต๋๋ค. ๊ฐ ์ํธ๋ฆฌ๋ ๋ค์๊ณผ ๊ฐ์ ์์ฑ์ ๊ฐ์ง๊ณ ์์ต๋๋ค.
name - is the name of the plug-in.
filename - is the executable file that was loaded to install the plug-in.
description - is a description of the plug-in, supplied by the developer.
mimeTypes - is an array with one entry for each MIME type supported by the plug-in.
์๋ ์์ ๋ฅผ ํ๋ฒ ๋ณด์ค๊น์?
<html>
<head>
<title>Using Plug-Ins</title>
</head>
<body>
<script language="JavaScript" type="text/javascript">
media = navigator.mimeTypes["video/quicktime"];
if (media){
document.write("<embed src='quick.mov' height=100 width=100>");
}
else{
document.write("<img src='quick.gif' height=100 width=100>");
}
</script>
</body>
</html>
|
video/quiktime ํ๋ฌ๊ทธ์ธ์ด ์ค์น๋์ด์๋์ง๋ฅผ ๊ฒ์ฌํ ๋ค, ์ค์น๊ฐ ๋์ด์์ผ๋ฉด quick.mov๋ฅผ embedํ์ฌ ํ๋ ์ด ์ํฌ ์ ์๋๋ก ํ์๊ณ ์ค์น๊ฐ ๋์ด์์ง ์์ผ๋ฉด quick.gif๋ผ๋ ์ด๋ฏธ์ง ํ์ผ์ ๋ณด์ฌ์ฃผ๋๋ก ํ๋ ์์ ์ ๋๋ค.
๋ฉํฐ๋ฏธ๋์ด ๋ค๋ฃจ๊ธฐ
๋๋ถ๋ถ์ ๋ธ๋ผ์ฐ์ ์์ ๋์ํ๋ ์์ ๋ฅผ ํ๋ฒ ๋ณด๋๋ก ํ ๊น์???
<html>
<head>
<title>Using Embeded Object</title>
<script type="text/javascript">
<!--
function play()
{
if (!document.demo.IsPlaying()){
document.demo.Play();
}
}
function stop()
{
if (document.demo.IsPlaying()){
document.demo.StopPlay();
}
}
function rewind()
{
if (document.demo.IsPlaying()){
document.demo.StopPlay();
}
document.demo.Rewind();
}
//-->
</script>
</head>
<body>
<embed id="demo" name="demo"
src="http://www.amrood.com/games/kumite.swf"
width="318" height="300" play="false" loop="false"
pluginspage="http://www.macromedia.com/go/getflashplayer"
swliveconnect="true">
</embed>
<form name="form" id="form" action="#" method="get">
<input type="button" value="Start" onclick="play();" />
<input type="button" value="Stop" onclick="stop();" />
<input type="button" value="Rewind" onclick="rewind();" />
</form>
</body>
</html>
|
์ ์์ ๋
http://www.amrood.com/games/kumite.swf ํ์ผ์ ๋ก๋ฉํด์ ํ๋ฉด์ ๋ณด์ฌ์ฃผ๋๋ฐ,
Start๋ฒํผ์ ๋๋ฅด๋ฉด kumite.swfํ์ผ์ด ์คํ์ด ๋๋ฉด์ ํ๋์ฌ๊ฒ์์ด ์งํ์ด ๋์ผ ํ๋๋ฐ,
์ ๋ธ๋ผ์ฐ์ ์์๋ ๋์์ ์ํ๋ค์? ใ ใ ์ ์๋๋์ง ์ด์ ๋ฅผ ๋ฐํ์ ์ฌ๋ฆฌ๋๋ก ํ๊ฒ ์ต๋๋ค. ใ ใ
(embedํ๊ทธ์ play์ต์ ์ true๋ก ์ฃผ๋ฉด ์คํ์ด ๋๋๋ฐ ์๋ง ์๋ฐ์คํฌ๋ฆฝํธ์์ ์คํํ๋ ๋ฐฉ๋ฒ์ด
์์ ์ ๋์์๋ ๊ฒ๊ณผ ๋ฌ๋ผ์ง๊ฒ์ด ์๋๊ฐ ์ถ๋ค์.)
--------------------------
swfํ์ผ ์คํ์ํค๋ ๊ฑฐ ํ์ฐธ ์ฐพ์๋ดค๋๋ฐ๋ ์ ๋ชจ๋ฅด๊ฒ ๋ค์. UI์ชฝ์ ์ญ์ ํ๋ค๊ตฐ์...์ํ....
์์๋ ๋ถ ๊ณ์๋ฉด ๋๊ธ์ข ๋จ๊ฒจ์ฃผ์ธ์ ใ ใ
Reference : http://www.tutorialspoint.com/javascript/javascript_multimedia.htm