播放状态切换
This commit is contained in:
parent
cdb2261773
commit
f89ddf2ecd
@ -42,7 +42,7 @@ export default class MusicList {
|
|||||||
ul.music-list > li > span {
|
ul.music-list > li > span {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
ul.music-list > li > span.play {
|
ul.music-list > li.play > span {
|
||||||
color: #02be08;
|
color: #02be08;
|
||||||
}
|
}
|
||||||
ul.music-list > li.cache::marker {
|
ul.music-list > li.cache::marker {
|
||||||
@ -92,12 +92,15 @@ export default class MusicList {
|
|||||||
textContent: `${item.name} - ${bytesToSize(item.size)}`,
|
textContent: `${item.name} - ${bytesToSize(item.size)}`,
|
||||||
onclick: event => {
|
onclick: event => {
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
if (!this.audio.paused) {
|
const li = event.target.parentElement // ListItem
|
||||||
event.target.classList.remove('play')
|
const ul = li.parentElement // List
|
||||||
|
const list = Array.from(ul.children) // ListItems
|
||||||
|
list.forEach(li => li.classList.remove('play'))
|
||||||
|
if (!this.audio.paused && this.playing === item) {
|
||||||
|
li.classList.remove('play')
|
||||||
this.stop(item)
|
this.stop(item)
|
||||||
} else {
|
} else {
|
||||||
this.ul.querySelectorAll('li span.play').forEach(span => span.classList.remove('play'))
|
li.classList.add('play')
|
||||||
event.target.classList.add('play')
|
|
||||||
this.play(item)
|
this.play(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user