1.安装hexo-tag-aplayer插件
$ npm install --save hexo-tag-aplayer
2.使用
2.1 Aplayer播放器基本格式
在每篇文章即.md
文件中的正文中添加如下内容:
{% aplayer title author music-url [picture-url, lrc:lrc-url, width:xx%, autoplay, narrow] %}
但如果无法直接在标签参数中加入空格,则直接将参数用双引号括起来使用,如下:
{% aplayer "title" "author" "music-url" "picture-url" "lrc:lrc-url" "width:xx%" "autoplay" "narrow" %}
其中,{% aplayer %}
是必须写上的格式,其他标签参数具体如下:
title
:歌曲的标题(必选)author
:歌曲的作者(必选)music-url
:歌曲本体的URL地址(必选)picture-url
:歌曲封面的URL地址(可选)lrc-url
:歌词的URL地址(可选)width:xx%
:宽度(可选,默认100%)autoplay
:自动播放(可选,移动端暂不支持)narrow
:袖珍风格播放器(可选)
若在网站根目录下的config.yml
文件中将post_asset_folder
设为true
,即开启了Hexo的文章资源文件夹功能,则可以将歌曲本体、歌曲封面、歌词放入与文章同名的对应的资源文件夹中,然后直接引用,如下:
{% aplayer "Running In The Dark" "MONKEY MAJIK" "Running In The Dark.mp3" "Running In The Dark.jpg" "lrc:Running In The Dark.txt" %}
效果如下[1]:
除了单曲,还支持列表模式,具体可参照播放列表
2.2 MeingJS播放器
介绍:MetingJS是基于Meting API的APlayer衍生播放器
功能:将支持对于QQ音乐、网易云音乐、虾米、酷狗、百度等平台的音乐播放
①在网站根目录下的config.yml
文件中添加如下:
aplayer:
meting: true
②在每篇文章即.md
文件中的正文中添加如下内容:
{% meting "2068111443" "netease" "song" "theme:#7777" "mutex:true" "listmaxheight:340px" "preload:auto" %}
效果如下:
其中,{% meting %}
是必须写上的格式,其他标签参数具体如下:
2068111443
是歌曲ID(必选),如网易云音乐分享歌曲链接的时https://music.163.com/song?id=2068111443&userid=
中2068111443
就是该歌曲的IDnetease
是网易云音乐平台(必选),也可以换成其他音乐平台如:tencent
,kugou
,xiami
,baidu
等song
是歌曲的类型(必选),单曲是song
,歌单是playlist
(效果可以参考我的About),专辑是album
,还有search
和artist
theme:#7777
是播放器主题色(可选),具体喜欢的RGB颜色请自行查找并更改mutex:true
意思是选择true
时,如果同页面有其他aplayer播放,该播放器会暂停listmaxheight:340px
意思是播放列表的最大长度默认为340px
preload:auto
意思是音乐文件预载入模式为auto
,可以改为none
或metadata
更多标签参数请看选项列表
③非post(正文)页面使用问题
如果在非post(正文)页面中无法使用Aplayer播放器,可以试试在.md
文件添加{% aplayer %}
或{% meting %}
之前添加如下内容:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer@1.10/dist/APlayer.min.css">
<script src="https://cdn.jsdelivr.net/npm/aplayer@1.10/dist/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@1.2/dist/Meting.min.js"></script>
hexo-tag-aplayer官方中文文档:https://github.com/MoePlayer/hexo-tag-aplayer/blob/master/docs/README-zh_cn.md
参考文章:https://blog.csdn.net/hushhw/article/details/88092728
不知道是不是主题原因,我用F12查看发现我的歌曲本体和歌词都没成功上传,暂时没得到解决 ↩︎