今天有一个朋友向我要播放器,我就写了这个教程给他!
一、下载一个音乐播放器,并且上传到你的主题根目录下
我给大家准备好了,这个播放器功能很多的,能播放多首歌,大家自己发掘吧!
[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来设置是否循环循环播放。
成功的样式应该是这样的:
这就相当于一个短代码音乐播放器啦~~
往functions.php添加代码,添加完代码,网站就错误 💡
@吉他手 @吉他手 : 可能代码有些错误,你先别添加了,等我再检查检查更新一下这个博文,谢谢关注
一、下载一个音乐播放器,并且上传到你的主题根目录下
第一句就把弄蒙了??根目录如何看? 技术盲来说,我目前不知道我的服务器指向哪里?
😮 多谢博主指点,弹了一晚上吉他,刚看到,哈哈
@松禅 @松禅 : 不用谢啦,举手之劳,何足挂齿 😀
@松禅 @松禅: Make Me feel at home
!
睡觉咯、晚安
@花七七 @花七七 : 晚安
@花七七 @花七七 : 你的网站太坑啦,又打不开了 😥
页面的代码出格子了 😯
@愚蠢的凡人 @愚蠢的凡人 : 我知道啦,我的那个高亮插件不能在bae上使用,所以暂时用的“pre” 呵呵
@愚蠢的凡人 @愚蠢的凡人 : 呵呵,这个问题刚刚我解决啦~
谢谢指点,来学习学习