vue-aplayer
vue-aplayer copied to clipboard
fix bug in #92
修复 #92 中提到的bug: 使用监听,在 musicList 更新时对 shuffledList 进行一次更新,从而解决列表切换后的实际播放列表未更换的问题。
debug 时使用的 App.vue
测试代码:
<template>
<div id="app">
<aplayer
autoplay
theme="pic"
shuffle
repeat="list"
show-lrc
:muted.sync="muted"
:volume.sync="volume"
:music='list[0]'
:list='list'
/>
<button @click="addList">添加列表</button>
<button @click="removeList">移除列表</button>
</div>
</template>
<script>
import Aplayer from '../vue-aplayer.vue'
export default {
name: 'App',
components: {
Aplayer,
},
data () {
return {
version: VERSION,
volume: 1,
muted: false,
music3: null,
list: [{
title: '回レ!雪月花',
artist: '小倉唯',
src: 'https://moeplayer.b0.upaiyun.com/aplayer/snowmoonflowers.mp3',
pic: 'https://moeplayer.b0.upaiyun.com/aplayer/snowmoonflowers.jpg',
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/snowmoonflowers.lrc',
},
{
title: 'あっちゅ~ま青春!',
artist: '七森中☆ごらく部',
src: 'https://moeplayer.b0.upaiyun.com/aplayer/yuruyuri.mp3',
pic: 'https://moeplayer.b0.upaiyun.com/aplayer/yuruyuri.jpg',
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/yuruyuri.lrc',
},],
}
},
methods: {
addList () {
this.list = [{
title: '前前前世',
artist: 'RADWIMPS',
src: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.mp3',
pic: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.jpg',
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.lrc',
},
{
title: '光るなら.m3u8',
artist: 'Goose house',
src: 'https://moeplayer.b0.upaiyun.com/aplayer/hls/hikarunara.m3u8',
pic: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.jpg',
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.lrc',
},
{
title: '回レ!雪月花',
artist: '小倉唯',
src: 'https://moeplayer.b0.upaiyun.com/aplayer/snowmoonflowers.mp3',
pic: 'https://moeplayer.b0.upaiyun.com/aplayer/snowmoonflowers.jpg',
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/snowmoonflowers.lrc',
},
{
title: 'あっちゅ~ま青春!',
artist: '七森中☆ごらく部',
src: 'https://moeplayer.b0.upaiyun.com/aplayer/yuruyuri.mp3',
pic: 'https://moeplayer.b0.upaiyun.com/aplayer/yuruyuri.jpg',
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/yuruyuri.lrc',
},]
},
removeList () {
this.list = [{
title: '光るなら.m3u8',
artist: 'Goose house',
src: 'https://moeplayer.b0.upaiyun.com/aplayer/hls/hikarunara.m3u8',
pic: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.jpg',
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.lrc',
}]
}
}
}
</script>
<style>
</style>
另外,如果初始的数组长度为 1(大于 1 时正常),那么不能进行播放。