考完了2门考试,终于有点时间了,嘿嘿……参考了SaBlog BBS里Tension的添加mp3标记的方法,改成了custom标记,可以自动识别播放mp3, swf, flv, wmv, mpg文件,虽然不是很完善,不过先用着好了,等到什么时候不懒了,再把播放rm和rmvb的功能也加进去,嘿嘿……
2007.7.5 新增了wma播放功能,不过因为那个flash播放器不支持wma,所以只能用windows media player来实现了,什么时候再去找找可以支持wma的播放器好了……
安装方法:
1. 下载压缩包mediaplayer,在你的Blog根目录下建立一个mediaplayer的文件夹,把压缩包里面的文件解压到这个目录中
mediaplayer.rar (70)
2. 在./template/你用的模版的目录/style.css里面添加
- .customfile {
- padding: 5px;
- background: #333333;
- font: 12px Verdana, Tahoma, sans-serif;
- border: 1px dotted #777;
- }
3. 在global.php文件中查找
- // 获取页面调试信息
在其上面添加
- function makecustomfile($id) {
- $pt = explode(‘.’,$id);
- $p = count($pt);
- if($p) {
- $ret = strtoupper($pt[($p-1)]);
- if($ret == ‘MP3′) $code = ‘<div class="customfile">’.$ret.‘音乐文件:<br><embed src="./mediaplayer/mediaplayer.swf?file=’.$id.‘&width=300&allowfullscreen=true&displayheight=0&height=20&frontcolor=0×333333&lightcolor=0x43B300&overstretch=true" width="300" height="18" scale="ShowAll" menu="menu" wmode="Window" quality="1" type="application/x-shockwave-flash"></embed><br>下载该附件:<a href="’.$id.‘">’.$id.‘</a></div>’;
- else if($ret == ‘SWF’ or $ret == ‘FLV’) $code = ‘<div class="customfile">Flash视频:<br><embed src="/mediaplayer/mediaplayer.swf?file=’.$id.‘&height=300&width=400&autostart=false" width="400" height="300" scale="ShowAll" menu="menu" wmode="Window" quality="1" type="application/x-shockwave-flash"></embed><br>下载该附件:<a href="’.$id.‘">’.$id.‘</a></div>’;
- else if($ret == ‘WMV’ or $ret == ‘MPG’ or $ret == ‘AVI’) $code = ‘<div class="customfile">’.$ret.‘视频:<br><object height="300" width="350" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" align="center" border="0"><param name="AutoStart" value="0"><param name="Balance" value="0"><param name="enabled" value="-1"><param name="EnableContextMenu" value="-1"><param name="url" value="’.$id.‘"><param name="PlayCount" value="1"><param name="rate" value="1"><param name="currentPosition" value="0"><param name="currentMarker" value="0"><param name="defaultFrame" value=""><param name="invokeURLs" value="0"><param name="baseURL" value=""><param name="stretchToFit" value="0"><param name="volume" value="100"><param name="mute" value="0"><param name="uiMode" value="full"><param name="windowlessVideo" value="0"><param name="fullScreen" value="0"><param name="enableErrorDialogs" value="-1"><param name="SAMIStyle" value><param name="SAMILang" value><param name="SAMIFilename" value><param name="captioningID" value></object><br>下载该附件:<a target="_blank" href="’.$id.‘">’.$id.‘</a></div>’;
- else if($ret == ‘WMA’) $code = ‘<div class="customfile">’.$ret.‘音乐文件:<br><object height="64" width="350" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" align="center" border="0"><param name="AutoStart" value="0"><param name="Balance" value="0"><param name="enabled" value="-1"><param name="EnableContextMenu" value="-1"><param name="url" value="’.$id.‘"><param name="PlayCount" value="1"><param name="rate" value="1"><param name="currentPosition" value="0"><param name="currentMarker" value="0"><param name="defaultFrame" value=""><param name="invokeURLs" value="0"><param name="baseURL" value=""><param name="stretchToFit" value="0"><param name="volume" value="100"><param name="mute" value="0"><param name="uiMode" value="full"><param name="windowlessVideo" value="-1"><param name="fullScreen" value="0"><param name="enableErrorDialogs" value="-1"><param name="SAMIStyle" value><param name="SAMILang" value><param name="SAMIFilename" value><param name="captioningID" value></object><br>下载该附件:<a target="_blank" href="’.$id.‘">’.$id.‘</a></div>’;
- else if($ret == ‘REG’) $code = ‘<div class="customfile">注册表文件:<br>下载该附件:<a target="_blank" href="’.$id.‘">’.$id.‘</a></div>’;
- else if($ret == ‘ZIP’ or $ret == ‘RAR’) $code = ‘<div class="customfile">’.$ret.‘压缩包:<br>下载该附件:<a target="_blank" href="’.$id.‘">’.$id.‘</a></div>’;
- else if($ret == ‘EXE’ or $ret == ‘COM’) $code = ‘<div class="customfile">应用程序:<br>下载该附件:<a target="_blank" href="’.$id.‘">’.$id.‘</a></div>’;
- else $code = ‘<div class="customfile">’.$ret.‘文件:<br>下载该附件:<a target="_blank" href="’.$id.‘">’.$id.‘</a></div>’;
- } else {
- $code = ‘<div class="customfile">未知文件:<br>下载该附件:<a target="_blank" href="’.$id.‘">’.$id.‘</a></div>’;
- }
- return $code;
- }
4. 在index.php中查找
- //处理PHP高亮
- $article['content'] = preg_replace("/\s*\[php\](.+?)\[\/php\]\s*/ies", "phphighlite(‘\\1′)", $article['content']);
在下面添加
- //处理自定义文件
- $article['content'] = preg_replace("/\s*\[custom\](.+?)\[\/custom\]\s*/ies", "makecustomfile(‘\\1′)", $article['content']);
这里有2处,别少加了,不然进入文档之后就看不到效果了……
5.安装完成,看看效果吧……嘿嘿……
先来做做测试,放2个文件上来……
Black Box Recorder – Seasons In The Sun
black_box_recorder_seasons_in_the_sun.wma (70)
Zack Kim – Supermario Theme 2 Guitars
supermario_2_guitars.flv (60)
Radiohead – Paranoid Android
radiohead.-.[paranoid.android].mv.mpg (72)