方法一:
1.添加:把以下代码复制至functions.php(注意在php循环内),然后下载mp3player.swf并放至你所用的主题的目录里,MP3默认不自动播放(www.rswebun.com)
1
2 3 4 5 |
function mp3player($atts, $content=null){
extract(shortcode_atts(array("auto"=>'0'),$atts)); return '<embed src="'.get_bloginfo("template_url").'/mp3player.swf?url='.$content.'&autoplay='.$auto.'" type="application/x-shockwave-flash" wmode="transparent" allowscriptaccess="always" width="400" height="30"/>'; } add_shortcode('mp3','mp3player'); |
2.使用:撰写文章时在“HTML(文本)模式”下插入以下格式代码即可
1
|
[mp3 auto="0" vol="60" ]MP3文件URL[/mp3]
|
上边的代码:auto:是否自动播放(0 or 1);vol:音量(1~100)
效果:
方法二:
1.把以下代码复制至functions.php(注意在php循环内),然后下载player.swf为了不和上边的冲突,这里用music短代码。
1
2 3 4 5 6 |
/**添加 flash player */
function myplayer($atts, $content=null){ extract(shortcode_atts(array("auto"=>'no',"loop"=>'no'),$atts)); return '<embed src="'.get_bloginfo("template_url").'/player.swf?soundFile='.$content.'&bg=0xeeeeee&leftbg=0x357dce&lefticon=0xFFFFFF&rightbg=0xf06a51&rightbghover=0xaf2910&righticon=0xFFFFFF&righticonhover=0xffffff&text=0x666666&slider=0x666666&track=0xFFFFFF&border=0x666666&loader=0x9FFFB8&loop='.$loop.'&autostart='.$auto.'" type="application/x-shockwave-flash" wmode="transparent" allowscriptaccess="always" width="290" height="30"/>'; } add_shortcode('music','myplayer'); |
2.使用:撰写文章时在“HTML(文本)模式”下插入以下格式代码即可
1
|
[music]MP3文件URL[/music]
|
该播放器可以自己设置颜色神马的,具体在上边修改颜色代码部分即可,可以自己折腾玩一下。效果如下:
<embed src="http://www.zhbk.name/wp-content/themes/weisaysimple/player.swf?soundFile=http://stream12.qqmusic.qq.com/31438749.mp3&bg=0xeeeeee&leftbg=0x357dce&lefticon=0xFFFFFF&rightbg=0xf06a51&rightbghover=0xaf2910&righticon=0xFFFFFF&righticonhover=0xffffff&text=0x666666&slider=0x666666&track=0xFFFFFF&border=0x666666&loader=0x9FFFB8&loop=no&autostart=no" type="application/x-shockwave-flash" wmode="transparent" allowscriptaccess="always" width="290" height="30">
转自子皓博客