一、前言

此教程适用自行开发网页、博客,以及有自定义aplayer需求的群体

比如说aplayer播放器对接alist | butlanys的博客播放等 (此文章正在写,稍安毋操)

二、准备

下载css、js到自己的网站目录下

地址:APlayer/dist at master · DIYgod/APlayer

致使用hexo butterfly主题的站长们,如果已在博客中使用aplayer需要在配置文件中把aplayerInject里enable值改为false

引入

这里以hexo butterfly为例

在_config.butterfly.yml文件的inject—head中加入

1
<link rel="stylesheet" href="/pluginsSrc/aplayer/dist/APlayer.min.css">

请将路径改为你自己的路径

在bottom中加入

1
<script src="/pluginsSrc/aplayer/dist/APlayer.min.js"></script>

调用

新建一个js文件

并参照官方文档进行修改:首页 - APlayer

引入自定义的配置文件

回到_config.butterfly.yml中,在bottom字段添加

1
2
<div id="aplayer"></div>
<script src="自定义的js文件名.js"></script>

完成

接下来就可以刷新你的网页,查看是否出现aplayer播放器

后续美化

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* Aplayer日间模式调整 */
/* 背景色 */
.aplayer {
background: rgba(255, 255, 255, 0.6) !important;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.07), 0 1px 5px 0 rgba(0, 0, 0, 0.1);
position: relative;
}

.aplayer.aplayer-fixed .aplayer-lrc:after,
.aplayer.aplayer-fixed .aplayer-lrc:before {
display: none;
}

.aplayer.aplayer.aplayer-fixed .aplayer-body {
background: rgba(255, 255, 255, 0.6) !important;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.07), 0 1px 5px 0 rgba(0, 0, 0, 0.1);
position: fixed;
}

/* 滚动条 */
.aplayer .aplayer-list ol::-webkit-scrollbar {
width: 5px;
}

.aplayer .aplayer-list ol::-webkit-scrollbar-thumb {
border-radius: 3px;
background-color: var(--theme-color) !important;
}

.aplayer .aplayer-list ol::-webkit-scrollbar-thumb:hover {
background-color: var(--theme-color) !important;
}

/* 圆角 */
.aplayer.aplayer-fixed .aplayer-list {
border-radius: 6px 6px 0 0 !important;
}

.aplayer.aplayer-fixed .aplayer-miniswitcher {
border-radius: 0 6px 6px 0 !important;
}

.aplayer.aplayer-fixed.aplayer-narrow .aplayer-body {
transition: 0.28s !important;
border-radius: 6px !important;
}

/* 选中与播放中歌曲激活颜色 */
.aplayer .aplayer-list ol li:hover {
background: var(--theme-color) !important;
}

.aplayer .aplayer-list ol li.aplayer-list-light {
background: var(--theme-color) !important;
}

/* 歌词 */
.aplayer-lrc p {
color: #ffffff !important;
text-shadow: #000000 1px 0 0, #000000 0 1px 0, #000000 -1px 0 0, #000000
0 -1px 0 !important;
}

/* Aplayer黑暗模式 */
[data-theme="dark"] .aplayer {
background: rgba(22, 22, 22, 0.6) !important;
color: rgb(255, 255, 255);
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.07), 0 1px 5px 0 rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .aplayer.aplayer-fixed .aplayer-body {
background: rgba(22, 22, 22, 0.6) !important;
color: rgb(255, 255, 255);
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.07), 0 1px 5px 0 rgba(0, 0, 0, 0.1);
}

[data-theme="dark"]
.aplayer
.aplayer-info
.aplayer-controller
.aplayer-time
path {
fill: #d4d4d4;
}

[data-theme="dark"] .aplayer .aplayer-list ol li:hover {
background: var(--theme-color) !important;
}

[data-theme="dark"] .aplayer .aplayer-list ol li.aplayer-list-light {
background: var(--theme-color) !important;
}

[data-theme="dark"] .aplayer .aplayer-info .aplayer-controller .aplayer-time {
color: #d4d4d4;
}

[data-theme="dark"] .aplayer .aplayer-list ol li .aplayer-list-index {
color: #d4d4d4;
}

[data-theme="dark"] .aplayer .aplayer-list ol li .aplayer-list-author {
color: #d4d4d4;
}

[data-theme="dark"] .aplayer.aplayer-fixed .aplayer-miniswitcher {
background: rgba(22, 22, 22, 0.6);
}