Skip to content

Commit d65afed

Browse files
committed
Merge branch 'hotfix/1.4.1'
2 parents e5b8612 + 670d29e commit d65afed

File tree

9 files changed

+100
-25
lines changed

9 files changed

+100
-25
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[![devDependency Status](https://img.shields.io/david/dev/SevenOutman/vue-aplayer.svg?style=flat-square)](https://david-dm.org/SevenOutman/vue-aplayer#info=devDependencies)
1010
[![npm](https://img.shields.io/npm/dt/vue-aplayer.svg?style=flat-square)](https://www.npmjs.com/package/vue-aplayer)
1111

12-
![vue-aplayer](https://i.loli.net/2018/03/16/5aab3da0746e7.png)
12+
![Vue-APlayer](https://i.loli.net/2018/03/16/5aab3da0746e7.png)
1313

1414
### Features
1515
- Clean and simple UI
@@ -28,7 +28,7 @@ Using Vue-APlayer in your project? [Let me know!](https://github.com/SevenOutman
2828
<aplayer autoplay
2929
:music="{
3030
title: 'secret base~君がくれたもの~',
31-
author: 'Silent Siren',
31+
artist: 'Silent Siren',
3232
src: 'https://moeplayer.b0.upaiyun.com/aplayer/secretbase.mp3',
3333
pic: 'https://moeplayer.b0.upaiyun.com/aplayer/secretbase.jpg'
3434
}"

docs/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $ npm install vue-aplayer --save
1919
<aplayer autoplay
2020
:music="{
2121
title: 'secret base~君がくれたもの~',
22-
author: 'Silent Siren',
22+
artist: 'Silent Siren',
2323
src: 'https://moeplayer.b0.upaiyun.com/aplayer/secretbase.mp3',
2424
pic: 'https://moeplayer.b0.upaiyun.com/aplayer/secretbase.jpg'
2525
}"
@@ -52,6 +52,7 @@ new Vue({
5252
| theme | String | `'#41b883'` | Theme color, will be overridden by current `music`'s theme if set |
5353
| mode | String | `'circulation'` | Play mode, can be 'random' 'single 'circulation'(loop) or 'order'(no loop) |
5454
| listMaxHeight | String | *none* | Max height of play list |
55+
| listFolded | Boolean | `false` | Fold playlist initially |
5556
| narrow | | | DEPRECATED, use `mini` instead |
5657
| listmaxheight | | | DEPRECATED, use `listMaxHeight` instead |
5758
| showlrc | | | DEPRECATED, use `showLrc` instead |
@@ -84,11 +85,12 @@ The `music` props contains info of the song to play.
8485
| -------- | ------- | ----------- |
8586
| src | *required* | Music source url |
8687
| title | `'Untitled'` | Music title |
87-
| author | `'Unknown'` | Music author |
88+
| artist | `'Unknown'` | Music artist |
8889
| pic | *none* | Music cover picture |
8990
| lrc | *none* | lrc or url to a .lrc file, see: [LRC](https://aplayer.js.org/#/home?id=lrc) |
9091
| theme | *none* | Song-specific theme color |
91-
| url || DEPRECATED, use `src` instead |
92+
| url | | DEPRECATED, use `src` instead |
93+
| author | | DEPRECATED, use `artist` instead |
9294

9395

9496

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-aplayer",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"description": "Easy-to-config music player for Vue 2.x",
55
"main": "dist/vue-aplayer.min.js",
66
"files": [

src/components/aplayer-controller-progress.vue

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
class="aplayer-thumb"
2222
:style="{borderColor: theme, backgroundColor: thumbHovered ? theme : '#fff'}"
2323
>
24+
<span class="aplayer-loading-icon"
25+
:style="{backgroundColor: theme }"
26+
>
27+
<icon type="loading"/>
28+
</span>
2429
</span>
2530
</div>
2631
</div>
@@ -29,8 +34,12 @@
2934

3035
<script>
3136
import {getElementViewLeft} from '../utils'
37+
import Icon from './aplayer-icon.vue'
3238
3339
export default {
40+
components: {
41+
Icon
42+
},
3443
props: ['loadProgress', 'playProgress', 'theme'],
3544
data () {
3645
return {
@@ -153,8 +162,40 @@
153162
&:hover {
154163
transform: scale(1);
155164
}
165+
166+
overflow: hidden;
167+
.aplayer-loading-icon {
168+
display: none;
169+
width: 100%;
170+
height: 100%;
171+
172+
svg {
173+
position: absolute;
174+
animation: spin 1s linear infinite;
175+
fill: #ffffff;
176+
}
177+
}
156178
}
157179
}
158180
}
159181
}
182+
183+
.aplayer-loading {
184+
.aplayer-bar-wrap .aplayer-bar .aplayer-thumb .aplayer-loading-icon {
185+
display: block;
186+
}
187+
188+
.aplayer-info .aplayer-controller .aplayer-bar-wrap .aplayer-bar .aplayer-played .aplayer-thumb {
189+
transform: scale(1);
190+
}
191+
}
192+
193+
@keyframes spin {
194+
0% {
195+
transform: rotate(0)
196+
}
197+
100% {
198+
transform: rotate(360deg)
199+
}
200+
}
160201
</style>

src/components/aplayer-icon.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
'order': ['0 0 32 32', 'M0.622 18.334h19.54v7.55l11.052-9.412-11.052-9.413v7.549h-19.54v3.725z'],
1919
'single': ['0 0 38 32', 'M2.072 21.577c0.71-0.197 1.125-0.932 0.928-1.641-0.221-0.796-0.333-1.622-0.333-2.457 0-5.049 4.108-9.158 9.158-9.158h5.428c0.056-0.922 0.221-1.816 0.482-2.667h-5.911c-3.158 0-6.128 1.23-8.361 3.463s-3.463 5.203-3.463 8.361c0 1.076 0.145 2.143 0.431 3.171 0.164 0.59 0.7 0.976 1.284 0.976 0.117 0 0.238-0.016 0.357-0.049zM21.394 25.613h-12.409v-2.362c0-0.758-0.528-1.052-1.172-0.652l-5.685 3.522c-0.644 0.4-0.651 1.063-0.014 1.474l5.712 3.69c0.637 0.411 1.158 0.127 1.158-0.63v-2.374h12.409c3.158 0 6.128-1.23 8.361-3.463 1.424-1.424 2.44-3.148 2.99-5.029-0.985 0.368-2.033 0.606-3.125 0.691-1.492 3.038-4.619 5.135-8.226 5.135zM28.718 0c-4.985 0-9.026 4.041-9.026 9.026s4.041 9.026 9.026 9.026 9.026-4.041 9.026-9.026-4.041-9.026-9.026-9.026zM30.392 13.827h-1.728v-6.822c-0.635 0.576-1.433 1.004-2.407 1.285v-1.713c0.473-0.118 0.975-0.325 1.506-0.62 0.532-0.325 0.975-0.665 1.329-1.034h1.3v8.904z'],
2020
'menu': ['0 0 22 32', 'M20.8 14.4q0.704 0 1.152 0.48t0.448 1.12-0.48 1.12-1.12 0.48h-19.2q-0.64 0-1.12-0.48t-0.48-1.12 0.448-1.12 1.152-0.48h19.2zM1.6 11.2q-0.64 0-1.12-0.48t-0.48-1.12 0.448-1.12 1.152-0.48h19.2q0.704 0 1.152 0.48t0.448 1.12-0.48 1.12-1.12 0.48h-19.2zM20.8 20.8q0.704 0 1.152 0.48t0.448 1.12-0.48 1.12-1.12 0.48h-19.2q-0.64 0-1.12-0.48t-0.48-1.12 0.448-1.12 1.152-0.48h19.2z'],
21+
'loading': ['0 0 32 32', 'M4 16c0-6.6 5.4-12 12-12s12 5.4 12 12c0 1.2-0.8 2-2 2s-2-0.8-2-2c0-4.4-3.6-8-8-8s-8 3.6-8 8 3.6 8 8 8c1.2 0 2 0.8 2 2s-0.8 2-2 2c-6.6 0-12-5.4-12-12z']
2122
};
2223
export default {
2324
props: ['type'],

src/components/aplayer-list.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<span class="aplayer-list-cur" :style="{background: theme}"></span>
1919
<span class="aplayer-list-index">{{ index + 1}}</span>
2020
<span class="aplayer-list-title">{{ aMusic.title || 'Untitled' }}</span>
21-
<span class="aplayer-list-author">{{ aMusic.author || 'Unknown' }}</span>
21+
<span class="aplayer-list-author">{{ aMusic.artist || aMusic.author || 'Unknown' }}</span>
2222
</li>
2323
</ol>
2424
</div>
@@ -46,8 +46,9 @@
4646
listmaxheight: String,
4747
},
4848
mounted () {
49-
this.$el.style.height = `${this.$el.offsetHeight}px`
50-
this.$refs.ol.style.height = `${this.$el.offsetHeight}px`
49+
const listHeight = 33 * this.musicList.length - 1
50+
this.$el.style.height = `${listHeight}px`
51+
this.$refs.ol.style.height = `${listHeight}px`
5152
},
5253
}
5354
</script>

src/components/aplayer-thumbnail.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
},
2323
props: {
2424
pic: String,
25+
theme: String,
2526
playing: {
2627
type: Boolean,
2728
default: false,
@@ -43,6 +44,7 @@
4344
if (!this.pic) return {}
4445
return {
4546
backgroundImage: `url(${this.pic})`,
47+
backgroundColor: this.theme
4648
}
4749
},
4850
},

src/demo/App.vue

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
</svg>
1414
</a>
1515
<div class="container">
16-
<h1>Vue-APlayer</h1>
17-
<p>
16+
<h1 align="center">Vue-APlayer</h1>
17+
<p align="center">
1818
<a href="https://www.npmjs.com/package/vue-aplayer"><img
1919
src="https://img.shields.io/npm/v/vue-aplayer.svg?style=flat-square"/></a>
2020
<a href="https://david-dm.org/SevenOutman/vue-aplayer#info=devDependencies"><img
@@ -28,7 +28,7 @@
2828
<aplayer
2929
:music="{
3030
title: 'secret base~君がくれたもの~',
31-
author: 'Silent Siren',
31+
artist: 'Silent Siren',
3232
src: 'https://moeplayer.b0.upaiyun.com/aplayer/secretbase.mp3',
3333
pic: 'https://moeplayer.b0.upaiyun.com/aplayer/secretbase.jpg'
3434
}"
@@ -74,7 +74,7 @@
7474
mode="circulation"
7575
:music="{
7676
title: 'トリカゴ',
77-
author: 'XX:me',
77+
artist: 'XX:me',
7878
src: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.mp3',
7979
pic: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.jpg',
8080
}"
@@ -113,28 +113,28 @@
113113
list3: [
114114
{
115115
title: '前前前世',
116-
author: 'RADWIMPS',
116+
artist: 'RADWIMPS',
117117
src: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.mp3',
118118
pic: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.jpg',
119119
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.lrc',
120120
},
121121
{
122122
title: '光るなら.m3u8',
123-
author: 'Goose house',
123+
artist: 'Goose house',
124124
src: 'https://moeplayer.b0.upaiyun.com/aplayer/hls/hikarunara.m3u8',
125125
pic: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.jpg',
126126
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.lrc',
127127
},
128128
{
129129
title: '回レ!雪月花',
130-
author: '小倉唯',
130+
artist: '小倉唯',
131131
src: 'https://moeplayer.b0.upaiyun.com/aplayer/snowmoonflowers.mp3',
132132
pic: 'https://moeplayer.b0.upaiyun.com/aplayer/snowmoonflowers.jpg',
133133
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/snowmoonflowers.lrc'
134134
},
135135
{
136136
title: 'あっちゅ~ま青春!',
137-
author: '七森中☆ごらく部',
137+
artist: '七森中☆ごらく部',
138138
src: 'https://moeplayer.b0.upaiyun.com/aplayer/yuruyuri.mp3',
139139
pic: 'https://moeplayer.b0.upaiyun.com/aplayer/yuruyuri.jpg',
140140
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/yuruyuri.lrc',
@@ -161,7 +161,7 @@
161161
}
162162
163163
h1 {
164-
font-size: 54px;
164+
font-size: 48px;
165165
color: #41b883;
166166
margin: 30px 0 10px;
167167
}

src/vue-aplayer.vue

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
'aplayer-narrow': isMiniMode,
66
'aplayer-withlist' : !isMiniMode && musicList.length > 0,
77
'aplayer-withlrc': !isMiniMode && (!!$slots.display || shouldShowLrc),
8-
'aplayer-float': isFloatMode
8+
'aplayer-float': isFloatMode,
9+
'aplayer-loading': isPlaying && isLoading
910
}"
1011
:style="floatStyleObj"
1112
>
@@ -14,14 +15,15 @@
1415
:pic="currentMusic.pic"
1516
:playing="isPlaying"
1617
:enable-drag="isFloatMode"
18+
:theme="currentTheme"
1719
@toggleplay="toggle"
1820
@dragbegin="onDragBegin"
1921
@dragging="onDragAround"
2022
/>
2123
<div class="aplayer-info" v-show="!isMiniMode">
2224
<div class="aplayer-music">
2325
<span class="aplayer-title">{{ currentMusic.title || 'Untitled' }}</span>
24-
<span class="aplayer-author">{{ currentMusic.author || 'Unknown' }}</span>
26+
<span class="aplayer-author">{{ currentMusic.artist || currentMusic.author || 'Unknown' }}</span>
2527
</div>
2628
<slot name="display" :current-music="currentMusic" :play-stat="playStat">
2729
<lyrics :current-music="currentMusic" :play-stat="playStat" v-show="shouldShowLrc"/>
@@ -91,6 +93,9 @@
9193
if (song.url) {
9294
deprecatedProp('music.url', '1.4.0', 'music.src')
9395
}
96+
if (song.author) {
97+
deprecatedProp('music.author', '1.4.1', 'music.artist')
98+
}
9499
return song.src || song.url
95100
},
96101
},
@@ -121,7 +126,14 @@
121126
default: 'circulation',
122127
},
123128
listMaxHeight: String,
124-
129+
/**
130+
* @since 1.4.1
131+
* Fold playlist initially
132+
*/
133+
listFolded: {
134+
type: Boolean,
135+
default: false
136+
},
125137
126138
/**
127139
* @since 1.2.0 Float mode
@@ -234,7 +246,7 @@
234246
loadedTime: 0,
235247
playedTime: 0,
236248
},
237-
showList: true,
249+
showList: !this.listFolded,
238250
239251
// handle Promise returned from audio.play()
240252
// @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/play
@@ -257,7 +269,11 @@
257269
// sync muted, volume
258270
259271
internalMuted: this.muted,
260-
internalVolume: this.volume
272+
internalVolume: this.volume,
273+
274+
// @since 1.4.1
275+
// Loading indicator
276+
isLoading: false
261277
}
262278
},
263279
computed: {
@@ -512,6 +528,12 @@
512528
onAudioPause () {
513529
this.isPlaying = false
514530
},
531+
onAudioWaiting () {
532+
this.isLoading = true
533+
},
534+
onAudioCanplay () {
535+
this.isLoading = false
536+
},
515537
onAudioDurationChange () {
516538
if (this.audio.duration !== 1) {
517539
this.playStat.duration = this.audio.duration
@@ -597,7 +619,9 @@
597619
'pause', 'play', 'playing', 'progress',
598620
'ratechange',
599621
'seeked', 'seeking', 'stalled', 'suspend',
600-
'timeupdate', 'volumechange', 'waiting'
622+
'timeupdate',
623+
'volumechange',
624+
'waiting'
601625
]
602626
mediaEvents.forEach(event => {
603627
this.audio.addEventListener(event, e => this.$emit(event, e))
@@ -610,6 +634,8 @@
610634
this.audio.addEventListener('play', this.onAudioPlay)
611635
this.audio.addEventListener('pause', this.onAudioPause)
612636
this.audio.addEventListener('abort', this.onAudioPause)
637+
this.audio.addEventListener('waiting', this.onAudioWaiting)
638+
this.audio.addEventListener('canplay', this.onAudioCanplay)
613639
this.audio.addEventListener('progress', this.onAudioProgress)
614640
this.audio.addEventListener('durationchange', this.onAudioDurationChange)
615641
this.audio.addEventListener('seeking', this.onAudioSeeking)
@@ -653,6 +679,9 @@
653679
654680
currentMusic: {
655681
handler (music) {
682+
// async
683+
this.setSelfAdaptingTheme()
684+
656685
const src = music.src || music.url
657686
// HLS support
658687
if (/\.m3u8(?=(#|\?|$))/.test(src)) {
@@ -680,7 +709,6 @@
680709
this.audio.src = src
681710
}
682711
// self-adapting theme color
683-
this.setSelfAdaptingTheme()
684712
},
685713
},
686714

0 commit comments

Comments
 (0)