Embed APlayer(https://github.com/DIYgod/APlayer) in Hexo posts/pages.
npm install --save hexo-tag-aplayer
{% aplayer title author url [picture_url, narrow, autoplay, width:xxx, lrc:xxx] %}
title
: music titleauthor
: music authorurl
: music file urlpicture_url
: optional, music picture urlnarrow
: optional, narrow styleautoplay
: optional, autoplay music, not supported by mobile browserswidth:xxx
: optional, prefixwidth:
, player's width (default: 100%)lrc:xxx
: optional, prefixlrc:
, LRC file url
With post asset folders enabled, you can easily place your image, music and LRC file into asset folder, and reference them like:
{% aplayer "Caffeine" "Jeff Williams" "caffeine.mp3" "picture.jpg" "lrc:caffeine.txt" %}
Besides 'lrc' option, you can use aplayerlrc
which has end tag to show lyrics.
{% aplayerlrc "title" "author" "url" "autoplay" %}
[00:00.00]lrc here
{% endaplayerlrc %}
{% aplayerlist %}
{
"narrow": false, // Optional, narrow style
"autoplay": true, // Optional, autoplay song(s), not supported by mobile browsers
"mode": "random", // Optional, play mode, can be `random` `single` `circulation`(loop) `order`(no loop), default: `circulation`
"showlrc": 3, // Optional, show lrc, can be 1, 2, 3
"mutex": true, // Optional, pause other players when this player playing
"theme": "#e6d0b2", // Optional, theme color, default: #b7daff
"preload": "metadata", // Optional, the way to load music, can be 'none' 'metadata' 'auto', default: 'auto'
"listmaxheight": "513px", // Optional, max height of play list
"music": [
{
"title": "CoCo",
"author": "Jeff Williams",
"url": "caffeine.mp3",
"pic": "caffeine.jpeg",
"lrc": "caffeine.txt"
},
{
"title": "アイロニ",
"author": "鹿乃",
"url": "irony.mp3",
"pic": "irony.jpg"
}
]
}
{% endaplayerlist %}
Hexo has an issue that cannot use space within tag arguments.
If you encounter this problem, install the latest (beta) version, and wrap the arguments within a string literal, for example:
{% aplayer "Caffeine" "Jeff Williams" "caffeine.mp3" "autoplay" "width:70%" "lrc:caffeine.txt" %}
You can modify variables scriptDir
(default: "/assets/js/" ) in index.js
according to your blog's directory structure.
MIT