Re: wmv ใน wordpress 2 (02 มิ.ย. 2006, 10:47 น.) |
|
ทำได้แล้วล่ะ
สร้างไฟล์ popup.php
จากโค้ดนี้
<?php
if ($_GET['url'])
$url = $_GET['url'];
if ($_GET['size'])
$size = $_GET['size'];
else
$size = 320;
$width = $size;
$height = round(($size/4)*3);
// get file extension
$url_array = split("/", $url);
$filename = $url_array[sizeof($url_array)-1];
$file_array = explode(".", $filename);
$file_ext = strtolower($file_array[sizeof($file_array)-1]);
?>
<html>
<head>
<title>Video</title>
<style>
body {
background-color: #000000;
text-align: center;
margin: 0px;
padding: 0px;
color:#CCCCCC;
font-size:12px;
font-family: Arial, Verdana, Helvetica, sans-serif;
}
a {
font-size:12px;
color:#CCCCCC;
text-decoration:none;
}
a:hover {
text-decoration: underline;
}
#video {
height: 100%;
margin: auto;
padding: 15px; auto;
}
</style>
</head>
<body>
<div id="video">
<?php
// print HTML embed code for each file type
switch ($file_ext) {
case "mov":
case "mp4":
case "qt":
case "smil":
case "3gp":
case "mpg":
case "mpeg":
case "m4v":
case "mp3":
case "wav":
case "aiff":
case "aac":
case "m4b":
$height = $height + 16;
$html =<<<END
<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
width="$width" height="$height" codebase="http://www.apple.com/qtactivex/qtplugin.cab">
<param name="src" value="$url">
<param name="autoplay" value="true">
<param name="controller" value="true">
<param name="scale" value="aspect">
<embed src="$url"
width="$width" height="$height"
autoplay="true"
controller="true"
scale="aspect"
pluginspace="http://www.apple.com/quicktime/download/">
</embed>
</object>
END;
break;
case "wmv":
case "avi":
$height = $height + 46;
$html =<<<END
<object id="MediaPlayer1"
width="$width" height="$height"
classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112"
standby="Loading..."
type="application/x-mplayer2">
<param name="fileName" value="$url">
<param name="showControls" value="true">
<param name="showTracker" value="true">
<embed type="application/x-mplayer2" name="MediaPlayer1"
pluginspage = "http://www.microsoft.com/Windows/MediaPlayer/"
width="$width" height="$height"
showControls="true" showTracker="true"
src="$url">
</embed>
</object>
END;
break;
case "swf":
break;
case "flv":
break;
}
echo $html;
echo "<br/>";
/*
echo "Resize: <a href=\"" . $_SERVER['PHP_SELF'] . "?url=" . $url . "&size=320\">320x340</a> | <a href=\"" . $_SERVER['PHP_SELF'] . "?url=" . $url . "&size=640\">640x480</a></div>";
*/
?>
</div>
</body>
</html>
แล้วอัพขึ้น Server
ไฟล์ใน WP ใส่โค้ดดังนี้
<a href="URL your media" rel="enclosure" onclick="window.open('URL your popup.php?url='+this.href,'video','width=340,height=310,top=20,left=20,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=yes,left=0,top=0');return false" >ชื่อเพลงที่ต้องการแสดง</a>
ผลลัพธ์ที่ได้ ดังรูป
สามารถเข้าไปแก้ไขสี และ หน้าตา รวมทั้งเพิ่มนามสกุลของไฟล์ ที่อยากใส่ได้ตามใจชอบ