WeChat Share

给自己的博客添加音乐播放器

今天有一个朋友向我要播放器,我就写了这个教程给他!

一、下载一个音乐播放器,并且上传到你的主题根目录下

我给大家准备好了,这个播放器功能很多的,能播放多首歌,大家自己发掘吧!

[butdown href=”http://bcs.duapp.com/lovels/lscx_player.zip”]下载播放器[/butdown]

二、在你的主题functions.php中添加以下代码

[codee]//音乐播放器
function mp3player ( $atts , $content = null ) {
extract (shortcode_atts (array ( “auto ” => ‘0 ′ ) , $atts ) ) ;
return ‘<embed src=”‘ . get_bloginfo ( “template_url” ) . ‘ /lscx_player.swf?mp3=’ . $content . ‘&autoplay=’ . $auto . ‘” type=”application/x-shockwave-flash” wmode=”transparent” allowscriptaccess=”always” width=”108″ height=”34″></embed>’ ;
}
add_shortcode ( ‘mp3’ , ‘lscx_player’ ) ;[/codee]
(2)如果你想播放多首音乐,可添加以下代码
 [codee]//播放多首音乐
function musicplayer ( $atts , $content = null ) {
extract (shortcode_atts (array ( “auto ” => ‘0 ′ ) , $atts ) ) ;
return ‘<embed src=”‘ . get_bloginfo ( “template_url” ) . ‘ /lscx_player.swf” flashvars=”mp3=’ . $content . ‘&autoreplay=” type=”application/x-shockwave-flash” wmode=”transparent” width=”108″ height=”34″></embed> ‘ ;
}
add_shortcode ( ‘lscx_player’ , ‘lscx_player’ ) ;[/codee]

三、代码的使用:在编辑文章时加入以下代码即可。
播放一首音乐的话就使用这行代码
[music]完整的音乐文件地址[/music]
播放多首音乐的话就使用这行代码
[ music ] http :// lscx.org / 第一首 . mp3 |http :// xxx . com / 第二首 . mp3 [/ music ]
其中:titles来设置歌曲名;auto来设置自动播放;loop来设置是否循环循环播放。
成功的样式应该是这样的:
图片已归档
这就相当于一个短代码音乐播放器啦~~

« 上一篇 我去!这个说世界末日的神棍居然又中了?
下一篇 » 今天看到一个新闻令我非常气愤!

13 条评论

  • 吉
    吉他手 2013-02-19 17:08 回复

    往functions.php添加代码,添加完代码,网站就错误 💡

    • 露水晨曦
      露水晨曦 博主 2013-02-19 20:41 回复

      @吉他手 @吉他手 : 可能代码有些错误,你先别添加了,等我再检查检查更新一下这个博文,谢谢关注

  • 淮
    淮海巷 2013-01-24 21:48 回复

    一、下载一个音乐播放器,并且上传到你的主题根目录下
    第一句就把弄蒙了??根目录如何看? 技术盲来说,我目前不知道我的服务器指向哪里?

  • 松
    松禅 2012-12-10 23:58 回复

    😮 多谢博主指点,弹了一晚上吉他,刚看到,哈哈

    • 露水晨曦
      露水晨曦 博主 2012-12-11 00:28 回复

      @松禅 @松禅 : 不用谢啦,举手之劳,何足挂齿 😀

    • 露水晨曦
      露水晨曦 博主 2012-12-20 22:27 回复

      @松禅 @松禅: Make Me feel at home
      !

  • 花
    花七七 2012-12-10 23:31 回复

    睡觉咯、晚安

  • 愚
    愚蠢的凡人 2012-12-10 16:16 回复

    页面的代码出格子了 😯

  • i
    ixwebhosting 2012-12-10 09:34 回复

    谢谢指点,来学习学习

向右滑动滑块完成验证