diff --git a/src/js/player.js b/src/js/player.js index 1726b3b..17dd253 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -206,12 +206,7 @@ class APlayer { else { this.template.pic.style.backgroundImage = ''; } - if (this.options.audio[this.playIndex].theme) { - this.template.pic.style.backgroundColor = this.options.audio[this.playIndex].theme; - this.template.played.style.background = this.options.audio[this.playIndex].theme; - this.template.thumb.style.background = this.options.audio[this.playIndex].theme; - this.template.volume.style.background = this.options.audio[this.playIndex].theme; - } + this.theme(); this.template.title.innerHTML = this.options.audio[this.playIndex].name; this.template.author.innerHTML = this.options.audio[this.playIndex].artist ? ' - ' + this.options.audio[this.playIndex].artist : ''; const light = this.container.getElementsByClassName('aplayer-list-light')[0]; @@ -244,6 +239,17 @@ class APlayer { }); } + theme (color = this.options.audio[this.playIndex].theme, index = this.playIndex) { + this.options.audio[index].theme = color; + this.template.listCurs[index].style.backgroundColor = color; + if (index === this.playIndex) { + this.template.pic.style.backgroundColor = color; + this.template.played.style.background = color; + this.template.thumb.style.background = color; + this.template.volume.style.background = color; + } + } + seek (time) { time = Math.max(time, 0); if (this.audio.duration) { diff --git a/src/js/template.js b/src/js/template.js index 72a8646..e1ce4f2 100644 --- a/src/js/template.js +++ b/src/js/template.js @@ -32,6 +32,7 @@ class Template { this.button = this.container.querySelector('.aplayer-button'); this.list = this.container.querySelector('.aplayer-list'); this.listOl = this.container.querySelector('.aplayer-list ol'); + this.listCurs = this.container.querySelectorAll('.aplayer-list-cur'); this.played = this.container.querySelector('.aplayer-played'); this.loaded = this.container.querySelector('.aplayer-loaded'); this.thumb = this.container.querySelector('.aplayer-thumb'); diff --git a/src/template/player.art b/src/template/player.art index 1272b21..8faf71d 100644 --- a/src/template/player.art +++ b/src/template/player.art @@ -52,7 +52,7 @@