贝塔罗拉

再来折腾一款在线音乐播放器

时间: 2010-04-10 / 分类: wordpress / 11个评论 发表评论

如果你不了解Wordpress段代码,建议先看一下我之前的文章《wordpress段代码应用实例》

首先,修改主题CSS文件,添加如下代码

1
.audio { border:1px solid #fff; width:230px; background:#fff; } .audioLeft { width:207px; margin:5px; padding:5px; border:1px solid #eee; }

然后,修改主题functions.php文件,添加如下代码

1
2
3
4
5
6
7
8
9
function mp3player($atts, $content=null){
	extract(shortcode_atts(array("auto"=>'0'),$atts));	
return <<<HTML
    <html>
    <div class='audio'><div class='audioLeft'><embed type="application/x-shockwave-flash" src="http://p.juv.im/swf/audio_player.swf?audio_file={$content}&amp;color=84cfe7" height="35" width="200" quality="best"></embed></div></div>
    </html>
HTML;
}
add_shortcode('mp3','mp3player');

最后,使用方法如下

1
[mp3]your mp3 url[/mp3]

如果有兴趣玩玩的同学,请把代码中的播放器地址换为自己的~

预览:http://juv.im/blog-or-not

本文链接: http://www.betarola.com/articles/another-mp3-player.html 转载请注明出处!