Skip to content

Commit 64ad4fd

Browse files
committed
Merge branch 'release/1.5.0'
2 parents 26529e0 + 2c0e9ee commit 64ad4fd

26 files changed

+325
-137
lines changed

docs/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@ new Vue({
5050
| showLrc | Boolean | `false` | Whether to show lyrics or not |
5151
| mutex | Boolean | `true` | Pause other players when this player is playing |
5252
| theme | String | `'#41b883'` | Theme color, will be overridden by current `music`'s theme if set |
53-
| mode | String | `'circulation'` | Play mode, can be 'random' 'single 'circulation'(loop) or 'order'(no loop) |
53+
| shuffle | Boolean | `false` | Shuffle the playlist |
54+
| repeat | String | `'no-repeat'` | How to repeat play. Either to `'repeat-one'` `'repeat-all'` or `'no-repeat'`. You can also use accordingly `'none'` `'music'` `'list'` for easier remembering |
5455
| listMaxHeight | String | *none* | Max height of play list |
5556
| listFolded | Boolean | `false` | Fold playlist initially |
5657
| narrow | | | DEPRECATED, use `mini` instead |
5758
| listmaxheight | | | DEPRECATED, use `listMaxHeight` instead |
5859
| showlrc | | | DEPRECATED, use `showLrc` instead |
5960

60-
> If you are using Vue@2.3.0+, you can use [`.sync` Modifier](https://vuejs.org/v2/guide/components.html#sync-Modifier) on `music` and `mode` props.
61+
> If you are using Vue@2.3.0+, you can use [`.sync` Modifier](https://vuejs.org/v2/guide/components.html#sync-Modifier) on `music`, `shuffle` and `repeat` props.
6162
6263

6364

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-aplayer",
3-
"version": "1.4.2",
3+
"version": "1.5.0",
44
"description": "Easy-to-config music player for Vue 2.x",
55
"main": "dist/vue-aplayer.min.js",
66
"files": [
@@ -59,6 +59,7 @@
5959
"postcss-loader": "^2.1.1",
6060
"sass-loader": "^6.0.7",
6161
"style-loader": "^0.20.2",
62+
"svg-inline-loader": "^0.8.0",
6263
"url-loader": "^1.0.1",
6364
"vue": "^2.5.16",
6465
"vue-html-loader": "^1.2.4",

src/assets/loading.svg

Lines changed: 3 additions & 0 deletions
Loading

src/assets/lrc.svg

Lines changed: 3 additions & 0 deletions
Loading

src/assets/menu.svg

Lines changed: 3 additions & 0 deletions
Loading

src/assets/no-repeat.svg

Lines changed: 3 additions & 0 deletions
Loading

src/assets/pause.svg

Lines changed: 3 additions & 0 deletions
Loading

src/assets/play.svg

Lines changed: 3 additions & 0 deletions
Loading

src/assets/repeat-all-legacy.svg

Lines changed: 3 additions & 0 deletions
Loading

src/assets/repeat-all.svg

Lines changed: 3 additions & 0 deletions
Loading

src/assets/repeat-one-legacy.svg

Lines changed: 3 additions & 0 deletions
Loading

src/assets/repeat-one.svg

Lines changed: 3 additions & 0 deletions
Loading

src/assets/shuffle.svg

Lines changed: 3 additions & 0 deletions
Loading

src/assets/skip.svg

Lines changed: 3 additions & 0 deletions
Loading

src/assets/volume-down.svg

Lines changed: 3 additions & 0 deletions
Loading

src/assets/volume-off.svg

Lines changed: 3 additions & 0 deletions
Loading

src/assets/volume-up.svg

Lines changed: 3 additions & 0 deletions
Loading

src/components/aplayer-controller.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
@togglemute="$emit('togglemute')"
2121
@setvolume="v => $emit('setvolume', v)"
2222
/>
23-
<icon-button class="aplayer-icon-mode" :icon="mode" @click.native="$emit('nextmode')"/>
23+
<icon-button class="aplayer-icon-mode" icon="shuffle" @click.native="$emit('toggleshuffle')" :class="{ 'inactive': !shuffle }"/>
24+
<icon-button class="aplayer-icon-mode" :icon="repeat === 'repeat-one' ? 'repeat-one' : 'repeat-all'" :class="{ 'inactive': repeat === 'no-repeat'}" @click.native="$emit('nextmode')"/>
2425
<icon-button class="aplayer-icon-menu" icon="menu" @click.native="$emit('togglelist')"/>
2526
</div>
2627
</div>
@@ -37,7 +38,7 @@
3738
VProgress,
3839
Volume,
3940
},
40-
props: ['mode', 'stat', 'theme', 'volume', 'muted'],
41+
props: ['shuffle', 'repeat', 'stat', 'theme', 'volume', 'muted'],
4142
computed: {
4243
loadProgress () {
4344
if (this.stat.duration === 0) return 0

src/components/aplayer-icon.vue

Lines changed: 17 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,29 @@
11
<template>
2-
<svg xmlns:xlink="http://www.w3.org/1999/xlink" height="100%" version="1.1" :viewBox="viewBox" width="100%">
2+
<svg xmlns:xlink="http://www.w3.org/1999/xlink" height="100%" version="1.1" :viewBox="svg.viewBox" width="100%">
33
<use xlink:href="#aplayer-${type}"></use>
4-
<path class="aplayer-fill" :d="d"></path>
4+
<path class="aplayer-fill" :d="svg.d"></path>
55
</svg>
66
</template>
77

88
<script>
9+
const requireAssets = require.context('../assets', false, /\.svg$/)
10+
const SVGs = requireAssets.keys().reduce((svgs, path) => {
11+
const inlineSvg = requireAssets(path)
12+
const [raw, viewBox, d] = inlineSvg.match(/^<svg.+?viewBox="(.+?)".*><path.+?d="(.+?)".*><\/path><\/svg>$/)
13+
14+
svgs[path.match(/^.*\/(.+?)\.svg$/)[1]] = {
15+
viewBox,
16+
d
17+
}
18+
return svgs
19+
}, {})
920
10-
const SVG = {
11-
'play': ['0 0 16 31', 'M15.552 15.168q0.448 0.32 0.448 0.832 0 0.448-0.448 0.768l-13.696 8.512q-0.768 0.512-1.312 0.192t-0.544-1.28v-16.448q0-0.96 0.544-1.28t1.312 0.192z'],
12-
'pause': ['0 0 17 32', 'M14.080 4.8q2.88 0 2.88 2.048v18.24q0 2.112-2.88 2.112t-2.88-2.112v-18.24q0-2.048 2.88-2.048zM2.88 4.8q2.88 0 2.88 2.048v18.24q0 2.112-2.88 2.112t-2.88-2.112v-18.24q0-2.048 2.88-2.048z'],
13-
'volume-up': ['0 0 28 32', 'M13.728 6.272v19.456q0 0.448-0.352 0.8t-0.8 0.32-0.8-0.32l-5.952-5.952h-4.672q-0.48 0-0.8-0.352t-0.352-0.8v-6.848q0-0.48 0.352-0.8t0.8-0.352h4.672l5.952-5.952q0.32-0.32 0.8-0.32t0.8 0.32 0.352 0.8zM20.576 16q0 1.344-0.768 2.528t-2.016 1.664q-0.16 0.096-0.448 0.096-0.448 0-0.8-0.32t-0.32-0.832q0-0.384 0.192-0.64t0.544-0.448 0.608-0.384 0.512-0.64 0.192-1.024-0.192-1.024-0.512-0.64-0.608-0.384-0.544-0.448-0.192-0.64q0-0.48 0.32-0.832t0.8-0.32q0.288 0 0.448 0.096 1.248 0.48 2.016 1.664t0.768 2.528zM25.152 16q0 2.72-1.536 5.056t-4 3.36q-0.256 0.096-0.448 0.096-0.48 0-0.832-0.352t-0.32-0.8q0-0.704 0.672-1.056 1.024-0.512 1.376-0.8 1.312-0.96 2.048-2.4t0.736-3.104-0.736-3.104-2.048-2.4q-0.352-0.288-1.376-0.8-0.672-0.352-0.672-1.056 0-0.448 0.32-0.8t0.8-0.352q0.224 0 0.48 0.096 2.496 1.056 4 3.36t1.536 5.056zM29.728 16q0 4.096-2.272 7.552t-6.048 5.056q-0.224 0.096-0.448 0.096-0.48 0-0.832-0.352t-0.32-0.8q0-0.64 0.704-1.056 0.128-0.064 0.384-0.192t0.416-0.192q0.8-0.448 1.44-0.896 2.208-1.632 3.456-4.064t1.216-5.152-1.216-5.152-3.456-4.064q-0.64-0.448-1.44-0.896-0.128-0.096-0.416-0.192t-0.384-0.192q-0.704-0.416-0.704-1.056 0-0.448 0.32-0.8t0.832-0.352q0.224 0 0.448 0.096 3.776 1.632 6.048 5.056t2.272 7.552z'],
14-
'volume-down': ['0 0 28 32', 'M13.728 6.272v19.456q0 0.448-0.352 0.8t-0.8 0.32-0.8-0.32l-5.952-5.952h-4.672q-0.48 0-0.8-0.352t-0.352-0.8v-6.848q0-0.48 0.352-0.8t0.8-0.352h4.672l5.952-5.952q0.32-0.32 0.8-0.32t0.8 0.32 0.352 0.8zM20.576 16q0 1.344-0.768 2.528t-2.016 1.664q-0.16 0.096-0.448 0.096-0.448 0-0.8-0.32t-0.32-0.832q0-0.384 0.192-0.64t0.544-0.448 0.608-0.384 0.512-0.64 0.192-1.024-0.192-1.024-0.512-0.64-0.608-0.384-0.544-0.448-0.192-0.64q0-0.48 0.32-0.832t0.8-0.32q0.288 0 0.448 0.096 1.248 0.48 2.016 1.664t0.768 2.528z'],
15-
'volume-off': ['0 0 28 32', 'M13.728 6.272v19.456q0 0.448-0.352 0.8t-0.8 0.32-0.8-0.32l-5.952-5.952h-4.672q-0.48 0-0.8-0.352t-0.352-0.8v-6.848q0-0.48 0.352-0.8t0.8-0.352h4.672l5.952-5.952q0.32-0.32 0.8-0.32t0.8 0.32 0.352 0.8z'],
16-
'circulation': ['0 0 29 32', 'M25.6 9.92q1.344 0 2.272 0.928t0.928 2.272v9.28q0 1.28-0.928 2.24t-2.272 0.96h-22.4q-1.28 0-2.24-0.96t-0.96-2.24v-9.28q0-1.344 0.96-2.272t2.24-0.928h8v-3.52l6.4 5.76-6.4 5.76v-3.52h-6.72v6.72h19.84v-6.72h-4.8v-4.48h6.080z'],
17-
'random': ['0 0 33 31', 'M29.867 9.356l-5.003 5.003c-0.094 0.094-0.235 0.141-0.36 0.141-0.266 0-0.5-0.219-0.5-0.5v-3.002h-4.002c-2.079 0-3.064 1.423-3.94 3.111-0.453 0.875-0.844 1.782-1.219 2.673-1.735 4.033-3.768 8.223-8.849 8.223h-3.502c-0.281 0-0.5-0.219-0.5-0.5v-3.002c0-0.281 0.219-0.5 0.5-0.5h3.502c2.079 0 3.064-1.423 3.94-3.111 0.453-0.875 0.844-1.782 1.219-2.673 1.735-4.033 3.768-8.223 8.849-8.223h4.002v-3.002c0-0.281 0.219-0.5 0.5-0.5 0.141 0 0.266 0.063 0.375 0.156l4.987 4.987c0.094 0.094 0.141 0.235 0.141 0.36s-0.047 0.266-0.141 0.36zM10.262 14.781c-0.907-1.892-1.907-3.783-4.268-3.783h-3.502c-0.281 0-0.5-0.219-0.5-0.5v-3.002c0-0.281 0.219-0.5 0.5-0.5h3.502c2.783 0 4.831 1.298 6.41 3.518-0.876 1.344-1.517 2.798-2.142 4.268zM29.867 23.363l-5.003 5.003c-0.094 0.094-0.235 0.141-0.36 0.141-0.266 0-0.5-0.235-0.5-0.5v-3.002c-4.643 0-7.504 0.547-10.396-3.518 0.86-1.344 1.501-2.798 2.126-4.268 0.907 1.892 1.907 3.783 4.268 3.783h4.002v-3.002c0-0.281 0.219-0.5 0.5-0.5 0.141 0 0.266 0.063 0.375 0.156l4.987 4.987c0.094 0.094 0.141 0.235 0.141 0.36s-0.047 0.266-0.141 0.36z'],
18-
'order': ['0 0 32 32', 'M0.622 18.334h19.54v7.55l11.052-9.412-11.052-9.413v7.549h-19.54v3.725z'],
19-
'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'],
20-
'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']
22-
};
2321
export default {
2422
props: ['type'],
2523
computed: {
26-
viewBox () {
27-
return SVG[this.type][0]
28-
},
29-
d () {
30-
return SVG[this.type][1]
31-
},
32-
},
33-
}
34-
</script>
35-
36-
<style lang="scss">
37-
.aplayer-icon {
38-
width: 15px;
39-
height: 15px;
40-
border: none;
41-
background-color: transparent;
42-
outline: none;
43-
cursor: pointer;
44-
opacity: .8;
45-
vertical-align: middle;
46-
padding: 0;
47-
font-size: 12px;
48-
margin: 0;
49-
display: inline;
50-
51-
.aplayer-fill {
52-
transition: all .2s ease-in-out;
24+
svg () {
25+
return SVGs[this.type] || {}
26+
}
5327
}
5428
}
55-
</style>
29+
</script>

src/components/aplayer-iconbutton.vue

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,33 @@
1717
props: ['icon'],
1818
}
1919
</script>
20+
21+
22+
<style lang="scss">
23+
.aplayer-icon {
24+
width: 15px;
25+
height: 15px;
26+
border: none;
27+
background-color: transparent;
28+
outline: none;
29+
cursor: pointer;
30+
opacity: .8;
31+
vertical-align: middle;
32+
padding: 0;
33+
font-size: 12px;
34+
margin: 0;
35+
display: inline;
36+
37+
&:hover {
38+
opacity: 1;
39+
}
40+
41+
&.inactive {
42+
opacity: .3;
43+
}
44+
45+
.aplayer-fill {
46+
transition: all .2s ease-in-out;
47+
}
48+
}
49+
</style>

src/demo/App.vue

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
<div class="container">
1616
<h1 align="center">Vue-APlayer</h1>
1717
<p align="center">
18+
<img :src="`https://img.shields.io/badge/DEMO-v${version}-41b883.svg?style=flat-square`"/>
1819
<a href="https://www.npmjs.com/package/vue-aplayer"><img
1920
src="https://img.shields.io/npm/v/vue-aplayer.svg?style=flat-square"/></a>
20-
<a href="https://david-dm.org/SevenOutman/vue-aplayer#info=devDependencies"><img
21-
src="https://img.shields.io/david/dev/SevenOutman/vue-aplayer.svg?style=flat-square"/></a>
2221
<a href="https://www.npmjs.com/package/vue-aplayer"><img
2322
src="https://img.shields.io/npm/dt/vue-aplayer.svg?style=flat-square"/></a>
2423
<a href="https://github.com/SevenOutman/vue-aplayer/blob/master/LICENSE"><img
@@ -38,7 +37,8 @@
3837
<aplayer
3938
autoplay
4039
theme="pic"
41-
mode="random"
40+
shuffle
41+
repeat="list"
4242
show-lrc
4343
:controls="controls"
4444
:muted.sync="muted"
@@ -53,12 +53,6 @@
5353
<li>HLS support</li>
5454
<li>External controls</li>
5555
<ul>
56-
<li>
57-
<a role="button" tabindex="-1" @click="controls = !controls">
58-
{{ controls ? 'Hide': 'Show'}} native controls (develop only)
59-
</a>
60-
<span v-if="controls">Drag on either Vue-APlayer or native controls to see how they synchronize</span>
61-
</li>
6256
<li>
6357
<a role="button" tabindex="-1" @click="muted = !muted">
6458
{{ muted ? 'Unmute' : 'Mute' }} player
@@ -106,6 +100,7 @@
106100
},
107101
data () {
108102
return {
103+
version: VERSION,
109104
controls: false,
110105
volume: 1,
111106
muted: false,

src/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ export function versionCompare (semantic1, semantic2) {
5353
if (semantic1 === semantic2) {
5454
return 0
5555
}
56-
const [major1, minor1, patch1] = semantic1.split('.')
57-
const [major2, minor2, patch2] = semantic2.split('.')
56+
const [major1, minor1, patch1] = semantic1.split('.').map(Number)
57+
const [major2, minor2, patch2] = semantic2.split('.').map(Number)
5858

5959
if (major1 > major2) {
6060
return 1

0 commit comments

Comments
 (0)