File tree Expand file tree Collapse file tree 3 files changed +14
-7
lines changed Expand file tree Collapse file tree 3 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -206,12 +206,7 @@ class APlayer {
206
206
else {
207
207
this . template . pic . style . backgroundImage = '' ;
208
208
}
209
- if ( this . options . audio [ this . playIndex ] . theme ) {
210
- this . template . pic . style . backgroundColor = this . options . audio [ this . playIndex ] . theme ;
211
- this . template . played . style . background = this . options . audio [ this . playIndex ] . theme ;
212
- this . template . thumb . style . background = this . options . audio [ this . playIndex ] . theme ;
213
- this . template . volume . style . background = this . options . audio [ this . playIndex ] . theme ;
214
- }
209
+ this . theme ( ) ;
215
210
this . template . title . innerHTML = this . options . audio [ this . playIndex ] . name ;
216
211
this . template . author . innerHTML = this . options . audio [ this . playIndex ] . artist ? ' - ' + this . options . audio [ this . playIndex ] . artist : '' ;
217
212
const light = this . container . getElementsByClassName ( 'aplayer-list-light' ) [ 0 ] ;
@@ -244,6 +239,17 @@ class APlayer {
244
239
} ) ;
245
240
}
246
241
242
+ theme ( color = this . options . audio [ this . playIndex ] . theme , index = this . playIndex ) {
243
+ this . options . audio [ index ] . theme = color ;
244
+ this . template . listCurs [ index ] . style . backgroundColor = color ;
245
+ if ( index === this . playIndex ) {
246
+ this . template . pic . style . backgroundColor = color ;
247
+ this . template . played . style . background = color ;
248
+ this . template . thumb . style . background = color ;
249
+ this . template . volume . style . background = color ;
250
+ }
251
+ }
252
+
247
253
seek ( time ) {
248
254
time = Math . max ( time , 0 ) ;
249
255
if ( this . audio . duration ) {
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ class Template {
32
32
this . button = this . container . querySelector ( '.aplayer-button' ) ;
33
33
this . list = this . container . querySelector ( '.aplayer-list' ) ;
34
34
this . listOl = this . container . querySelector ( '.aplayer-list ol' ) ;
35
+ this . listCurs = this . container . querySelectorAll ( '.aplayer-list-cur' ) ;
35
36
this . played = this . container . querySelector ( '.aplayer-played' ) ;
36
37
this . loaded = this . container . querySelector ( '.aplayer-loaded' ) ;
37
38
this . thumb = this . container . querySelector ( '.aplayer-thumb' ) ;
Original file line number Diff line number Diff line change 52
52
<ol{{ if options.listMaxHeight }} style="max-height: {{ options.listMaxHeight }}"{{ /if }}>
53
53
{{each options.audio}}
54
54
<li>
55
- <span class="aplayer-list-cur" style="background: {{ $value.theme || options.theme }};"></span>
55
+ <span class="aplayer-list-cur" style="background-color : {{ $value.theme || options.theme }};"></span>
56
56
<span class="aplayer-list-index">{{ $index + 1 }}</span>
57
57
<span class="aplayer-list-title">{{ $value.name }}</span>
58
58
<span class="aplayer-list-author">{{ $value.artist }}</span>
You can’t perform that action at this time.
0 commit comments