Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cbc0f99eee | ||
|
|
c3d98f3aca | ||
|
|
bf566955a8 | ||
|
|
960b8b34fd | ||
|
|
d381582fe4 | ||
|
|
3d64d42305 | ||
|
|
7b4d2320a8 | ||
|
|
6f2174cab4 | ||
|
|
ef1ae2b761 | ||
|
|
6f496ac41c | ||
|
|
287950513d | ||
|
|
584f11ce04 | ||
|
|
53096c4e0b | ||
|
|
c4c3ead825 | ||
|
|
a0467709eb | ||
|
|
230f43f41c | ||
|
|
a2c9072c1f | ||
|
|
9c13dfa7f6 | ||
|
|
4c20d7f8be | ||
|
|
b74b5b0802 | ||
|
|
eec8c3a0ed | ||
|
|
3877378602 | ||
|
|
370d039099 | ||
|
|
634ad2def4 | ||
|
|
0b0be17c70 | ||
|
|
d985b8dd8f | ||
|
|
96190c0ebf | ||
|
|
c7df64b2fd | ||
|
|
e78ac91628 | ||
|
|
9030303ad1 | ||
|
|
097fd27caa | ||
|
|
5ce630df04 |
@@ -0,0 +1,7 @@
|
||||
中文用户请注意:请尽量用**英文**描述你的 issue,这样能够让尽可能多的人帮到你。
|
||||
|
||||
If you want to report a bug, please provide the following information:
|
||||
|
||||
- The steps to reproduce.
|
||||
- A minimal demo of the problem via https://jsfiddle.net or http://codepen.io/pen if possible.
|
||||
- Which versions of APlayer, and which browser / OS are affected by this issue?
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "4.0"
|
||||
- "6.1"
|
||||
@@ -1,6 +1,6 @@
|
||||
The Star And Thank Author License (SATA)
|
||||
|
||||
Copyright (c) 2016 DIYgod(i@html.love)
|
||||
Copyright (c) 2016-2017 DIYgod(i@html.love)
|
||||
|
||||
Project Url: https://github.com/DIYgod/APlayer
|
||||
|
||||
@@ -34,4 +34,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
THE SOFTWARE.
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# APlayer
|
||||
|
||||
[](https://www.npmjs.com/package/aplayer)
|
||||
[](https://cdnjs.com/libraries/aplayer)
|
||||
[](https://github.com/DIYgod/APlayer/blob/master/LICENSE)
|
||||
[](https://david-dm.org/DIYgod/APlayer#info=devDependencies)
|
||||
[](https://www.npmjs.com/package/aplayer)
|
||||
[](https://travis-ci.org/DIYgod/APlayer)
|
||||
[](https://gitter.im/diygod233/aplayer)
|
||||
[](https://www.anotherhome.net/)
|
||||
|
||||
> Wow, such a beautiful html5 music player
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
[Demo](http://aplayer.js.org)
|
||||
|
||||
[Docs](http://aplayer.js.org/docs)
|
||||
|
||||
Using APlayer on your project? [Let me know!](https://github.com/DIYgod/APlayer/issues/79)
|
||||
|
||||
Screenshot
|
||||

|
||||
|
||||
@@ -25,173 +29,15 @@ $ npm install aplayer --save
|
||||
|
||||
## CDN
|
||||
|
||||
[unpkg](https://unpkg.com/aplayer)
|
||||
|
||||
[cdnjs](https://cdnjs.com/libraries/aplayer)
|
||||
|
||||
[BootCDN](http://www.bootcdn.cn/aplayer)
|
||||
|
||||
## Usage
|
||||
|
||||
### HTML
|
||||
|
||||
```HTML
|
||||
<div id="player1" class="aplayer"></div>
|
||||
<!-- ... -->
|
||||
<script src="APlayer.min.js"></script>
|
||||
```
|
||||
|
||||
### JS
|
||||
|
||||
```JS
|
||||
var ap = new APlayer(option);
|
||||
```
|
||||
|
||||
#### Options
|
||||
|
||||
```JS
|
||||
var option = {
|
||||
element: document.getElementById('player1'), // Optional, player element
|
||||
narrow: false, // Optional, narrow style
|
||||
autoplay: true, // Optional, autoplay song(s), not supported by mobile browsers
|
||||
showlrc: 0, // Optional, show lrc, can be 0, 1, 2, see: ###With lrc
|
||||
mutex: true, // Optional, pause other players when this player playing
|
||||
theme: '#e6d0b2', // Optional, theme color, default: #b7daff
|
||||
mode: 'random', // Optional, play mode, can be `random` `single` `circulation`(loop) `order`(no loop), default: `circulation`
|
||||
preload: 'metadata', // Optional, the way to load music, can be 'none' 'metadata' 'auto', default: 'auto'
|
||||
listmaxheight: '513px', // Optional, max height of play list
|
||||
music: { // Required, music info, see: ###With playlist
|
||||
title: 'Preparation', // Required, music title
|
||||
author: 'Hans Zimmer/Richard Harvey', // Required, music author
|
||||
url: 'http://7xifn9.com1.z0.glb.clouddn.com/Preparation.mp3', // Required, music url
|
||||
pic: 'http://7xifn9.com1.z0.glb.clouddn.com/Preparation.jpg', // Optional, music picture
|
||||
lrc: '[00:00.00]lrc here\n[00:01.00]aplayer' // Optional, lrc, see: ###With lrc
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### API
|
||||
|
||||
+ `ap.play()` // Resume play
|
||||
+ `ap.play(time)` // Set currentTime
|
||||
+ `ap.pause()` // Pause
|
||||
+ `ap.toggle()` // Toggle between play and pause
|
||||
+ `ap.volume(percentage)` // Set volume
|
||||
+ `ap.on(event, handler)` // Event binding
|
||||
+ `ap.setMusic(index)` // Switch music
|
||||
+ `ap.lrc` // Lrc time and text
|
||||
+ `ap.playIndex` // Current playing index
|
||||
+ `ap.audio` // Return native video, most [native api](http://www.w3schools.com/tags/ref_av_dom.asp) are supported
|
||||
+ `dp.audio.currentTime` // Returns the current playback position
|
||||
+ Most [native api](http://www.w3schools.com/tags/ref_av_dom.asp)
|
||||
|
||||
#### Event binding
|
||||
|
||||
`ap.on(event, handler)`
|
||||
|
||||
`event`:
|
||||
+ `play`: Triggered when APlayer start play
|
||||
+ `pause`: Triggered when APlayer paused
|
||||
+ `canplay`: Triggered when enough data is available that APlayer can be played
|
||||
+ `playing`: Triggered periodically when APlayer is playing
|
||||
+ `ended`: Triggered when APlayer ended
|
||||
+ `error`: Triggered when an error occurs
|
||||
|
||||
#### Work with module bundler
|
||||
|
||||
```js
|
||||
var APlayer = require('APlayer');
|
||||
var ap = new APlayer({
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
### With lrc
|
||||
|
||||
Show lrc, you can put LRC in JS or HTML as you like.
|
||||
|
||||
#### LRC format:
|
||||
|
||||
Support multiple time tag, support three decimal second
|
||||
|
||||
```
|
||||
[mm:ss.xx]lyric
|
||||
[mm:ss.xxx]lyric
|
||||
[mm:ss.xx][mm:ss.xx][mm:ss.xx]lyric
|
||||
...
|
||||
```
|
||||
|
||||
#### LRC in JS:
|
||||
|
||||
JS:
|
||||
|
||||
```js
|
||||
{
|
||||
showlrc: 1,
|
||||
music: {
|
||||
lrc: '[00:00.00]lrc here\n[00:01.00]aplayer' // lrc here, separate lines with \n
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### LRC in HTML:
|
||||
|
||||
JS:
|
||||
|
||||
```js
|
||||
{
|
||||
showlrc: 2
|
||||
}
|
||||
```
|
||||
|
||||
HTML:
|
||||
|
||||
```HTML
|
||||
<div id="player1" class="aplayer">
|
||||
<pre class="aplayer-lrc-content">
|
||||
[00:00.00]平凡之路 - 朴树
|
||||
[00:04.01]作词:韩寒 朴树
|
||||
[00:08.02]作曲:朴树 编曲:朴树
|
||||
[00:12.02]徘徊着的 在路上的
|
||||
[00:17.37]你要走吗
|
||||
[00:23.20]易碎的 骄傲着
|
||||
<!-- ... -->
|
||||
</pre>
|
||||
</div>
|
||||
```
|
||||
|
||||
#### LRC in lrc file or API:
|
||||
|
||||
```js
|
||||
{
|
||||
showlrc: 3,
|
||||
music: {
|
||||
lrc: 'path/to/music.lrc'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### With playlist
|
||||
|
||||
Show multiple music.
|
||||
|
||||
#### JS:
|
||||
|
||||
Option:
|
||||
|
||||
```JS
|
||||
music: [
|
||||
{
|
||||
title: '',
|
||||
author: '',
|
||||
url: '',
|
||||
pic: ''
|
||||
},
|
||||
{
|
||||
title: '',
|
||||
author: '',
|
||||
url: '',
|
||||
pic: ''
|
||||
},
|
||||
...
|
||||
]
|
||||
```
|
||||
See [docs](http://aplayer.js.org/docs)
|
||||
|
||||
## Run in development
|
||||
|
||||
@@ -217,6 +63,8 @@ $ npm run build
|
||||
|
||||
- [Hermit-X(APlayer for WordPress)](https://github.com/liwanglin12/Hermit-X)
|
||||
|
||||
- [vue-aplayer](https://github.com/SevenOutman/vue-aplayer)
|
||||
|
||||
## LICENSE
|
||||
|
||||
[The Star And Thank Author License (SATA)](https://github.com/DIYgod/APlayer/blob/master/LICENSE)
|
||||
[The Star And Thank Author License (SATA)](https://github.com/DIYgod/APlayer/blob/master/LICENSE)
|
||||
|
||||
Vendored
+7
-2
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+16
-14
@@ -1,15 +1,16 @@
|
||||
{
|
||||
"name": "aplayer",
|
||||
"version": "1.5.4",
|
||||
"version": "1.6.0",
|
||||
"description": "Wow, such a beautiful html5 music player",
|
||||
"main": "dist/APlayer.min.js",
|
||||
"scripts": {
|
||||
"test": "webpack",
|
||||
"start": "webpack-dev-server --hot --progress --inline --host 0.0.0.0"
|
||||
"build": "webpack",
|
||||
"dev": "WEBPACK_ENV=dev webpack-dev-server --hot --progress --inline --host 0.0.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/DIYgod/APlayer.git"
|
||||
"url": "git+https://github.com/DIYgod/APlayer.git",
|
||||
"type": "git"
|
||||
},
|
||||
"keywords": [
|
||||
"player",
|
||||
@@ -23,18 +24,19 @@
|
||||
},
|
||||
"homepage": "https://github.com/DIYgod/APlayer#readme",
|
||||
"devDependencies": {
|
||||
"autoprefixer": "^6.4.0",
|
||||
"babel-loader": "^6.2.4",
|
||||
"babel-preset-es2015": "^6.13.2",
|
||||
"css-loader": "^0.25.0",
|
||||
"autoprefixer": "^6.7.2",
|
||||
"babel-core": "^6.22.1",
|
||||
"babel-loader": "^6.2.10",
|
||||
"babel-preset-es2015": "^6.22.0",
|
||||
"css-loader": "^0.27.1",
|
||||
"exports-loader": "^0.6.3",
|
||||
"file-loader": "^0.9.0",
|
||||
"node-sass": "^3.8.0",
|
||||
"postcss-loader": "^0.13.0",
|
||||
"sass-loader": "^4.0.0",
|
||||
"file-loader": "^0.10.0",
|
||||
"node-sass": "^4.5.0",
|
||||
"postcss-loader": "^1.2.2",
|
||||
"sass-loader": "^6.0.3",
|
||||
"style-loader": "^0.13.1",
|
||||
"url-loader": "^0.5.7",
|
||||
"webpack": "^1.13.1",
|
||||
"webpack-dev-server": "^1.14.1"
|
||||
"webpack": "^2.2.1",
|
||||
"webpack-dev-server": "^2.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
plugins: [
|
||||
require('autoprefixer')
|
||||
]
|
||||
}
|
||||
+282
-173
@@ -1,4 +1,4 @@
|
||||
console.log("\n %c APlayer 1.5.4 %c http://aplayer.js.org \n\n","color: #fadfa3; background: #030307; padding:5px 0;","background: #fadfa3; padding:5px 0;");
|
||||
console.log("\n %c APlayer 1.6.0 %c http://aplayer.js.org \n\n","color: #fadfa3; background: #030307; padding:5px 0;","background: #fadfa3; padding:5px 0;");
|
||||
|
||||
require('./APlayer.scss');
|
||||
|
||||
@@ -21,7 +21,7 @@ class APlayer {
|
||||
'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'],
|
||||
'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'],
|
||||
'order': ['0 0 32 32', 'M0.622 18.334h19.54v7.55l11.052-9.412-11.052-9.413v7.549h-19.54v3.725z'],
|
||||
'single': ['0 0 34 32', 'M16 0c-8.837 0-16 7.163-16 16s7.163 16 16 16c8.837 0 16-7.163 16-16s-7.163-16-16-16zM16 29.5c-7.456 0-13.5-6.044-13.5-13.5s6.044-13.5 13.5-13.5 13.5 6.044 13.5 13.5-6.044 13.5-13.5 13.5zM15.606 12.578h-3.856v-1.563h1.207c0.429 0 0.839-0.076 1.219-0.225 0.386-0.148 0.715-0.353 0.987-0.612 0.272-0.263 0.495-0.578 0.659-0.952 0.171-0.369 0.253-0.781 0.253-1.227h1.675v16h-2.144v-11.422z'],
|
||||
'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'],
|
||||
'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']
|
||||
};
|
||||
this.getSVG = (type) => {
|
||||
@@ -55,9 +55,6 @@ class APlayer {
|
||||
}
|
||||
}
|
||||
|
||||
// multiple music
|
||||
this.playIndex = Object.prototype.toString.call(option.music) === '[object Array]' ? 0 : -1;
|
||||
|
||||
this.option = option;
|
||||
this.audios = [];
|
||||
this.mode = option.mode;
|
||||
@@ -69,6 +66,9 @@ class APlayer {
|
||||
* @return {String} 00:00 format. 00:00:00 if over an hour long.
|
||||
*/
|
||||
this.secondToTime = (second) => {
|
||||
if (isNaN(second)) {
|
||||
return '00:00';
|
||||
}
|
||||
const add0 = (num) => {
|
||||
return num < 10 ? '0' + num : '' + num;
|
||||
};
|
||||
@@ -133,22 +133,32 @@ class APlayer {
|
||||
}
|
||||
};
|
||||
|
||||
this.multiple = this.playIndex > -1;
|
||||
this.music = this.multiple ? this.option.music[this.playIndex] : this.option.music;
|
||||
// multiple music
|
||||
this.playIndex = 0;
|
||||
this.multiple = Object.prototype.toString.call(option.music) === '[object Array]';
|
||||
if (!this.multiple) {
|
||||
this.option.music = [this.option.music];
|
||||
}
|
||||
this.music = this.option.music[this.playIndex];
|
||||
|
||||
// add class aplayer-withlrc
|
||||
if (this.option.showlrc) {
|
||||
this.element.classList.add('aplayer-withlrc');
|
||||
}
|
||||
if (this.option.music.length > 1) {
|
||||
this.element.classList.add('aplayer-list');
|
||||
this.element.classList.add('aplayer-withlist');
|
||||
}
|
||||
|
||||
if (!this.multiple && this.mode !== 'circulation' && this.mode !== 'order') {
|
||||
this.mode = 'circulation';
|
||||
}
|
||||
this.getRandomOrder();
|
||||
|
||||
// fill in HTML
|
||||
let eleHTML = `
|
||||
<div class="aplayer-pic" ${(this.music.pic ? (`style="background-image: url('${this.music.pic}');"`) : ``)}>
|
||||
<div class="aplayer-button aplayer-play">
|
||||
<button class="aplayer-icon aplayer-icon-play">`
|
||||
<button type="button" class="aplayer-icon aplayer-icon-play">`
|
||||
+ this.getSVG('play')
|
||||
+ ` </button>
|
||||
</div>
|
||||
@@ -175,7 +185,7 @@ class APlayer {
|
||||
- <span class="aplayer-ptime">00:00</span> / <span class="aplayer-dtime">00:00</span>
|
||||
</span>
|
||||
<div class="aplayer-volume-wrap">
|
||||
<button class="aplayer-icon aplayer-icon-volume-down" ${this.isMobile ? 'style="display: none;"' : ''}>`
|
||||
<button type="button" class="aplayer-icon aplayer-icon-volume-down" ${this.isMobile ? 'style="display: none;"' : ''}>`
|
||||
+ this.getSVG('volume-down')
|
||||
+ ` </button>
|
||||
<div class="aplayer-volume-bar-wrap">
|
||||
@@ -184,17 +194,15 @@ class APlayer {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="aplayer-icon aplayer-icon-mode">`
|
||||
<button type="button" class="aplayer-icon aplayer-icon-mode">`
|
||||
+ this.getSVG(this.mode)
|
||||
+ ` </button>
|
||||
${(this.multiple ? `<button class="aplayer-icon aplayer-icon-menu">`
|
||||
<button type="button" class="aplayer-icon aplayer-icon-menu">`
|
||||
+ this.getSVG('menu')
|
||||
+ ` </button>` : ``)}
|
||||
+ ` </button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
if (this.multiple) {
|
||||
eleHTML += `
|
||||
</div>
|
||||
<div class="aplayer-list" ${this.option.listmaxheight ? `style="max-height: ${this.option.listmaxheight}` : ``}">
|
||||
<ol>`;
|
||||
for (let i = 0; i < this.option.music.length; i++) {
|
||||
@@ -209,7 +217,6 @@ class APlayer {
|
||||
eleHTML += `
|
||||
</ol>
|
||||
</div>`
|
||||
}
|
||||
this.element.innerHTML = eleHTML;
|
||||
|
||||
// hide mode button in arrow container
|
||||
@@ -234,30 +241,28 @@ class APlayer {
|
||||
// play and pause button
|
||||
this.button = this.element.getElementsByClassName('aplayer-button')[0];
|
||||
this.button.addEventListener('click', (e) => {
|
||||
if (this.button.classList.contains('aplayer-play')) {
|
||||
this.play();
|
||||
}
|
||||
else if (this.button.classList.contains('aplayer-pause')) {
|
||||
this.pause();
|
||||
}
|
||||
this.toggle();
|
||||
});
|
||||
|
||||
// click music list: change music
|
||||
if (this.multiple) {
|
||||
const listItem = this.element.getElementsByClassName('aplayer-list')[0].getElementsByTagName('li');
|
||||
for (let i = 0; i < this.option.music.length; i++) {
|
||||
listItem[i].addEventListener('click', () => {
|
||||
const musicIndex = parseInt(listItem[i].getElementsByClassName('aplayer-list-index')[0].innerHTML) - 1;
|
||||
if (musicIndex !== this.playIndex) {
|
||||
this.setMusic(musicIndex);
|
||||
this.play();
|
||||
}
|
||||
else {
|
||||
this.toggle();
|
||||
}
|
||||
});
|
||||
const list = this.element.getElementsByClassName('aplayer-list')[0];
|
||||
list.addEventListener('click', (e) => {
|
||||
let target;
|
||||
if (e.target.tagName.toUpperCase() === 'LI') {
|
||||
target = e.target;
|
||||
}
|
||||
}
|
||||
else {
|
||||
target = e.target.parentElement;
|
||||
}
|
||||
const musicIndex = parseInt(target.getElementsByClassName('aplayer-list-index')[0].innerHTML) - 1;
|
||||
if (musicIndex !== this.playIndex) {
|
||||
this.setMusic(musicIndex);
|
||||
this.play();
|
||||
}
|
||||
else {
|
||||
this.toggle();
|
||||
}
|
||||
});
|
||||
|
||||
// control play progress
|
||||
bar.playedBar = this.element.getElementsByClassName('aplayer-played')[0];
|
||||
@@ -268,9 +273,14 @@ class APlayer {
|
||||
const e = event || window.event;
|
||||
barWidth = bar.barWrap.clientWidth;
|
||||
const percentage = (e.clientX - getElementViewLeft(bar.barWrap)) / barWidth;
|
||||
this.updateBar('played', percentage, 'width');
|
||||
this.element.getElementsByClassName('aplayer-ptime')[0].innerHTML = this.secondToTime(percentage * this.audio.duration);
|
||||
this.audio.currentTime = parseFloat(bar.playedBar.style.width) / 100 * this.audio.duration;
|
||||
if (isNaN(this.audio.duration)) {
|
||||
this.updateBar('played', 0, 'width');
|
||||
}
|
||||
else {
|
||||
this.updateBar('played', percentage, 'width');
|
||||
this.element.getElementsByClassName('aplayer-ptime')[0].innerHTML = this.secondToTime(percentage * this.audio.duration);
|
||||
this.audio.currentTime = parseFloat(bar.playedBar.style.width) / 100 * this.audio.duration;
|
||||
}
|
||||
});
|
||||
|
||||
thumb.addEventListener('mouseover', () => {
|
||||
@@ -295,15 +305,20 @@ class APlayer {
|
||||
const thumbUp = () => {
|
||||
document.removeEventListener('mouseup', thumbUp);
|
||||
document.removeEventListener('mousemove', thumbMove);
|
||||
this.audio.currentTime = parseFloat(bar.playedBar.style.width) / 100 * this.audio.duration;
|
||||
this.playedTime = setInterval(() => {
|
||||
this.updateBar('played', this.audio.currentTime / this.audio.duration, 'width');
|
||||
if (this.option.showlrc) {
|
||||
this.updateLrc();
|
||||
}
|
||||
this.element.getElementsByClassName('aplayer-ptime')[0].innerHTML = this.secondToTime(this.audio.currentTime);
|
||||
this.trigger('playing');
|
||||
}, 100);
|
||||
if (isNaN(this.audio.duration)) {
|
||||
this.updateBar('played', 0, 'width');
|
||||
}
|
||||
else {
|
||||
this.audio.currentTime = parseFloat(bar.playedBar.style.width) / 100 * this.audio.duration;
|
||||
this.playedTime = setInterval(() => {
|
||||
this.updateBar('played', this.audio.currentTime / this.audio.duration, 'width');
|
||||
if (this.option.showlrc) {
|
||||
this.updateLrc();
|
||||
}
|
||||
this.element.getElementsByClassName('aplayer-ptime')[0].innerHTML = this.secondToTime(this.audio.currentTime);
|
||||
this.trigger('playing');
|
||||
}, 100);
|
||||
}
|
||||
};
|
||||
|
||||
thumb.addEventListener('mousedown', () => {
|
||||
@@ -375,39 +390,45 @@ class APlayer {
|
||||
// mode control
|
||||
const modeEle = this.element.getElementsByClassName('aplayer-icon-mode')[0];
|
||||
modeEle.addEventListener('click', () => {
|
||||
if (this.mode === 'random') {
|
||||
this.mode = 'single';
|
||||
if (this.multiple) {
|
||||
if (this.mode === 'random') {
|
||||
this.mode = 'single';
|
||||
}
|
||||
else if (this.mode === 'single') {
|
||||
this.mode = 'order';
|
||||
}
|
||||
else if (this.mode === 'order') {
|
||||
this.mode = 'circulation';
|
||||
}
|
||||
else if (this.mode === 'circulation') {
|
||||
this.mode = 'random';
|
||||
}
|
||||
}
|
||||
else if (this.mode === 'single') {
|
||||
this.mode = 'order';
|
||||
}
|
||||
else if (this.mode === 'order') {
|
||||
this.mode = 'circulation';
|
||||
}
|
||||
else if (this.mode === 'circulation') {
|
||||
this.mode = 'random';
|
||||
else {
|
||||
if (this.mode === 'circulation') {
|
||||
this.mode = 'order';
|
||||
}
|
||||
else {
|
||||
this.mode = 'circulation';
|
||||
}
|
||||
}
|
||||
modeEle.innerHTML = this.getSVG(this.mode);
|
||||
this.audio.loop = !(this.multiple || this.mode === 'order');
|
||||
});
|
||||
|
||||
// toggle menu control
|
||||
if (this.multiple) {
|
||||
const list = this.element.getElementsByClassName('aplayer-list')[0];
|
||||
list.style.height = list.offsetHeight + 'px';
|
||||
this.element.getElementsByClassName('aplayer-icon-menu')[0].addEventListener('click', () => {
|
||||
if (!list.classList.contains('aplayer-list-hide')) {
|
||||
list.classList.add('aplayer-list-hide');
|
||||
}
|
||||
else {
|
||||
list.classList.remove('aplayer-list-hide');
|
||||
}
|
||||
});
|
||||
}
|
||||
list.style.height = list.offsetHeight + 'px';
|
||||
this.element.getElementsByClassName('aplayer-icon-menu')[0].addEventListener('click', () => {
|
||||
if (!list.classList.contains('aplayer-list-hide')) {
|
||||
list.classList.add('aplayer-list-hide');
|
||||
}
|
||||
else {
|
||||
list.classList.remove('aplayer-list-hide');
|
||||
}
|
||||
});
|
||||
|
||||
if (this.mode === 'random') {
|
||||
let random = parseInt(Math.random() * this.option.music.length);
|
||||
this.setMusic(random);
|
||||
this.setMusic(this.randomOrder[0]);
|
||||
}
|
||||
else {
|
||||
this.setMusic(0);
|
||||
@@ -421,11 +442,11 @@ class APlayer {
|
||||
*/
|
||||
setMusic(index) {
|
||||
// get this.music
|
||||
if (this.multiple && typeof(index) !== 'undefined') {
|
||||
if (typeof(index) !== 'undefined') {
|
||||
this.playIndex = index;
|
||||
}
|
||||
const indexMusic = this.playIndex;
|
||||
this.music = this.multiple ? this.option.music[indexMusic] : this.option.music;
|
||||
this.music = this.option.music[indexMusic];
|
||||
|
||||
// set html
|
||||
if (this.music.pic) {
|
||||
@@ -433,12 +454,10 @@ class APlayer {
|
||||
}
|
||||
this.element.getElementsByClassName('aplayer-title')[0].innerHTML = this.music.title;
|
||||
this.element.getElementsByClassName('aplayer-author')[0].innerHTML = ` - ${this.music.author}`;
|
||||
if (this.multiple) {
|
||||
if (this.element.getElementsByClassName('aplayer-list-light')[0]) {
|
||||
this.element.getElementsByClassName('aplayer-list-light')[0].classList.remove('aplayer-list-light');
|
||||
}
|
||||
this.element.getElementsByClassName('aplayer-list')[0].getElementsByTagName('li')[indexMusic].classList.add('aplayer-list-light');
|
||||
if (this.element.getElementsByClassName('aplayer-list-light')[0]) {
|
||||
this.element.getElementsByClassName('aplayer-list-light')[0].classList.remove('aplayer-list-light');
|
||||
}
|
||||
this.element.getElementsByClassName('aplayer-list')[0].getElementsByTagName('li')[indexMusic].classList.add('aplayer-list-light');
|
||||
|
||||
// set the previous audio object
|
||||
if (this.audio) {
|
||||
@@ -446,16 +465,66 @@ class APlayer {
|
||||
this.audio.currentTime = 0;
|
||||
}
|
||||
|
||||
if (this.multiple) {
|
||||
this.element.getElementsByClassName('aplayer-list')[0].scrollTop = indexMusic * 33;
|
||||
}
|
||||
this.element.getElementsByClassName('aplayer-list')[0].scrollTop = indexMusic * 33;
|
||||
|
||||
// get this audio object
|
||||
if ((this.multiple && !this.audios[indexMusic]) || this.playIndex === -1) {
|
||||
if (!this.audios[indexMusic]) {
|
||||
this.audio = document.createElement("audio");
|
||||
this.audio.src = this.music.url;
|
||||
this.audio.preload = this.option.preload ? this.option.preload : 'auto';
|
||||
|
||||
this.audio.addEventListener('play', () => {
|
||||
if (this.button.classList.contains('aplayer-play')) {
|
||||
this.button.classList.remove('aplayer-play');
|
||||
this.button.classList.add('aplayer-pause');
|
||||
this.button.innerHTML = '';
|
||||
setTimeout(() => {
|
||||
this.button.innerHTML = `
|
||||
<button type="button" class="aplayer-icon aplayer-icon-pause">`
|
||||
+ this.getSVG('pause')
|
||||
+ ` </button>`;
|
||||
}, 100);
|
||||
|
||||
// pause other players (Thanks @Aprikyblue)
|
||||
if (this.option.mutex) {
|
||||
for (let i = 0; i < instances.length; i++) {
|
||||
if (this != instances[i]) {
|
||||
instances[i].pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.playedTime) {
|
||||
clearInterval(this.playedTime);
|
||||
}
|
||||
this.playedTime = setInterval(() => {
|
||||
this.updateBar('played', this.audio.currentTime / this.audio.duration, 'width');
|
||||
if (this.option.showlrc) {
|
||||
this.updateLrc();
|
||||
}
|
||||
this.ptime.innerHTML = this.secondToTime(this.audio.currentTime);
|
||||
this.trigger('playing');
|
||||
}, 100);
|
||||
this.trigger('play');
|
||||
}
|
||||
});
|
||||
|
||||
this.audio.addEventListener('pause', () => {
|
||||
if (this.button && (this.button.classList.contains('aplayer-pause') || this.ended)) {
|
||||
this.ended = false;
|
||||
this.button.classList.remove('aplayer-pause');
|
||||
this.button.classList.add('aplayer-play');
|
||||
this.button.innerHTML = '';
|
||||
setTimeout(() => {
|
||||
this.button.innerHTML = `
|
||||
<button type="button" class="aplayer-icon aplayer-icon-play">`
|
||||
+ this.getSVG('play')
|
||||
+ ` </button>`;
|
||||
}, 100);
|
||||
clearInterval(this.playedTime);
|
||||
this.trigger('pause');
|
||||
}
|
||||
});
|
||||
|
||||
// show audio time: the metadata has loaded or changed
|
||||
this.audio.addEventListener('durationchange', () => {
|
||||
if (this.audio.duration !== 1) { // compatibility: Android browsers will output 1 at first
|
||||
@@ -482,8 +551,8 @@ class APlayer {
|
||||
|
||||
// multiple music play
|
||||
this.ended = false;
|
||||
if (this.multiple) {
|
||||
this.audio.addEventListener('ended', () => {
|
||||
this.audio.addEventListener('ended', () => {
|
||||
if (this.multiple) {
|
||||
if (this.isMobile) {
|
||||
this.ended = true;
|
||||
this.pause();
|
||||
@@ -491,12 +560,7 @@ class APlayer {
|
||||
}
|
||||
if (this.audio.currentTime !== 0) {
|
||||
if (this.mode === 'random') {
|
||||
let random = parseInt(Math.random() * this.option.music.length);
|
||||
if (random === this.playIndex) {
|
||||
random++;
|
||||
random = random % this.option.music.length;
|
||||
}
|
||||
this.setMusic(random);
|
||||
this.setMusic(this.nextRandomNum());
|
||||
}
|
||||
else if (this.mode === 'single') {
|
||||
this.setMusic(this.playIndex);
|
||||
@@ -520,17 +584,15 @@ class APlayer {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.audio.addEventListener('ended', () => {
|
||||
}
|
||||
else {
|
||||
if (this.mode === 'order') {
|
||||
this.ended = true;
|
||||
this.pause();
|
||||
this.trigger('ended');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// control volume
|
||||
this.audio.volume = parseInt(this.element.getElementsByClassName('aplayer-volume')[0].style.height) / 100;
|
||||
@@ -538,9 +600,7 @@ class APlayer {
|
||||
// loop
|
||||
this.audio.loop = !(this.multiple || this.mode === 'order');
|
||||
|
||||
if (this.multiple) {
|
||||
this.audios[indexMusic] = this.audio;
|
||||
}
|
||||
this.audios[indexMusic] = this.audio;
|
||||
}
|
||||
else {
|
||||
this.audio = this.audios[indexMusic];
|
||||
@@ -585,17 +645,12 @@ class APlayer {
|
||||
|
||||
// fill in lrc
|
||||
if (this.option.showlrc) {
|
||||
const index = this.multiple ? indexMusic : 0;
|
||||
const index = indexMusic;
|
||||
|
||||
if (!this.lrcs[index]) {
|
||||
let lrcs = '';
|
||||
if (this.option.showlrc === 1) {
|
||||
if (this.multiple) {
|
||||
lrcs = this.option.music[index].lrc;
|
||||
}
|
||||
else {
|
||||
lrcs = this.option.music.lrc;
|
||||
}
|
||||
lrcs = this.option.music[index].lrc;
|
||||
}
|
||||
else if (this.option.showlrc === 2 || this.option.showlrc === true) {
|
||||
lrcs = this.savelrc[index];
|
||||
@@ -607,32 +662,28 @@ class APlayer {
|
||||
if (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) {
|
||||
lrcs = xhr.responseText;
|
||||
this.lrcs[index] = parseLrc(lrcs);
|
||||
this.lrc = this.lrcs[index];
|
||||
let lrcHTML = '';
|
||||
this.lrcContents = this.element.getElementsByClassName('aplayer-lrc-contents')[0];
|
||||
for (let i = 0; i < this.lrc.length; i++) {
|
||||
lrcHTML += `<p>${this.lrc[i][1]}</p>`;
|
||||
}
|
||||
this.lrcContents.innerHTML = lrcHTML;
|
||||
if (!this.lrcIndex) {
|
||||
this.lrcIndex = 0;
|
||||
}
|
||||
this.lrcContents.getElementsByTagName('p')[0].classList.add('aplayer-lrc-current');
|
||||
this.lrcContents.style.transform = 'translateY(0px)';
|
||||
this.lrcContents.style.webkitTransform = 'translateY(0px)';
|
||||
}
|
||||
else {
|
||||
console.log('Request was unsuccessful: ' + xhr.status);
|
||||
this.lrcs[index] = [['00:00', 'Not available']];
|
||||
}
|
||||
this.lrc = this.lrcs[index];
|
||||
let lrcHTML = '';
|
||||
this.lrcContents = this.element.getElementsByClassName('aplayer-lrc-contents')[0];
|
||||
for (let i = 0; i < this.lrc.length; i++) {
|
||||
lrcHTML += `<p>${this.lrc[i][1]}</p>`;
|
||||
}
|
||||
this.lrcContents.innerHTML = lrcHTML;
|
||||
if (!this.lrcIndex) {
|
||||
this.lrcIndex = 0;
|
||||
}
|
||||
this.lrcContents.getElementsByTagName('p')[0].classList.add('aplayer-lrc-current');
|
||||
this.lrcContents.style.transform = 'translateY(0px)';
|
||||
this.lrcContents.style.webkitTransform = 'translateY(0px)';
|
||||
}
|
||||
};
|
||||
let apiurl;
|
||||
if (this.multiple) {
|
||||
apiurl = this.option.music[index].lrc;
|
||||
}
|
||||
else {
|
||||
apiurl = this.option.music.lrc;
|
||||
}
|
||||
apiurl = this.option.music[index].lrc;
|
||||
xhr.open('get', apiurl, true);
|
||||
xhr.send(null);
|
||||
}
|
||||
@@ -640,7 +691,12 @@ class APlayer {
|
||||
this.lrcs[index] = parseLrc(lrcs);
|
||||
}
|
||||
else {
|
||||
this.lrcs[index] = [['00:00', 'Loading']];
|
||||
if (this.option.showlrc === 3) {
|
||||
this.lrcs[index] = [['00:00', 'Loading']];
|
||||
}
|
||||
else {
|
||||
this.lrcs[index] = [['00:00', 'Not available']];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -683,37 +739,7 @@ class APlayer {
|
||||
this.audio.currentTime = time;
|
||||
}
|
||||
if (this.audio.paused) {
|
||||
this.button.classList.remove('aplayer-play');
|
||||
this.button.classList.add('aplayer-pause');
|
||||
this.button.innerHTML = '';
|
||||
setTimeout(() => {
|
||||
this.button.innerHTML = `
|
||||
<button class="aplayer-icon aplayer-icon-pause">`
|
||||
+ this.getSVG('pause')
|
||||
+ ` </button>`;
|
||||
}, 100);
|
||||
|
||||
// pause other players (Thanks @Aprikyblue)
|
||||
if (this.option.mutex) {
|
||||
for (let i = 0; i < instances.length; i++) {
|
||||
if (this != instances[i]) {
|
||||
instances[i].pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
this.audio.play();
|
||||
if (this.playedTime) {
|
||||
clearInterval(this.playedTime);
|
||||
}
|
||||
this.playedTime = setInterval(() => {
|
||||
this.updateBar('played', this.audio.currentTime / this.audio.duration, 'width');
|
||||
if (this.option.showlrc) {
|
||||
this.updateLrc();
|
||||
}
|
||||
this.ptime.innerHTML = this.secondToTime(this.audio.currentTime);
|
||||
this.trigger('playing');
|
||||
}, 100);
|
||||
this.trigger('play');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -721,20 +747,8 @@ class APlayer {
|
||||
* Pause music
|
||||
*/
|
||||
pause() {
|
||||
if (!this.audio.paused || this.ended) {
|
||||
this.ended = false;
|
||||
this.button.classList.remove('aplayer-pause');
|
||||
this.button.classList.add('aplayer-play');
|
||||
this.button.innerHTML = '';
|
||||
setTimeout(() => {
|
||||
this.button.innerHTML = `
|
||||
<button class="aplayer-icon aplayer-icon-play">`
|
||||
+ this.getSVG('play')
|
||||
+ ` </button>`;
|
||||
}, 100);
|
||||
if (!this.audio.paused) {
|
||||
this.audio.pause();
|
||||
clearInterval(this.playedTime);
|
||||
this.trigger('pause');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -770,13 +784,108 @@ class APlayer {
|
||||
* toggle between play and pause
|
||||
*/
|
||||
toggle() {
|
||||
if (this.audio.paused) {
|
||||
if (this.button.classList.contains('aplayer-play')) {
|
||||
this.play();
|
||||
}
|
||||
else {
|
||||
else if (this.button.classList.contains('aplayer-pause')) {
|
||||
this.pause();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get random order, using Fisher–Yates shuffle
|
||||
*/
|
||||
getRandomOrder() {
|
||||
function random(min, max) {
|
||||
if (max == null) {
|
||||
max = min;
|
||||
min = 0;
|
||||
}
|
||||
return min + Math.floor(Math.random() * (max - min + 1));
|
||||
}
|
||||
function shuffle(arr) {
|
||||
var length = arr.length,
|
||||
shuffled = new Array(length);
|
||||
for (var index = 0, rand; index < length; index++) {
|
||||
rand = random(0, index);
|
||||
if (rand !== index) shuffled[index] = shuffled[rand];
|
||||
shuffled[rand] = arr[index];
|
||||
}
|
||||
return shuffled;
|
||||
}
|
||||
if (this.multiple) {
|
||||
this.randomOrder = shuffle([...Array(this.option.music.length)].map(function(item, i) {
|
||||
return i;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get next random number
|
||||
*/
|
||||
nextRandomNum() {
|
||||
if (this.multiple) {
|
||||
let index = this.randomOrder.indexOf(this.playIndex);
|
||||
if (index === this.randomOrder.length - 1) {
|
||||
return this.randomOrder[0];
|
||||
}
|
||||
else {
|
||||
return this.randomOrder[index + 1];
|
||||
}
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* destroy this player
|
||||
*/
|
||||
destroy() {
|
||||
instances.splice(instances.indexOf(this), 1);
|
||||
this.pause();
|
||||
this.element.innerHTML = '';
|
||||
clearInterval(this.playedTime);
|
||||
for (let key in this) {
|
||||
if (this.hasOwnProperty(key)) {
|
||||
delete this[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* add music dynamically
|
||||
*
|
||||
* @param {Array} newMusic
|
||||
*/
|
||||
addMusic(newMusic) {
|
||||
this.option.music = this.option.music.concat(newMusic);
|
||||
|
||||
const list = this.element.getElementsByClassName('aplayer-list')[0];
|
||||
const listEle = list.getElementsByTagName('ol')[0];
|
||||
let newItemHTML = ``;
|
||||
for (let i = 0; i < newMusic.length; i++) {
|
||||
newItemHTML += `
|
||||
<li>
|
||||
<span class="aplayer-list-cur" style="background: ${this.option.theme};"></span>
|
||||
<span class="aplayer-list-index">${this.option.music.length - newMusic.length + i + 1}</span>
|
||||
<span class="aplayer-list-title">${newMusic[i].title}</span>
|
||||
<span class="aplayer-list-author">${newMusic[i].author}</span>
|
||||
</li>`
|
||||
}
|
||||
listEle.innerHTML += newItemHTML;
|
||||
|
||||
if (!this.multiple) {
|
||||
this.multiple = true;
|
||||
this.element.classList.add('aplayer-withlist');
|
||||
this.audio.loop = false;
|
||||
}
|
||||
|
||||
list.style.height = 'auto';
|
||||
list.style.height = list.offsetHeight + 'px';
|
||||
|
||||
this.getRandomOrder();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = APlayer;
|
||||
+20
-3
@@ -34,11 +34,19 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height - 6;
|
||||
}
|
||||
}
|
||||
|
||||
.aplayer-list {
|
||||
.aplayer-withlist {
|
||||
&.aplayer {
|
||||
.aplayer-info {
|
||||
border-bottom: 1px solid #e9e9e9;
|
||||
}
|
||||
|
||||
.aplayer-list {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.aplayer-icon-menu {
|
||||
display: inline !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +73,9 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height - 6;
|
||||
opacity: .8;
|
||||
vertical-align: middle;
|
||||
padding: 0;
|
||||
font-size: 12px;
|
||||
margin: 0;
|
||||
display: inline;
|
||||
|
||||
.aplayer-fill {
|
||||
transition: all .2s ease-in-out;
|
||||
@@ -148,7 +159,7 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height - 6;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
margin-bottom: 13px;
|
||||
margin: 0 0 13px 5px;
|
||||
user-select: text;
|
||||
cursor: default;
|
||||
padding-bottom: 2px;
|
||||
@@ -242,6 +253,10 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height - 6;
|
||||
fill: #000;
|
||||
}
|
||||
}
|
||||
|
||||
&.aplayer-icon-menu {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
&.aplayer-time-narrow {
|
||||
@@ -299,7 +314,6 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height - 6;
|
||||
display: none;
|
||||
position: relative;
|
||||
height: $lrc-height;
|
||||
background: #fff;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
margin: -10px 0 7px;
|
||||
@@ -347,6 +361,8 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height - 6;
|
||||
|
||||
&.aplayer-lrc-current {
|
||||
opacity: 1;
|
||||
overflow: visible;
|
||||
height: initial !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -362,6 +378,7 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height - 6;
|
||||
overflow: auto;
|
||||
transition: all 0.5s ease;
|
||||
will-change: height;
|
||||
display: none;
|
||||
|
||||
&.aplayer-list-hide {
|
||||
height: 0 !important;
|
||||
|
||||
+27
-23
@@ -2,60 +2,64 @@ var webpack = require('webpack');
|
||||
var path = require('path');
|
||||
var autoprefixer = require('autoprefixer');
|
||||
|
||||
var libraryName = 'APlayer';
|
||||
var env = process.env.WEBPACK_ENV;
|
||||
var ROOT_PATH = path.resolve(__dirname);
|
||||
var APP_PATH = path.resolve(ROOT_PATH, 'src');
|
||||
var BUILD_PATH = path.resolve(ROOT_PATH, 'dist');
|
||||
|
||||
module.exports = {
|
||||
devtool: 'source-map',
|
||||
var plugins = [];
|
||||
if (env !== 'dev') {
|
||||
plugins.push(
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
sourceMap: true
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
entry: './src/APlayer.js',
|
||||
module.exports = {
|
||||
entry: './src/' + libraryName + '.js',
|
||||
|
||||
output: {
|
||||
path: BUILD_PATH,
|
||||
filename: 'APlayer.min.js',
|
||||
library: 'APlayer',
|
||||
filename: libraryName + '.min.js',
|
||||
library: libraryName,
|
||||
libraryTarget: 'umd',
|
||||
umdNamedDefine: true
|
||||
},
|
||||
|
||||
devtool: 'source-map',
|
||||
|
||||
devServer: {
|
||||
publicPath: "/dist/",
|
||||
},
|
||||
|
||||
module: {
|
||||
loaders: [
|
||||
rules: [
|
||||
{
|
||||
test: /\.js$/,
|
||||
loader: 'babel',
|
||||
loader: 'babel-loader',
|
||||
include: APP_PATH,
|
||||
query: {
|
||||
options: {
|
||||
presets: ['es2015']
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.scss$/,
|
||||
loaders: ['style', 'css', 'postcss', 'sass'],
|
||||
use: [
|
||||
'style-loader',
|
||||
'css-loader',
|
||||
'postcss-loader',
|
||||
'sass-loader'
|
||||
],
|
||||
include: APP_PATH
|
||||
},
|
||||
{
|
||||
test: /\.(png|jpg)$/,
|
||||
loader: 'url?limit=40000'
|
||||
loader: 'url-loader?limit=40000'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
plugins: [
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
compress: {
|
||||
warnings: false
|
||||
}
|
||||
})
|
||||
],
|
||||
|
||||
postcss: [
|
||||
autoprefixer({
|
||||
browsers: ['last 15 versions', '> 1%', 'ie 8', 'ie 7']
|
||||
})
|
||||
]
|
||||
plugins: plugins
|
||||
};
|
||||
Reference in New Issue
Block a user