Compare commits
@@ -0,0 +1,3 @@
|
|||||||
|
dist
|
||||||
|
demo
|
||||||
|
docs
|
||||||
@@ -1,15 +1,16 @@
|
|||||||
{
|
{
|
||||||
"extends": "eslint:recommended",
|
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
|
||||||
|
"plugins": ["prettier"],
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": 6,
|
"ecmaVersion": 2018,
|
||||||
"sourceType": "module"
|
"sourceType": "module"
|
||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"browser": true
|
"es6": true,
|
||||||
|
"browser": true,
|
||||||
|
"node": true,
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-console": 0,
|
|
||||||
"no-extra-parens": 1,
|
|
||||||
"block-scoped-var": 1,
|
"block-scoped-var": 1,
|
||||||
"curly": 1,
|
"curly": 1,
|
||||||
"eqeqeq": 1,
|
"eqeqeq": 1,
|
||||||
@@ -20,10 +21,8 @@
|
|||||||
"comma-spacing": 1,
|
"comma-spacing": 1,
|
||||||
"comma-style": 1,
|
"comma-style": 1,
|
||||||
"func-call-spacing": 1,
|
"func-call-spacing": 1,
|
||||||
"indent": 1,
|
|
||||||
"keyword-spacing": 1,
|
"keyword-spacing": 1,
|
||||||
"linebreak-style": 1,
|
"linebreak-style": 1,
|
||||||
"lines-around-comment": 1,
|
|
||||||
"no-multiple-empty-lines": 1,
|
"no-multiple-empty-lines": 1,
|
||||||
"space-infix-ops": 1,
|
"space-infix-ops": 1,
|
||||||
"arrow-spacing": 1,
|
"arrow-spacing": 1,
|
||||||
@@ -31,14 +30,12 @@
|
|||||||
"prefer-const": 1,
|
"prefer-const": 1,
|
||||||
"no-unsafe-negation": 1,
|
"no-unsafe-negation": 1,
|
||||||
"array-callback-return": 1,
|
"array-callback-return": 1,
|
||||||
"dot-location": 1,
|
|
||||||
"dot-notation": 1,
|
"dot-notation": 1,
|
||||||
"no-eval": 1,
|
"no-eval": 1,
|
||||||
"no-extend-native": 1,
|
"no-extend-native": 1,
|
||||||
"no-extra-label": 1,
|
"no-extra-label": 1,
|
||||||
"semi": 1,
|
"semi": 1,
|
||||||
"space-before-blocks": 1,
|
"space-before-blocks": 1,
|
||||||
"space-before-function-paren": 1,
|
|
||||||
"space-in-parens": 1,
|
"space-in-parens": 1,
|
||||||
"space-unary-ops": 1,
|
"space-unary-ops": 1,
|
||||||
"spaced-comment": 1,
|
"spaced-comment": 1,
|
||||||
@@ -49,13 +46,11 @@
|
|||||||
"no-useless-computed-key": 1,
|
"no-useless-computed-key": 1,
|
||||||
"no-useless-rename": 1,
|
"no-useless-rename": 1,
|
||||||
"rest-spread-spacing": 1,
|
"rest-spread-spacing": 1,
|
||||||
"no-trailing-spaces": 1
|
"no-trailing-spaces": 1,
|
||||||
},
|
"no-control-regex": 0,
|
||||||
"globals": {
|
"prettier/prettier": 0,
|
||||||
"require": false,
|
"no-await-in-loop": 1,
|
||||||
"module": false,
|
"require-atomic-updates": 0,
|
||||||
"Hls": false,
|
"no-prototype-builtins": 0
|
||||||
"flvjs": false,
|
|
||||||
"dashjs": false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
If you want to report a bug, please provide the following information:
|
If you want to report a bug, please provide the following information:
|
||||||
|
|
||||||
- The steps to reproduce.
|
- The steps to reproduce.
|
||||||
- A minimal demo of the problem via https://jsfiddle.net or http://codepen.io/pen if possible.
|
- 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?
|
- Which versions of APlayer, and which browser / OS are affected by this issue?
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
dist
|
||||||
|
demo
|
||||||
|
docs
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"printWidth": 233,
|
||||||
|
"tabWidth": 4,
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "es5",
|
||||||
|
"arrowParens": "always"
|
||||||
|
}
|
||||||
+4
-1
@@ -1,7 +1,10 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
|
|
||||||
node_js:
|
node_js:
|
||||||
- "node"
|
- lts/*
|
||||||
|
|
||||||
|
script:
|
||||||
|
- npm run build
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
yarn: true
|
yarn: true
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://ws4.sinaimg.cn/large/006tKfTcgy1fhu01y9uy7j305k04s3yc.jpg" alt="ADPlayer" width="100">
|
<img src="https://i.imgur.com/LnPvZvO.png" alt="ADPlayer" width="100">
|
||||||
</p>
|
</p>
|
||||||
<h1 align="center">APlayer</h1>
|
<h1 align="center">APlayer</h1>
|
||||||
|
|
||||||
@@ -21,13 +21,8 @@ APlayer is a lovely HTML5 music player.
|
|||||||
|
|
||||||
**APlayer supports:**
|
**APlayer supports:**
|
||||||
|
|
||||||
- Media formats
|
- Media formats - MP4 H.264 (AAC or MP3) - WAVE PCM - Ogg Theora Vorbis
|
||||||
- MP4 H.264 (AAC or MP3)
|
- Features - Playlist - Lyrics
|
||||||
- WAVE PCM
|
|
||||||
- Ogg Theora Vorbis
|
|
||||||
- Features
|
|
||||||
- Playlist
|
|
||||||
- Lyrics
|
|
||||||
|
|
||||||
Using APlayer on your project? [Let me know!](https://github.com/MoePlayer/APlayer/issues/79)
|
Using APlayer on your project? [Let me know!](https://github.com/MoePlayer/APlayer/issues/79)
|
||||||
|
|
||||||
@@ -37,73 +32,53 @@ Using APlayer on your project? [Let me know!](https://github.com/MoePlayer/APlay
|
|||||||
|
|
||||||
## Join the Discussion
|
## Join the Discussion
|
||||||
|
|
||||||
- [Telegram Group](https://t.me/adplayer)
|
- [Telegram Group](https://t.me/adplayer)
|
||||||
- [QQ Group](https://shang.qq.com/wpa/qunwpa?idkey=bf22213ae0028a82e5adf3f286dfd4f01e0997dc9f1dcd8e831a0a85e799be17): 415835947
|
- [QQ Group](https://shang.qq.com/wpa/qunwpa?idkey=bf22213ae0028a82e5adf3f286dfd4f01e0997dc9f1dcd8e831a0a85e799be17): 415835947
|
||||||
|
|
||||||
## Related Projects
|
## Related Projects
|
||||||
|
|
||||||
### Plugins
|
### Plugins
|
||||||
|
|
||||||
- [APlayer-Typecho-Plugin](https://github.com/zgq354/APlayer-Typecho-Plugin): Typecho
|
- [APlayer-Typecho-Plugin](https://github.com/zgq354/APlayer-Typecho-Plugin): Typecho
|
||||||
- [hexo-tag-aplayer](https://github.com/grzhan/hexo-tag-aplayer): Hexo
|
- [hexo-tag-aplayer](https://github.com/grzhan/hexo-tag-aplayer): Hexo
|
||||||
- [Hermit-X(APlayer for WordPress)](https://github.com/liwanglin12/Hermit-X): WordPress
|
- [Hermit-X(APlayer for WordPress)](https://github.com/liwanglin12/Hermit-X): WordPress
|
||||||
- [APlayerHandle](https://github.com/kn007/APlayerHandle): WordPress
|
- [APlayerHandle](https://github.com/kn007/APlayerHandle): WordPress
|
||||||
- [APlayer_for_Z-BlogPHP](https://github.com/fghrsh/APlayer_for_Z-BlogPHP): Z-BlogPHP
|
- [APlayer_for_Z-BlogPHP](https://github.com/fghrsh/APlayer_for_Z-BlogPHP): Z-BlogPHP
|
||||||
- [react-aplayer](https://github.com/sabrinaluo/react-aplayer): React
|
- [react-aplayer](https://github.com/sabrinaluo/react-aplayer): React
|
||||||
- [vue-aplayer](https://github.com/SevenOutman/vue-aplayer): Vue
|
- [Vue-APlayer](https://github.com/SevenOutman/vue-aplayer): Vue
|
||||||
- [vue-aplayer](https://github.com/MoeFE/vue-aplayer): Vue
|
- [vue-aplayer](https://github.com/MoeFE/vue-aplayer): Vue
|
||||||
- [php-aplayer](https://github.com/Daryl-L/php-aplayer): PHP
|
- [php-aplayer](https://github.com/Daryl-L/php-aplayer): PHP
|
||||||
|
- [aplayer-hugo-module](https://github.com/Runzelee/aplayer-hugo-module): Hugo
|
||||||
|
|
||||||
### Tooling
|
### Tooling
|
||||||
|
|
||||||
- [APlayer-Controler](https://github.com/Mashiro-Sorata/APlayer-Controler): controling tool
|
- [APlayer-Controler](https://github.com/Mashiro-Sorata/APlayer-Controler): controling tool
|
||||||
- [MetingJS](https://github.com/metowolf/MetingJS): work with Meting music API
|
- [MetingJS](https://github.com/metowolf/MetingJS): work with Meting music API
|
||||||
|
- Feel free to submit yours in [`Let me know!`](https://github.com/MoePlayer/APlayer/issues/79)
|
||||||
|
|
||||||
## Who use APlayer?
|
## Who use APlayer?
|
||||||
|
|
||||||
- [bilibili](https://www.bilibili.com/): 国内知名的视频弹幕网站
|
- [bilibili](https://www.bilibili.com/): 国内知名的视频弹幕网站
|
||||||
- [Jelly Rue](http://jellyrue.com/): Jelly Rue, an indie pop-rock band from Tartu.
|
- [黑客派](https://hacpai.com/): 程序员和设计师的聚集地,一个活跃的小众社区
|
||||||
- [LLSupport](https://www.lovelivesupport.com/): This site provides a lot of information about LoveLive
|
- [浙江大学 CC98 论坛](https://zh.wikipedia.org/wiki/CC98%E8%AE%BA%E5%9D%9B): 浙江大学校网内规模最大的论坛,中国各大学中较活跃的 BBS 之一
|
||||||
- [站长之家](http://www.chinaz.com/15year/index.html): 针对中文站点提供资讯、技术、资源、服务
|
- [Jelly Rue](http://jellyrue.com/): Jelly Rue, an indie pop-rock band from Tartu.
|
||||||
- [歌词千寻](https://www.lrcgc.com/diy): 每日更新的LRC歌词网站
|
- [Opus](http://www.opusopus.co/): An artist-exploration data visualization application
|
||||||
- [iSearch](http://i.oppsu.cn): 一个提供 iTunes 搜索,试听,高清专辑封面获取,查看最新音乐动态等综合性平台
|
- [站长之家](http://www.chinaz.com/15year/index.html): 针对中文站点提供资讯、技术、资源、服务
|
||||||
- [LRC歌词编辑器](https://github.com/MoeFE/Lyric): 一款非常实用的在线LRC歌词编辑器
|
- [LLSupport](https://www.lovelivesupport.com/): This site provides a lot of information about LoveLive
|
||||||
- [Аэростатика](https://aerostatica.ru/)
|
- [歌词千寻](https://www.lrcgc.com/diy): 每日更新的 LRC 歌词网站
|
||||||
|
- [iSearch](http://i.oppsu.cn): 一个提供 iTunes 搜索,试听,高清专辑封面获取,查看最新音乐动态等综合性平台
|
||||||
## Donate
|
- [LRC 歌词编辑器](https://github.com/MoeFE/Lyric): 一款非常实用的在线 LRC 歌词编辑器
|
||||||
|
- [Аэростатика](https://aerostatica.ru/)
|
||||||
APlayer is an MIT licensed open source project and completely free to use. However, the amount of effort needed to maintain and develop new features for the project is not sustainable without proper financial backing.
|
- [HealthDig](https://healthdig.co): 每天只需两分钟的重点新闻资讯
|
||||||
|
- Feel free to submit yours in [`Let me know!`](https://github.com/MoePlayer/APlayer/issues/79)
|
||||||
## One-time Donations
|
|
||||||
|
|
||||||
We accept donations through these channels:
|
|
||||||
|
|
||||||
- [Paypal](https://www.paypal.me/DIYgod)
|
|
||||||
- [WeChat Pay](https://i.imgur.com/aq6PtWa.png)
|
|
||||||
- [Alipay](https://i.imgur.com/wv1Pj2k.png)
|
|
||||||
- Bitcoin: 13CwQLHzPYm2tewNMSJBeArbbRM5NSmCD1
|
|
||||||
|
|
||||||
## Recurring Pledges
|
|
||||||
|
|
||||||
Recurring pledges come with exclusive perks, e.g. having your name or your company logo listed in the APlayer GitHub repository and this website.
|
|
||||||
|
|
||||||
- Become a backer or sponsor via [OpenCollective](https://opencollective.com/aplayer)
|
|
||||||
- E-mail us: i#html.love
|
|
||||||
|
|
||||||
## Current Premium Sponsors
|
## Current Premium Sponsors
|
||||||
|
|
||||||
### Special Sponsors
|
### Special Sponsors
|
||||||
|
|
||||||
<a href="https://pear.hk/" target="_blank">
|
<a href="https://www.dogecloud.com/?ref=dplayer" target="_blank">
|
||||||
<img width="222px" src="https://i.imgur.com/5qQYmfc.png">
|
<img width="222px" src="https://player.dogecloud.com/img/logo_with_product3.png">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://console.upyun.com/register/?invite=BkLZ2Xqob" target="_blank">
|
|
||||||
<img width="222px" src="https://imgur.com/apG1uKf.png">
|
|
||||||
</a>
|
|
||||||
|
|
||||||
### OpenCollective backers
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
|
|
||||||
@@ -111,6 +86,27 @@ This project exists thanks to all the people who contribute.
|
|||||||
|
|
||||||
<a href="https://github.com/MoePlayer/APlayer/graphs/contributors"><img src="https://opencollective.com/APlayer/contributors.svg?width=890" /></a>
|
<a href="https://github.com/MoePlayer/APlayer/graphs/contributors"><img src="https://opencollective.com/APlayer/contributors.svg?width=890" /></a>
|
||||||
|
|
||||||
|
## Donate
|
||||||
|
|
||||||
|
APlayer is an MIT licensed open source project and completely free to use. However, the amount of effort needed to maintain and develop new features for the project is not sustainable without proper financial backing.
|
||||||
|
|
||||||
|
You can support APlayer via donations.
|
||||||
|
|
||||||
|
### Recurring Donation
|
||||||
|
|
||||||
|
- Become a Sponser on [GitHub](https://github.com/sponsors/DIYgod)
|
||||||
|
- Become a Sponser on [Patreon](https://www.patreon.com/DIYgod)
|
||||||
|
- Become a Sponser on [爱发电](https://afdian.net/@diygod)
|
||||||
|
- Contact us directly: i@diygod.me
|
||||||
|
|
||||||
|
### One-time Donation
|
||||||
|
|
||||||
|
We accept donations via the following ways:
|
||||||
|
|
||||||
|
- [WeChat Pay](https://diygod.me/images/wx.jpg)
|
||||||
|
- [Alipay](https://diygod.me/images/zfb.jpg)
|
||||||
|
- [Paypal](https://www.paypal.me/DIYgod)
|
||||||
|
|
||||||
## Author
|
## Author
|
||||||
|
|
||||||
**APlayer** © [DIYgod](https://github.com/DIYgod), Released under the [MIT](./LICENSE) License.<br>
|
**APlayer** © [DIYgod](https://github.com/DIYgod), Released under the [MIT](./LICENSE) License.<br>
|
||||||
|
|||||||
+47
-36
@@ -8,8 +8,8 @@ const ap1 = new APlayer({
|
|||||||
audio: [{
|
audio: [{
|
||||||
name: '光るなら',
|
name: '光るなら',
|
||||||
artist: 'Goose house',
|
artist: 'Goose house',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||||
theme: '#ebd0c2'
|
theme: '#ebd0c2'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
@@ -44,9 +44,9 @@ const ap2 = new APlayer({
|
|||||||
audio: [{
|
audio: [{
|
||||||
name: '光るなら',
|
name: '光るなら',
|
||||||
artist: 'Goose house',
|
artist: 'Goose house',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||||
lrc: "https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.lrc",
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.lrc',
|
||||||
theme: '#ebd0c2'
|
theme: '#ebd0c2'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
@@ -60,9 +60,9 @@ const ap3 = new APlayer({
|
|||||||
audio: [{
|
audio: [{
|
||||||
name: '光るなら',
|
name: '光るなら',
|
||||||
artist: 'Goose house',
|
artist: 'Goose house',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||||
lrc: "https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.lrc",
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.lrc',
|
||||||
theme: '#ebd0c2'
|
theme: '#ebd0c2'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
@@ -78,29 +78,29 @@ const ap4 = new APlayer({
|
|||||||
audio: [{
|
audio: [{
|
||||||
name: '光るなら',
|
name: '光るなら',
|
||||||
artist: 'Goose house',
|
artist: 'Goose house',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||||
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.lrc',
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.lrc',
|
||||||
theme: '#ebd0c2'
|
theme: '#ebd0c2'
|
||||||
}, {
|
}, {
|
||||||
name: 'トリカゴ',
|
name: 'トリカゴ',
|
||||||
artist: 'XX:me',
|
artist: 'XX:me',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.jpg',
|
||||||
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.lrc',
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.lrc',
|
||||||
theme: '#46718b'
|
theme: '#46718b'
|
||||||
}, {
|
}, {
|
||||||
name: '前前前世',
|
name: '前前前世',
|
||||||
artist: 'RADWIMPS',
|
artist: 'RADWIMPS',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.jpg',
|
||||||
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.lrc',
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.lrc',
|
||||||
theme: '#505d6b'
|
theme: '#505d6b'
|
||||||
}, {
|
}, {
|
||||||
name: '光るなら(HLS)',
|
name: '光るなら(HLS)',
|
||||||
artist: 'Goose house',
|
artist: 'Goose house',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/hls/hikarunara.m3u8',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hls/hikarunara.m3u8',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||||
theme: '#ebd0c2',
|
theme: '#ebd0c2',
|
||||||
type: 'hls'
|
type: 'hls'
|
||||||
}]
|
}]
|
||||||
@@ -114,33 +114,44 @@ const ap5 = new APlayer({
|
|||||||
mutex: true,
|
mutex: true,
|
||||||
theme: '#e9e9e9',
|
theme: '#e9e9e9',
|
||||||
listFolded: false,
|
listFolded: false,
|
||||||
listMaxHeight: '80px',
|
listMaxHeight: 80,
|
||||||
audio: [{
|
audio: [{
|
||||||
name: '光るなら',
|
name: '光るなら',
|
||||||
artist: 'Goose house',
|
artist: 'Goose house',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||||
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.lrc',
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.lrc',
|
||||||
}, {
|
}, {
|
||||||
name: 'トリカゴ',
|
name: 'トリカゴ',
|
||||||
artist: 'XX:me',
|
artist: 'XX:me',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.jpg',
|
||||||
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.lrc',
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.lrc',
|
||||||
}, {
|
}, {
|
||||||
name: '前前前世',
|
name: '前前前世',
|
||||||
artist: 'RADWIMPS',
|
artist: 'RADWIMPS',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.jpg',
|
||||||
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.lrc',
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.lrc',
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
const colorThief = new ColorThief();
|
const colorThief = new ColorThief();
|
||||||
|
const image = new Image();
|
||||||
|
const xhr = new XMLHttpRequest();
|
||||||
const setTheme = (index) => {
|
const setTheme = (index) => {
|
||||||
if (!ap5.list.audios[index].theme) {
|
if (!ap5.list.audios[index].theme) {
|
||||||
colorThief.getColorAsync(ap5.list.audios[index].cover, function (color) {
|
xhr.onload = function(){
|
||||||
ap5.theme(`rgb(${color[0]}, ${color[1]}, ${color[2]})`, index);
|
let coverUrl = URL.createObjectURL(this.response);
|
||||||
});
|
image.onload = function(){
|
||||||
|
let color = colorThief.getColor(image);
|
||||||
|
ap5.theme(`rgb(${color[0]}, ${color[1]}, ${color[2]})`, index);
|
||||||
|
URL.revokeObjectURL(coverUrl)
|
||||||
|
};
|
||||||
|
image.src = coverUrl;
|
||||||
|
}
|
||||||
|
xhr.open('GET', ap5.list.audios[index].cover, true);
|
||||||
|
xhr.responseType = 'blob';
|
||||||
|
xhr.send();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
setTheme(ap5.list.index);
|
setTheme(ap5.list.index);
|
||||||
@@ -154,8 +165,8 @@ const ap6 = new APlayer({
|
|||||||
audio: [{
|
audio: [{
|
||||||
name: '光るなら(HLS)',
|
name: '光るなら(HLS)',
|
||||||
artist: 'Goose house',
|
artist: 'Goose house',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/hls/hikarunara.m3u8',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hls/hikarunara.m3u8',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||||
theme: '#ebd0c2',
|
theme: '#ebd0c2',
|
||||||
type: 'hls'
|
type: 'hls'
|
||||||
}]
|
}]
|
||||||
@@ -166,8 +177,8 @@ const ap7 = new APlayer({
|
|||||||
audio: [{
|
audio: [{
|
||||||
name: '光るなら(HLS)',
|
name: '光るなら(HLS)',
|
||||||
artist: 'Goose house',
|
artist: 'Goose house',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/hls/hikarunara.m3u8',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hls/hikarunara.m3u8',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||||
theme: '#ebd0c2',
|
theme: '#ebd0c2',
|
||||||
type: 'customHls',
|
type: 'customHls',
|
||||||
}],
|
}],
|
||||||
|
|||||||
+6
-6
@@ -66,20 +66,20 @@
|
|||||||
{
|
{
|
||||||
name: 'あっちゅ~ま青春!',
|
name: 'あっちゅ~ま青春!',
|
||||||
artist: '七森中☆ごらく部',
|
artist: '七森中☆ごらく部',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/yuruyuri.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yuruyuri.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/yuruyuri.jpg'
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yuruyuri.jpg'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'secret base~君がくれたもの~',
|
name: 'secret base~君がくれたもの~',
|
||||||
artist: '茅野愛衣',
|
artist: '茅野愛衣',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/secretbase.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/secretbase.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/secretbase.jpg'
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/secretbase.jpg'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '回レ!雪月花',
|
name: '回レ!雪月花',
|
||||||
artist: '小倉唯',
|
artist: '小倉唯',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/snowmoonflowers.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/snowmoonflowers.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/snowmoonflowers.jpg'
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/snowmoonflowers.jpg'
|
||||||
}
|
}
|
||||||
])">ap.addAudio(...)</button>
|
])">ap.addAudio(...)</button>
|
||||||
<button onclick="ap1.destroy()">ap.destroy()</button>
|
<button onclick="ap1.destroy()">ap.destroy()</button>
|
||||||
|
|||||||
Vendored
+1
-1
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
Vendored
+1
-1
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
+24
-16
@@ -8,11 +8,8 @@ search: english
|
|||||||
|
|
||||||
## Special Sponsors
|
## Special Sponsors
|
||||||
|
|
||||||
<a href="https://pear.hk/" target="_blank">
|
<a href="https://www.dogecloud.com/?ref=dplayer" target="_blank">
|
||||||
<img width="222px" src="https://i.imgur.com/5qQYmfc.png">
|
<img width="222px" src="https://player.dogecloud.com/img/logo_with_product3.png">
|
||||||
</a>
|
|
||||||
<a href="https://www.upyun.com/" target="_blank">
|
|
||||||
<img width="222px" src="https://imgur.com/apG1uKf.png">
|
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
@@ -56,8 +53,8 @@ const ap = new APlayer({
|
|||||||
Work with module bundler:
|
Work with module bundler:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import 'APlayer/dist/APlayer.min.css';
|
import 'aplayer/dist/APlayer.min.css';
|
||||||
import APlayer from 'APlayer';
|
import APlayer from 'aplayer';
|
||||||
|
|
||||||
const ap = new APlayer(options);
|
const ap = new APlayer(options);
|
||||||
```
|
```
|
||||||
@@ -108,7 +105,7 @@ const ap = new APlayer({
|
|||||||
volume: 0.7,
|
volume: 0.7,
|
||||||
mutex: true,
|
mutex: true,
|
||||||
listFolded: false,
|
listFolded: false,
|
||||||
listMaxHeight: '90px',
|
listMaxHeight: 90,
|
||||||
lrcType: 3,
|
lrcType: 3,
|
||||||
audio: [
|
audio: [
|
||||||
{
|
{
|
||||||
@@ -240,7 +237,7 @@ ap.on('ended', function () {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
Video events
|
Audio events
|
||||||
|
|
||||||
- abort
|
- abort
|
||||||
- canplay
|
- canplay
|
||||||
@@ -396,7 +393,7 @@ APlayer will show a playlist when it has more than one audio, option `listFolded
|
|||||||
const ap = new APlayer({
|
const ap = new APlayer({
|
||||||
container: document.getElementById('player'),
|
container: document.getElementById('player'),
|
||||||
listFolded: false,
|
listFolded: false,
|
||||||
listMaxHeight: '90px',
|
listMaxHeight: 90,
|
||||||
lrcType: 3,
|
lrcType: 3,
|
||||||
audio: [
|
audio: [
|
||||||
{
|
{
|
||||||
@@ -555,16 +552,27 @@ const ap = new APlayer({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const colorThief = new ColorThief();
|
const colorThief = new ColorThief();
|
||||||
|
const image = new Image();
|
||||||
|
const xhr = new XMLHttpRequest();
|
||||||
const setTheme = (index) => {
|
const setTheme = (index) => {
|
||||||
if (!ap.list.audios[index].theme) {
|
if (!ap.list.audios[index].theme) {
|
||||||
colorThief.getColorAsync(ap.list.audios[index].cover, function (color) {
|
xhr.onload = function(){
|
||||||
ap.theme(`rgb(${color[0]}, ${color[1]}, ${color[2]})`, index);
|
let coverUrl = URL.createObjectURL(this.response);
|
||||||
});
|
image.onload = function(){
|
||||||
|
let color = colorThief.getColor(image);
|
||||||
|
ap.theme(`rgb(${color[0]}, ${color[1]}, ${color[2]})`, index);
|
||||||
|
URL.revokeObjectURL(coverUrl)
|
||||||
|
};
|
||||||
|
image.src = coverUrl;
|
||||||
|
}
|
||||||
|
xhr.open('GET', ap.list.audios[index].cover, true);
|
||||||
|
xhr.responseType = 'blob';
|
||||||
|
xhr.send();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
setTheme(ap.list.index);
|
setTheme(ap.list.index);
|
||||||
ap.on('listswitch', (data) => {
|
ap.on('listswitch', (index) => {
|
||||||
setTheme(data.index);
|
setTheme(index);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -578,4 +586,4 @@ ap.on('listswitch', (data) => {
|
|||||||
|
|
||||||
### Why can't player autoplay in some mobile browsers?
|
### Why can't player autoplay in some mobile browsers?
|
||||||
|
|
||||||
Most mobile browsers forbid video autoplay, you wont be able to achieve it without hacks.
|
Most mobile browsers forbid audio autoplay, you wont be able to achieve it without hacks.
|
||||||
+77
-68
@@ -47,10 +47,19 @@ docute.init({
|
|||||||
url: 'https://aplayer.js.org'
|
url: 'https://aplayer.js.org'
|
||||||
}),
|
}),
|
||||||
evanyou(),
|
evanyou(),
|
||||||
player()
|
player(),
|
||||||
|
insertUmamiJS('8c8b314e-99d9-4ac4-bee9-0e9826bb2b1c', 'https://umami.diygod.dev/script.js')
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function insertUmamiJS(id, url) {
|
||||||
|
var script = document.createElement('script');
|
||||||
|
script.setAttribute("data-website-id",id);
|
||||||
|
script.src = url;
|
||||||
|
script.async = true;
|
||||||
|
document.head.appendChild(script);
|
||||||
|
}
|
||||||
|
|
||||||
function player () {
|
function player () {
|
||||||
return function (context) {
|
return function (context) {
|
||||||
context.event.on('landing:updated', function () {
|
context.event.on('landing:updated', function () {
|
||||||
@@ -87,23 +96,23 @@ function aplayer1 () {
|
|||||||
audio: [{
|
audio: [{
|
||||||
name: '光るなら',
|
name: '光るなら',
|
||||||
artist: 'Goose house',
|
artist: 'Goose house',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||||
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.lrc',
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.lrc',
|
||||||
theme: '#ebd0c2'
|
theme: '#ebd0c2'
|
||||||
}, {
|
}, {
|
||||||
name: 'トリカゴ',
|
name: 'トリカゴ',
|
||||||
artist: 'XX:me',
|
artist: 'XX:me',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.jpg',
|
||||||
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.lrc',
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.lrc',
|
||||||
theme: '#46718b'
|
theme: '#46718b'
|
||||||
}, {
|
}, {
|
||||||
name: '前前前世',
|
name: '前前前世',
|
||||||
artist: 'RADWIMPS',
|
artist: 'RADWIMPS',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.jpg',
|
||||||
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.lrc',
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.lrc',
|
||||||
theme: '#505d6b'
|
theme: '#505d6b'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
@@ -117,23 +126,23 @@ function aplayer0 () {
|
|||||||
audio: [{
|
audio: [{
|
||||||
name: '前前前世',
|
name: '前前前世',
|
||||||
artist: 'RADWIMPS',
|
artist: 'RADWIMPS',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.jpg',
|
||||||
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.lrc',
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.lrc',
|
||||||
theme: '#505d6b'
|
theme: '#505d6b'
|
||||||
}, {
|
}, {
|
||||||
name: 'トリカゴ',
|
name: 'トリカゴ',
|
||||||
artist: 'XX:me',
|
artist: 'XX:me',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.jpg',
|
||||||
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.lrc',
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.lrc',
|
||||||
theme: '#46718b'
|
theme: '#46718b'
|
||||||
}, {
|
}, {
|
||||||
name: '光るなら',
|
name: '光るなら',
|
||||||
artist: 'Goose house',
|
artist: 'Goose house',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||||
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.lrc',
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.lrc',
|
||||||
theme: '#ebd0c2'
|
theme: '#ebd0c2'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
@@ -145,8 +154,8 @@ function aplayer2 () {
|
|||||||
audio: [{
|
audio: [{
|
||||||
name: '光るなら',
|
name: '光るなら',
|
||||||
artist: 'Goose house',
|
artist: 'Goose house',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||||
theme: '#ebd0c2'
|
theme: '#ebd0c2'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
@@ -163,28 +172,28 @@ function aplayer3 () {
|
|||||||
volume: 0.7,
|
volume: 0.7,
|
||||||
mutex: true,
|
mutex: true,
|
||||||
listFolded: false,
|
listFolded: false,
|
||||||
listMaxHeight: '90px',
|
listMaxHeight: 90,
|
||||||
lrcType: 3,
|
lrcType: 3,
|
||||||
audio: [{
|
audio: [{
|
||||||
name: '光るなら',
|
name: '光るなら',
|
||||||
artist: 'Goose house',
|
artist: 'Goose house',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||||
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.lrc',
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.lrc',
|
||||||
theme: '#ebd0c2'
|
theme: '#ebd0c2'
|
||||||
}, {
|
}, {
|
||||||
name: 'トリカゴ',
|
name: 'トリカゴ',
|
||||||
artist: 'XX:me',
|
artist: 'XX:me',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.jpg',
|
||||||
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.lrc',
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.lrc',
|
||||||
theme: '#46718b'
|
theme: '#46718b'
|
||||||
}, {
|
}, {
|
||||||
name: '前前前世',
|
name: '前前前世',
|
||||||
artist: 'RADWIMPS',
|
artist: 'RADWIMPS',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.jpg',
|
||||||
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.lrc',
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.lrc',
|
||||||
theme: '#505d6b'
|
theme: '#505d6b'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
@@ -197,9 +206,9 @@ function aplayer4 () {
|
|||||||
audio: [{
|
audio: [{
|
||||||
name: '光るなら',
|
name: '光るなら',
|
||||||
artist: 'Goose house',
|
artist: 'Goose house',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||||
lrc: "https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.lrc",
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.lrc',
|
||||||
theme: '#ebd0c2'
|
theme: '#ebd0c2'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
@@ -212,23 +221,23 @@ function aplayer5 () {
|
|||||||
audio: [{
|
audio: [{
|
||||||
name: '光るなら',
|
name: '光るなら',
|
||||||
artist: 'Goose house',
|
artist: 'Goose house',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||||
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.lrc',
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.lrc',
|
||||||
theme: '#ebd0c2'
|
theme: '#ebd0c2'
|
||||||
}, {
|
}, {
|
||||||
name: 'トリカゴ',
|
name: 'トリカゴ',
|
||||||
artist: 'XX:me',
|
artist: 'XX:me',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.jpg',
|
||||||
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.lrc',
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.lrc',
|
||||||
theme: '#46718b'
|
theme: '#46718b'
|
||||||
}, {
|
}, {
|
||||||
name: '前前前世',
|
name: '前前前世',
|
||||||
artist: 'RADWIMPS',
|
artist: 'RADWIMPS',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.jpg',
|
||||||
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.lrc',
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.lrc',
|
||||||
theme: '#505d6b'
|
theme: '#505d6b'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
@@ -241,8 +250,8 @@ function aplayer6 () {
|
|||||||
audio: [{
|
audio: [{
|
||||||
name: '光るなら',
|
name: '光るなら',
|
||||||
artist: 'Goose house',
|
artist: 'Goose house',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||||
theme: '#ebd0c2'
|
theme: '#ebd0c2'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
@@ -254,27 +263,27 @@ function aplayer7 () {
|
|||||||
audio: [{
|
audio: [{
|
||||||
name: '光るなら(HLS)',
|
name: '光るなら(HLS)',
|
||||||
artist: 'Goose house',
|
artist: 'Goose house',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/hls/hikarunara.m3u8',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hls/hikarunara.m3u8',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||||
theme: '#ebd0c2',
|
theme: '#ebd0c2',
|
||||||
type: 'hls'
|
type: 'hls'
|
||||||
}, {
|
}, {
|
||||||
name: '光るなら',
|
name: '光るなら',
|
||||||
artist: 'Goose house',
|
artist: 'Goose house',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||||
theme: '#ebd0c2'
|
theme: '#ebd0c2'
|
||||||
}, {
|
}, {
|
||||||
name: 'トリカゴ',
|
name: 'トリカゴ',
|
||||||
artist: 'XX:me',
|
artist: 'XX:me',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.jpg',
|
||||||
theme: '#46718b'
|
theme: '#46718b'
|
||||||
}, {
|
}, {
|
||||||
name: '前前前世',
|
name: '前前前世',
|
||||||
artist: 'RADWIMPS',
|
artist: 'RADWIMPS',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.jpg',
|
||||||
theme: '#505d6b'
|
theme: '#505d6b'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
@@ -287,18 +296,18 @@ function aplayer8 () {
|
|||||||
audio: [{
|
audio: [{
|
||||||
name: '光るなら',
|
name: '光るなら',
|
||||||
artist: 'Goose house',
|
artist: 'Goose house',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||||
}, {
|
}, {
|
||||||
name: 'トリカゴ',
|
name: 'トリカゴ',
|
||||||
artist: 'XX:me',
|
artist: 'XX:me',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.jpg',
|
||||||
}, {
|
}, {
|
||||||
name: '前前前世',
|
name: '前前前世',
|
||||||
artist: 'RADWIMPS',
|
artist: 'RADWIMPS',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.jpg',
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -320,23 +329,23 @@ function aplayer9 () {
|
|||||||
audio: [{
|
audio: [{
|
||||||
name: '光るなら',
|
name: '光るなら',
|
||||||
artist: 'Goose house',
|
artist: 'Goose house',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||||
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/hikarunara.lrc',
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.lrc',
|
||||||
theme: '#ebd0c2'
|
theme: '#ebd0c2'
|
||||||
}, {
|
}, {
|
||||||
name: 'トリカゴ',
|
name: 'トリカゴ',
|
||||||
artist: 'XX:me',
|
artist: 'XX:me',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.jpg',
|
||||||
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/darling.lrc',
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.lrc',
|
||||||
theme: '#46718b'
|
theme: '#46718b'
|
||||||
}, {
|
}, {
|
||||||
name: '前前前世',
|
name: '前前前世',
|
||||||
artist: 'RADWIMPS',
|
artist: 'RADWIMPS',
|
||||||
url: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.mp3',
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.mp3',
|
||||||
cover: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.jpg',
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.jpg',
|
||||||
lrc: 'https://moeplayer.b0.upaiyun.com/aplayer/yourname.lrc',
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.lrc',
|
||||||
theme: '#505d6b'
|
theme: '#505d6b'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
|||||||
+8
-3
@@ -27,9 +27,10 @@ Let's make APlayer better, feel free to submit yours in [`Let me know!`](https:/
|
|||||||
- [APlayerHandle](https://github.com/kn007/APlayerHandle): WordPress
|
- [APlayerHandle](https://github.com/kn007/APlayerHandle): WordPress
|
||||||
- [APlayer_for_Z-BlogPHP](https://github.com/fghrsh/APlayer_for_Z-BlogPHP): Z-BlogPHP
|
- [APlayer_for_Z-BlogPHP](https://github.com/fghrsh/APlayer_for_Z-BlogPHP): Z-BlogPHP
|
||||||
- [react-aplayer](https://github.com/sabrinaluo/react-aplayer): React
|
- [react-aplayer](https://github.com/sabrinaluo/react-aplayer): React
|
||||||
- [vue-aplayer](https://github.com/SevenOutman/vue-aplayer): Vue
|
- [Vue-APlayer](https://github.com/SevenOutman/vue-aplayer): Vue
|
||||||
- [vue-aplayer](https://github.com/MoeFE/vue-aplayer): Vue
|
- [vue-aplayer](https://github.com/MoeFE/vue-aplayer): Vue
|
||||||
- [php-aplayer](https://github.com/Daryl-L/php-aplayer): PHP
|
- [php-aplayer](https://github.com/Daryl-L/php-aplayer): PHP
|
||||||
|
- [aplayer-hugo-module](https://github.com/Runzelee/aplayer-hugo-module): Hugo
|
||||||
|
|
||||||
### Tooling
|
### Tooling
|
||||||
|
|
||||||
@@ -39,10 +40,14 @@ Let's make APlayer better, feel free to submit yours in [`Let me know!`](https:/
|
|||||||
## Who use APlayer?
|
## Who use APlayer?
|
||||||
|
|
||||||
- [bilibili](https://www.bilibili.com/): 国内知名的视频弹幕网站
|
- [bilibili](https://www.bilibili.com/): 国内知名的视频弹幕网站
|
||||||
|
- [黑客派](https://hacpai.com/): 程序员和设计师的聚集地,一个活跃的小众社区
|
||||||
|
- [浙江大学CC98论坛](https://zh.wikipedia.org/wiki/CC98%E8%AE%BA%E5%9D%9B): 浙江大学校网内规模最大的论坛,中国各大学中较活跃的BBS之一
|
||||||
- [Jelly Rue](http://jellyrue.com/): Jelly Rue, an indie pop-rock band from Tartu.
|
- [Jelly Rue](http://jellyrue.com/): Jelly Rue, an indie pop-rock band from Tartu.
|
||||||
- [LLSupport](https://www.lovelivesupport.com/): This site provides a lot of information about LoveLive
|
- [Opus](http://www.opusopus.co/): An artist-exploration data visualization application
|
||||||
- [站长之家](http://www.chinaz.com/15year/index.html): 针对中文站点提供资讯、技术、资源、服务
|
- [站长之家](http://www.chinaz.com/15year/index.html): 针对中文站点提供资讯、技术、资源、服务
|
||||||
|
- [LLSupport](https://www.lovelivesupport.com/): This site provides a lot of information about LoveLive
|
||||||
- [歌词千寻](https://www.lrcgc.com/diy): 每日更新的LRC歌词网站
|
- [歌词千寻](https://www.lrcgc.com/diy): 每日更新的LRC歌词网站
|
||||||
- [iSearch](http://i.oppsu.cn): 一个提供 iTunes 搜索,试听,高清专辑封面获取,查看最新音乐动态等综合性平台
|
- [iSearch](http://i.oppsu.cn): 一个提供 iTunes 搜索,试听,高清专辑封面获取,查看最新音乐动态等综合性平台
|
||||||
- [LRC歌词编辑器](https://github.com/MoeFE/Lyric): 一款非常实用的在线LRC歌词编辑器
|
- [LRC歌词编辑器](https://github.com/MoeFE/Lyric): 一款非常实用的在线LRC歌词编辑器
|
||||||
- [Аэростатика](https://aerostatica.ru/)
|
- [Аэростатика](https://aerostatica.ru/)
|
||||||
|
- [HealthDig](https://healthdig.co): 每天只需两分钟的重点新闻资讯
|
||||||
+4
-4
@@ -5,8 +5,8 @@
|
|||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" />
|
||||||
<title>APlayer</title>
|
<title>APlayer</title>
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docute/dist/docute.css">
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docute@3.4.12/dist/docute.css">
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docute/dist/theme-github.css" />
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docute@3.4.12/dist/theme-github.css" />
|
||||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||||
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-48084758-8"></script>
|
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-48084758-8"></script>
|
||||||
<script>
|
<script>
|
||||||
@@ -39,9 +39,9 @@
|
|||||||
<body>
|
<body>
|
||||||
<!-- don't remove this part start -->
|
<!-- don't remove this part start -->
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/docute/plugins/docsearch.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/docute@3.4.12/plugins/docsearch.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/docute-evanyou/dist/evanyou.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/docute-evanyou/dist/evanyou.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/docute/dist/docute.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/docute@3.4.12/dist/docute.js"></script>
|
||||||
<script src="./config.js"></script>
|
<script src="./config.js"></script>
|
||||||
<!-- livereload script placeholder -->
|
<!-- livereload script placeholder -->
|
||||||
<!-- don't remove this part end -->
|
<!-- don't remove this part end -->
|
||||||
|
|||||||
+13
-21
@@ -10,38 +10,30 @@ If you run a business and are using APlayer in a revenue-generating product, it
|
|||||||
|
|
||||||
If you are an individual user and have enjoyed the productivity of using APlayer, consider donating as a sign of appreciation - like buying me coffee once in a while :)
|
If you are an individual user and have enjoyed the productivity of using APlayer, consider donating as a sign of appreciation - like buying me coffee once in a while :)
|
||||||
|
|
||||||
You can support APlayer development via the following methods:
|
You can support APlayer via donations.
|
||||||
|
|
||||||
## One-time Donations
|
### Recurring Donation
|
||||||
|
|
||||||
We accept donations through these channels:
|
- Become a Sponser on [GitHub](https://github.com/sponsors/DIYgod)
|
||||||
|
- Become a Sponser on [Patreon](https://www.patreon.com/DIYgod)
|
||||||
|
- Become a Sponser on [爱发电](https://afdian.net/@diygod)
|
||||||
|
- Contact us directly: i@diygod.me
|
||||||
|
|
||||||
- [Paypal](https://www.paypal.me/DIYgod)
|
### One-time Donation
|
||||||
- [WeChat Pay](https://i.imgur.com/aq6PtWa.png)
|
|
||||||
- [Alipay](https://i.imgur.com/wv1Pj2k.png)
|
|
||||||
- Bitcoin: 13CwQLHzPYm2tewNMSJBeArbbRM5NSmCD1
|
|
||||||
|
|
||||||
## Recurring Pledges
|
We accept donations via the following ways:
|
||||||
|
|
||||||
Recurring pledges come with exclusive perks, e.g. having your name or your company logo listed in the APlayer GitHub repository and this website.
|
- [WeChat Pay](https://diygod.me/images/wx.jpg)
|
||||||
|
- [Alipay](https://diygod.me/images/zfb.jpg)
|
||||||
- Become a backer or sponsor via [OpenCollective](https://opencollective.com/aplayer)
|
- [Paypal](https://www.paypal.me/DIYgod)
|
||||||
- E-mail us: i#html.love
|
|
||||||
|
|
||||||
## Current Premium Sponsors
|
## Current Premium Sponsors
|
||||||
|
|
||||||
### Special Sponsors
|
### Special Sponsors
|
||||||
|
|
||||||
<a href="https://pear.hk/" target="_blank">
|
<a href="https://www.dogecloud.com/?ref=dplayer" target="_blank">
|
||||||
<img width="222px" src="https://i.imgur.com/5qQYmfc.png">
|
<img width="222px" src="https://player.dogecloud.com/img/logo_with_product3.png">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://console.upyun.com/register/?invite=BkLZ2Xqob" target="_blank">
|
|
||||||
<img width="222px" src="https://imgur.com/apG1uKf.png">
|
|
||||||
</a>
|
|
||||||
|
|
||||||
### OpenCollective backers
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## APlayer contributors
|
## APlayer contributors
|
||||||
|
|
||||||
|
|||||||
+21
-13
@@ -9,11 +9,8 @@ search: zh-Hans
|
|||||||
|
|
||||||
## 特别赞助商
|
## 特别赞助商
|
||||||
|
|
||||||
<a href="https://pear.hk/" target="_blank">
|
<a href="https://www.dogecloud.com/?ref=dplayer" target="_blank">
|
||||||
<img width="222px" src="https://i.imgur.com/5qQYmfc.png">
|
<img width="222px" src="https://player.dogecloud.com/img/logo_with_product3.png">
|
||||||
</a>
|
|
||||||
<a href="https://console.upyun.com/register/?invite=BkLZ2Xqob" target="_blank">
|
|
||||||
<img width="222px" src="https://imgur.com/apG1uKf.png">
|
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
## 安装
|
## 安装
|
||||||
@@ -109,7 +106,7 @@ const ap = new APlayer({
|
|||||||
volume: 0.7,
|
volume: 0.7,
|
||||||
mutex: true,
|
mutex: true,
|
||||||
listFolded: false,
|
listFolded: false,
|
||||||
listMaxHeight: '90px',
|
listMaxHeight: 90,
|
||||||
lrcType: 3,
|
lrcType: 3,
|
||||||
audio: [
|
audio: [
|
||||||
{
|
{
|
||||||
@@ -172,9 +169,9 @@ const ap = new APlayer({
|
|||||||
ap.notice('Amazing player', 2000, 0.8);
|
ap.notice('Amazing player', 2000, 0.8);
|
||||||
```
|
```
|
||||||
|
|
||||||
+ `ap.skipBack()`: 切换到下一首音频
|
+ `ap.skipBack()`: 切换到上一首音频
|
||||||
|
|
||||||
+ `ap.skipForward()`: 切换到上一首音频
|
+ `ap.skipForward()`: 切换到下一首音频
|
||||||
|
|
||||||
+ `ap.destroy()`: 销毁播放器
|
+ `ap.destroy()`: 销毁播放器
|
||||||
|
|
||||||
@@ -221,7 +218,7 @@ const ap = new APlayer({
|
|||||||
|
|
||||||
+ `ap.list.clear()`: 清空播放列表
|
+ `ap.list.clear()`: 清空播放列表
|
||||||
|
|
||||||
+ `ap.audio`: 原生 video
|
+ `ap.audio`: 原生 audio
|
||||||
|
|
||||||
+ `ap.audio.currentTime`: 返回音频当前播放时间
|
+ `ap.audio.currentTime`: 返回音频当前播放时间
|
||||||
|
|
||||||
@@ -397,7 +394,7 @@ const ap = new APlayer({
|
|||||||
const ap = new APlayer({
|
const ap = new APlayer({
|
||||||
container: document.getElementById('player'),
|
container: document.getElementById('player'),
|
||||||
listFolded: false,
|
listFolded: false,
|
||||||
listMaxHeight: '90px',
|
listMaxHeight: 90,
|
||||||
lrcType: 3,
|
lrcType: 3,
|
||||||
audio: [
|
audio: [
|
||||||
{
|
{
|
||||||
@@ -555,11 +552,22 @@ const ap = new APlayer({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const colorThief = new ColorThief();
|
const colorThief = new ColorThief();
|
||||||
|
const image = new Image();
|
||||||
|
const xhr = new XMLHttpRequest();
|
||||||
const setTheme = (index) => {
|
const setTheme = (index) => {
|
||||||
if (!ap.list.audios[index].theme) {
|
if (!ap.list.audios[index].theme) {
|
||||||
colorThief.getColorAsync(ap.list.audios[index].cover, function (color) {
|
xhr.onload = function(){
|
||||||
ap.theme(`rgb(${color[0]}, ${color[1]}, ${color[2]})`, index);
|
let coverUrl = URL.createObjectURL(this.response);
|
||||||
});
|
image.onload = function(){
|
||||||
|
let color = colorThief.getColor(image);
|
||||||
|
ap.theme(`rgb(${color[0]}, ${color[1]}, ${color[2]})`, index);
|
||||||
|
URL.revokeObjectURL(coverUrl)
|
||||||
|
};
|
||||||
|
image.src = coverUrl;
|
||||||
|
}
|
||||||
|
xhr.open('GET', ap.list.audios[index].cover, true);
|
||||||
|
xhr.responseType = 'blob';
|
||||||
|
xhr.send();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
setTheme(ap.list.index);
|
setTheme(ap.list.index);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ search: zh-Hans
|
|||||||
- [APlayerHandle](https://github.com/kn007/APlayerHandle): WordPress
|
- [APlayerHandle](https://github.com/kn007/APlayerHandle): WordPress
|
||||||
- [APlayer_for_Z-BlogPHP](https://github.com/fghrsh/APlayer_for_Z-BlogPHP): Z-BlogPHP
|
- [APlayer_for_Z-BlogPHP](https://github.com/fghrsh/APlayer_for_Z-BlogPHP): Z-BlogPHP
|
||||||
- [react-aplayer](https://github.com/sabrinaluo/react-aplayer): React
|
- [react-aplayer](https://github.com/sabrinaluo/react-aplayer): React
|
||||||
- [vue-aplayer](https://github.com/SevenOutman/vue-aplayer): Vue
|
- [Vue-APlayer](https://github.com/SevenOutman/vue-aplayer): Vue
|
||||||
- [vue-aplayer](https://github.com/MoeFE/vue-aplayer): Vue
|
- [vue-aplayer](https://github.com/MoeFE/vue-aplayer): Vue
|
||||||
- [php-aplayer](https://github.com/Daryl-L/php-aplayer): PHP
|
- [php-aplayer](https://github.com/Daryl-L/php-aplayer): PHP
|
||||||
|
|
||||||
@@ -40,9 +40,12 @@ search: zh-Hans
|
|||||||
## 谁在用 APlayer?
|
## 谁在用 APlayer?
|
||||||
|
|
||||||
- [bilibili](https://www.bilibili.com/): 国内知名的视频弹幕网站
|
- [bilibili](https://www.bilibili.com/): 国内知名的视频弹幕网站
|
||||||
|
- [黑客派](https://hacpai.com/): 程序员和设计师的聚集地,一个活跃的小众社区
|
||||||
|
- [浙江大学CC98论坛](https://zh.wikipedia.org/wiki/CC98%E8%AE%BA%E5%9D%9B): 浙江大学校网内规模最大的论坛,中国各大学中较活跃的BBS之一
|
||||||
- [Jelly Rue](http://jellyrue.com/): Jelly Rue, an indie pop-rock band from Tartu.
|
- [Jelly Rue](http://jellyrue.com/): Jelly Rue, an indie pop-rock band from Tartu.
|
||||||
- [LLSupport](https://www.lovelivesupport.com/): This site provides a lot of information about LoveLive
|
- [Opus](http://www.opusopus.co/): An artist-exploration data visualization application
|
||||||
- [站长之家](http://www.chinaz.com/15year/index.html): 针对中文站点提供资讯、技术、资源、服务
|
- [站长之家](http://www.chinaz.com/15year/index.html): 针对中文站点提供资讯、技术、资源、服务
|
||||||
|
- [LLSupport](https://www.lovelivesupport.com/): This site provides a lot of information about LoveLive
|
||||||
- [歌词千寻](https://www.lrcgc.com/diy): 每日更新的LRC歌词网站
|
- [歌词千寻](https://www.lrcgc.com/diy): 每日更新的LRC歌词网站
|
||||||
- [iSearch](http://i.oppsu.cn): 一个提供 iTunes 搜索,试听,高清专辑封面获取,查看最新音乐动态等综合性平台
|
- [iSearch](http://i.oppsu.cn): 一个提供 iTunes 搜索,试听,高清专辑封面获取,查看最新音乐动态等综合性平台
|
||||||
- [LRC歌词编辑器](https://github.com/MoeFE/Lyric): 一款非常实用的在线LRC歌词编辑器
|
- [LRC歌词编辑器](https://github.com/MoeFE/Lyric): 一款非常实用的在线LRC歌词编辑器
|
||||||
|
|||||||
+14
-22
@@ -11,38 +11,30 @@ APlayer 是采用 MIT 许可的开源项目,使用完全免费。 但是随着
|
|||||||
|
|
||||||
如果你是个人开发者并且享受 APlayer 带来的高开发效率,可以用捐助来表示你的谢意 —— 比如偶尔给我买杯咖啡 :)
|
如果你是个人开发者并且享受 APlayer 带来的高开发效率,可以用捐助来表示你的谢意 —— 比如偶尔给我买杯咖啡 :)
|
||||||
|
|
||||||
你可以通过下列的方法来赞助 APlayer 的开发。
|
你可以通过下列的方法来赞助 APlayer 的开发.
|
||||||
|
|
||||||
## 一次性赞助
|
|
||||||
|
|
||||||
我们通过以下方式接受赞助:
|
|
||||||
|
|
||||||
- [微信支付](https://i.imgur.com/aq6PtWa.png)
|
|
||||||
- [支付宝](https://i.imgur.com/wv1Pj2k.png)
|
|
||||||
- [Paypal](https://www.paypal.me/DIYgod)
|
|
||||||
- 比特币: 13CwQLHzPYm2tewNMSJBeArbbRM5NSmCD1
|
|
||||||
|
|
||||||
## 周期性赞助
|
## 周期性赞助
|
||||||
|
|
||||||
周期性赞助可以获得额外的回报,比如你的名字或你的公司 logo 会出现在 APlayer 的 GitHub 仓库和现在我们的官网中。
|
- 通过 [GitHub](https://github.com/sponsors/DIYgod) 赞助
|
||||||
|
- 通过 [Patreon](https://www.patreon.com/DIYgod) 赞助
|
||||||
|
- 通过 [爱发电](https://afdian.net/@diygod) 赞助
|
||||||
|
- 给我们发邮件联系赞助事宜: <i@diygod.me>
|
||||||
|
|
||||||
- 通过 [OpenCollective](https://opencollective.com/aplayer) 赞助成为 backer 或 sponsor
|
## 一次性赞助
|
||||||
- 给我们发邮件联系赞助事宜: i#html.love
|
|
||||||
|
我们通过以下方式接受赞助:
|
||||||
|
|
||||||
|
- [微信支付](https://diygod.me/images/wx.jpg)
|
||||||
|
- [支付宝](https://diygod.me/images/zfb.jpg)
|
||||||
|
- [Paypal](https://www.paypal.me/DIYgod)
|
||||||
|
|
||||||
## 当前的顶级赞助商
|
## 当前的顶级赞助商
|
||||||
|
|
||||||
### 特别赞助商
|
### 特别赞助商
|
||||||
|
|
||||||
<a href="https://pear.hk/" target="_blank">
|
<a href="https://www.dogecloud.com/?ref=dplayer" target="_blank">
|
||||||
<img width="222px" src="https://i.imgur.com/5qQYmfc.png">
|
<img width="222px" src="https://player.dogecloud.com/img/logo_with_product3.png">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://console.upyun.com/register/?invite=BkLZ2Xqob" target="_blank">
|
|
||||||
<img width="222px" src="https://imgur.com/apG1uKf.png">
|
|
||||||
</a>
|
|
||||||
|
|
||||||
### OpenCollective backers
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## APlayer 贡献者
|
## APlayer 贡献者
|
||||||
|
|
||||||
|
|||||||
+78
-58
@@ -1,60 +1,80 @@
|
|||||||
{
|
{
|
||||||
"name": "aplayer",
|
"name": "aplayer",
|
||||||
"version": "1.10.0",
|
"version": "1.10.1",
|
||||||
"description": "Wow, such a beautiful html5 music player",
|
"description": "Wow, such a beautiful html5 music player",
|
||||||
"main": "dist/APlayer.min.js",
|
"main": "dist/APlayer.min.js",
|
||||||
"style": "dist/APlayer.min.css",
|
"style": "dist/APlayer.min.css",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "npm run dev",
|
"start": "npm run dev",
|
||||||
"build": "cross-env NODE_ENV=production webpack --config webpack/prod.config.js --progress --display-error-details --colors",
|
"build": "cross-env NODE_ENV=production webpack --config webpack/prod.config.js --progress --display-error-details --colors",
|
||||||
"dev": "cross-env NODE_ENV=development webpack-dev-server --config webpack/dev.config.js --watch --colors",
|
"dev": "cross-env NODE_ENV=development webpack-dev-server --config webpack/dev.config.js --watch --colors",
|
||||||
"test": "eslint src webpack"
|
"test": "eslint src webpack",
|
||||||
},
|
"format": "eslint \"**/*.js\" --fix && prettier \"**/*.{js,json,md}\" --write",
|
||||||
"files": [
|
"format:staged": "eslint \"**/*.js\" --fix && pretty-quick --staged --verbose --pattern \"**/*.{js,json,md}\"",
|
||||||
"dist"
|
"format:check": "eslint \"**/*.js\" && prettier-check \"**/*.{js,json,md}\""
|
||||||
],
|
},
|
||||||
"repository": {
|
"files": [
|
||||||
"url": "git+https://github.com/DIYgod/APlayer.git",
|
"dist"
|
||||||
"type": "git"
|
],
|
||||||
},
|
"repository": {
|
||||||
"keywords": [
|
"url": "git+https://github.com/DIYgod/APlayer.git",
|
||||||
"player",
|
"type": "git"
|
||||||
"music",
|
},
|
||||||
"html5"
|
"keywords": [
|
||||||
],
|
"player",
|
||||||
"author": "DIYgod",
|
"music",
|
||||||
"license": "MIT",
|
"html5"
|
||||||
"bugs": {
|
],
|
||||||
"url": "https://github.com/DIYgod/APlayer/issues"
|
"gitHooks": {
|
||||||
},
|
"pre-commit": "npm run format:staged"
|
||||||
"homepage": "https://github.com/DIYgod/APlayer#readme",
|
},
|
||||||
"devDependencies": {
|
"author": "DIYgod",
|
||||||
"art-template": "4.12.2",
|
"license": "MIT",
|
||||||
"art-template-loader": "1.4.3",
|
"bugs": {
|
||||||
"autoprefixer": "^8.1.0",
|
"url": "https://github.com/DIYgod/APlayer/issues"
|
||||||
"babel-core": "^6.26.0",
|
},
|
||||||
"babel-loader": "^7.1.4",
|
"homepage": "https://github.com/DIYgod/APlayer#readme",
|
||||||
"babel-preset-env": "^1.6.1",
|
"devDependencies": {
|
||||||
"cross-env": "^5.1.4",
|
"@babel/core": "^7.6.0",
|
||||||
"css-loader": "^0.28.10",
|
"@babel/preset-env": "^7.4.5",
|
||||||
"eslint": "^4.18.2",
|
"@vuepress/plugin-back-to-top": "1.7.1",
|
||||||
"eslint-loader": "^2.0.0",
|
"@vuepress/plugin-google-analytics": "1.7.1",
|
||||||
"git-revision-webpack-plugin": "^2.5.1",
|
"@vuepress/plugin-pwa": "1.7.1",
|
||||||
"mini-css-extract-plugin": "0.2.0",
|
"art-template": "4.13.2",
|
||||||
"node-sass": "^4.7.2",
|
"art-template-loader": "1.4.3",
|
||||||
"postcss-loader": "^2.1.1",
|
"autoprefixer": "^9.6.1",
|
||||||
"sass-loader": "^6.0.7",
|
"babel-loader": "^8.0.6",
|
||||||
"style-loader": "^0.20.3",
|
"cross-env": "^7.0.0",
|
||||||
"svg-inline-loader": "0.8.0",
|
"css-loader": "^5.0.0",
|
||||||
"template-string-optimize-loader": "^2.2.3",
|
"cssnano": "^4.1.10",
|
||||||
"url-loader": "^1.0.1",
|
"eslint": "^7.0.0",
|
||||||
"webpack": "^4.1.1",
|
"eslint-config-prettier": "^6.3.0",
|
||||||
"webpack-cli": "2.0.12",
|
"eslint-loader": "^4.0.0",
|
||||||
"webpack-dev-server": "^3.1.1"
|
"eslint-plugin-prettier": "^3.1.1",
|
||||||
},
|
"exports-loader": "^1.0.0",
|
||||||
"dependencies": {
|
"file-loader": "^6.0.0",
|
||||||
"balloon-css": "^0.5.0",
|
"git-revision-webpack-plugin": "^3.0.3",
|
||||||
"promise-polyfill": "7.1.0",
|
"mini-css-extract-plugin": "1.3.0",
|
||||||
"smoothscroll": "0.4.0"
|
"node-sass": "^5.0.0",
|
||||||
}
|
"postcss-loader": "^3.0.0",
|
||||||
|
"prettier": "^2.0.1",
|
||||||
|
"prettier-check": "^2.0.0",
|
||||||
|
"pretty-quick": "^3.0.0",
|
||||||
|
"sass-loader": "^10.0.0",
|
||||||
|
"strip-loader": "^0.1.2",
|
||||||
|
"style-loader": "^2.0.0",
|
||||||
|
"svg-inline-loader": "0.8.2",
|
||||||
|
"template-string-optimize-loader": "^3.0.0",
|
||||||
|
"url-loader": "^4.0.0",
|
||||||
|
"vuepress": "1.7.1",
|
||||||
|
"webpack": "^4.40.2",
|
||||||
|
"webpack-cli": "3.3.12",
|
||||||
|
"webpack-dev-server": "^3.8.1",
|
||||||
|
"yorkie": "^2.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"balloon-css": "^1.0.3",
|
||||||
|
"promise-polyfill": "8.2.0",
|
||||||
|
"smoothscroll": "0.4.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+54
-60
@@ -112,7 +112,7 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height - 6;
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
z-index: 98;
|
z-index: 98;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
text-shadow: 0 0 1px #fff, 0 0 10px #fff;
|
text-shadow: -1px -1px 0 #fff;
|
||||||
|
|
||||||
&:before,
|
&:before,
|
||||||
&:after {
|
&:after {
|
||||||
@@ -330,6 +330,7 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height - 6;
|
|||||||
user-select: text;
|
user-select: text;
|
||||||
cursor: default;
|
cursor: default;
|
||||||
padding-bottom: 2px;
|
padding-bottom: 2px;
|
||||||
|
height: 20px;
|
||||||
|
|
||||||
.aplayer-title {
|
.aplayer-title {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
@@ -575,78 +576,71 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height - 6;
|
|||||||
will-change: height;
|
will-change: height;
|
||||||
display: none;
|
display: none;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
list-style-type: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
overflow-y: auto;
|
||||||
|
|
||||||
&.aplayer-list-hide {
|
&::-webkit-scrollbar {
|
||||||
max-height: 0 !important;
|
width: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
ol {
|
&::-webkit-scrollbar-thumb {
|
||||||
list-style-type: none;
|
border-radius: 3px;
|
||||||
|
background-color: #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::-webkit-scrollbar-thumb:hover {
|
||||||
|
background-color: #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
li {
|
||||||
|
position: relative;
|
||||||
|
height: 32px;
|
||||||
|
line-height: 32px;
|
||||||
|
padding: 0 15px;
|
||||||
|
font-size: 12px;
|
||||||
|
border-top: 1px solid #e9e9e9;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
overflow: hidden;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
|
||||||
overflow-y: auto;
|
|
||||||
|
|
||||||
&::-webkit-scrollbar {
|
&:first-child {
|
||||||
width: 5px;
|
border-top: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
&::-webkit-scrollbar-thumb {
|
&:hover {
|
||||||
border-radius: 3px;
|
background: #efefef;
|
||||||
background-color: #eee;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&::-webkit-scrollbar-thumb:hover {
|
&.aplayer-list-light {
|
||||||
background-color: #ccc;
|
background: #e9e9e9;
|
||||||
}
|
|
||||||
|
|
||||||
li {
|
|
||||||
position: relative;
|
|
||||||
height: 32px;
|
|
||||||
line-height: 32px;
|
|
||||||
padding: 0 15px;
|
|
||||||
font-size: 12px;
|
|
||||||
border-top: 1px solid #e9e9e9;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
overflow: hidden;
|
|
||||||
margin: 0;
|
|
||||||
|
|
||||||
&:first-child {
|
|
||||||
border-top: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: #efefef;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.aplayer-list-light {
|
|
||||||
background: #e9e9e9;
|
|
||||||
|
|
||||||
.aplayer-list-cur {
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.aplayer-list-cur {
|
.aplayer-list-cur {
|
||||||
display: none;
|
display: inline-block;
|
||||||
width: 3px;
|
|
||||||
height: 22px;
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
top: 5px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.aplayer-list-index {
|
|
||||||
color: #666;
|
|
||||||
margin-right: 12px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.aplayer-list-author {
|
|
||||||
color: #666;
|
|
||||||
float: right;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.aplayer-list-cur {
|
||||||
|
display: none;
|
||||||
|
width: 3px;
|
||||||
|
height: 22px;
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.aplayer-list-index {
|
||||||
|
color: #666;
|
||||||
|
margin-right: 12px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.aplayer-list-author {
|
||||||
|
color: #666;
|
||||||
|
float: right;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -1,5 +1,5 @@
|
|||||||
class Bar {
|
class Bar {
|
||||||
constructor (template) {
|
constructor(template) {
|
||||||
this.elements = {};
|
this.elements = {};
|
||||||
this.elements.volume = template.volume;
|
this.elements.volume = template.volume;
|
||||||
this.elements.played = template.played;
|
this.elements.played = template.played;
|
||||||
@@ -13,15 +13,15 @@ class Bar {
|
|||||||
* @param {Number} percentage
|
* @param {Number} percentage
|
||||||
* @param {String} direction - Point out the direction of this bar, Should be height or width
|
* @param {String} direction - Point out the direction of this bar, Should be height or width
|
||||||
*/
|
*/
|
||||||
set (type, percentage, direction) {
|
set(type, percentage, direction) {
|
||||||
percentage = Math.max(percentage, 0);
|
percentage = Math.max(percentage, 0);
|
||||||
percentage = Math.min(percentage, 1);
|
percentage = Math.min(percentage, 1);
|
||||||
this.elements[type].style[direction] = percentage * 100 + '%';
|
this.elements[type].style[direction] = percentage * 100 + '%';
|
||||||
}
|
}
|
||||||
|
|
||||||
get (type, direction) {
|
get(type, direction) {
|
||||||
return parseFloat(this.elements[type].style[direction]) / 100;
|
return parseFloat(this.elements[type].style[direction]) / 100;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Bar;
|
export default Bar;
|
||||||
|
|||||||
+24
-33
@@ -2,7 +2,7 @@ import utils from './utils';
|
|||||||
import Icons from './icons';
|
import Icons from './icons';
|
||||||
|
|
||||||
class Controller {
|
class Controller {
|
||||||
constructor (player) {
|
constructor(player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
||||||
this.initPlayButton();
|
this.initPlayButton();
|
||||||
@@ -18,15 +18,15 @@ class Controller {
|
|||||||
this.initLrcButton();
|
this.initLrcButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
initPlayButton () {
|
initPlayButton() {
|
||||||
this.player.template.pic.addEventListener('click', () => {
|
this.player.template.pic.addEventListener('click', () => {
|
||||||
this.player.toggle();
|
this.player.toggle();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initPlayBar () {
|
initPlayBar() {
|
||||||
const thumbMove = (e) => {
|
const thumbMove = (e) => {
|
||||||
let percentage = ((e.clientX || e.changedTouches[0].clientX) - utils.getElementViewLeft(this.player.template.barWrap)) / this.player.template.barWrap.clientWidth;
|
let percentage = ((e.clientX || e.changedTouches[0].clientX) - this.player.template.barWrap.getBoundingClientRect().left) / this.player.template.barWrap.clientWidth;
|
||||||
percentage = Math.max(percentage, 0);
|
percentage = Math.max(percentage, 0);
|
||||||
percentage = Math.min(percentage, 1);
|
percentage = Math.min(percentage, 1);
|
||||||
this.player.bar.set('played', percentage, 'width');
|
this.player.bar.set('played', percentage, 'width');
|
||||||
@@ -37,11 +37,11 @@ class Controller {
|
|||||||
const thumbUp = (e) => {
|
const thumbUp = (e) => {
|
||||||
document.removeEventListener(utils.nameMap.dragEnd, thumbUp);
|
document.removeEventListener(utils.nameMap.dragEnd, thumbUp);
|
||||||
document.removeEventListener(utils.nameMap.dragMove, thumbMove);
|
document.removeEventListener(utils.nameMap.dragMove, thumbMove);
|
||||||
let percentage = ((e.clientX || e.changedTouches[0].clientX) - utils.getElementViewLeft(this.player.template.barWrap)) / this.player.template.barWrap.clientWidth;
|
let percentage = ((e.clientX || e.changedTouches[0].clientX) - this.player.template.barWrap.getBoundingClientRect().left) / this.player.template.barWrap.clientWidth;
|
||||||
percentage = Math.max(percentage, 0);
|
percentage = Math.max(percentage, 0);
|
||||||
percentage = Math.min(percentage, 1);
|
percentage = Math.min(percentage, 1);
|
||||||
this.player.bar.set('played', percentage, 'width');
|
this.player.bar.set('played', percentage, 'width');
|
||||||
this.player.seek(this.player.bar.get('played', 'width') * this.player.duration);
|
this.player.seek(percentage * this.player.duration);
|
||||||
this.player.disableTimeupdate = false;
|
this.player.disableTimeupdate = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -52,14 +52,11 @@ class Controller {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initVolumeButton () {
|
initVolumeButton() {
|
||||||
this.player.template.volumeButton.addEventListener('click', () => {
|
this.player.template.volumeButton.addEventListener('click', () => {
|
||||||
if (this.player.audio.muted) {
|
if (this.player.audio.muted) {
|
||||||
this.player.audio.muted = false;
|
this.player.volume(this.player.audio.volume, true);
|
||||||
this.player.switchVolumeIcon();
|
} else {
|
||||||
this.player.bar.set('volume', this.player.volume(), 'height');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.player.audio.muted = true;
|
this.player.audio.muted = true;
|
||||||
this.player.switchVolumeIcon();
|
this.player.switchVolumeIcon();
|
||||||
this.player.bar.set('volume', 0, 'height');
|
this.player.bar.set('volume', 0, 'height');
|
||||||
@@ -67,7 +64,7 @@ class Controller {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const thumbMove = (e) => {
|
const thumbMove = (e) => {
|
||||||
let percentage = 1 - ((e.clientY || e.changedTouches[0].clientY) - utils.getElementViewTop(this.player.template.volumeBar, this.player.options.fixed)) / this.player.template.volumeBar.clientHeight;
|
let percentage = 1 - ((e.clientY || e.changedTouches[0].clientY) - this.player.template.volumeBar.getBoundingClientRect().top) / this.player.template.volumeBar.clientHeight;
|
||||||
percentage = Math.max(percentage, 0);
|
percentage = Math.max(percentage, 0);
|
||||||
percentage = Math.min(percentage, 1);
|
percentage = Math.min(percentage, 1);
|
||||||
this.player.volume(percentage);
|
this.player.volume(percentage);
|
||||||
@@ -77,7 +74,7 @@ class Controller {
|
|||||||
this.player.template.volumeBarWrap.classList.remove('aplayer-volume-bar-wrap-active');
|
this.player.template.volumeBarWrap.classList.remove('aplayer-volume-bar-wrap-active');
|
||||||
document.removeEventListener(utils.nameMap.dragEnd, thumbUp);
|
document.removeEventListener(utils.nameMap.dragEnd, thumbUp);
|
||||||
document.removeEventListener(utils.nameMap.dragMove, thumbMove);
|
document.removeEventListener(utils.nameMap.dragMove, thumbMove);
|
||||||
let percentage = 1 - ((e.clientY || e.changedTouches[0].clientY) - utils.getElementViewTop(this.player.template.volumeBar, this.player.options.fixed)) / this.player.template.volumeBar.clientHeight;
|
let percentage = 1 - ((e.clientY || e.changedTouches[0].clientY) - this.player.template.volumeBar.getBoundingClientRect().top) / this.player.template.volumeBar.clientHeight;
|
||||||
percentage = Math.max(percentage, 0);
|
percentage = Math.max(percentage, 0);
|
||||||
percentage = Math.min(percentage, 1);
|
percentage = Math.min(percentage, 1);
|
||||||
this.player.volume(percentage);
|
this.player.volume(percentage);
|
||||||
@@ -90,41 +87,36 @@ class Controller {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initOrderButton () {
|
initOrderButton() {
|
||||||
this.player.template.order.addEventListener('click', () => {
|
this.player.template.order.addEventListener('click', () => {
|
||||||
if (this.player.options.order === 'list') {
|
if (this.player.options.order === 'list') {
|
||||||
this.player.options.order = 'random';
|
this.player.options.order = 'random';
|
||||||
this.player.template.order.innerHTML = Icons.orderRandom;
|
this.player.template.order.innerHTML = Icons.orderRandom;
|
||||||
}
|
} else if (this.player.options.order === 'random') {
|
||||||
else if (this.player.options.order === 'random') {
|
|
||||||
this.player.options.order = 'list';
|
this.player.options.order = 'list';
|
||||||
this.player.template.order.innerHTML = Icons.orderList;
|
this.player.template.order.innerHTML = Icons.orderList;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initLoopButton () {
|
initLoopButton() {
|
||||||
this.player.template.loop.addEventListener('click', () => {
|
this.player.template.loop.addEventListener('click', () => {
|
||||||
if (this.player.list.audios.length > 1) {
|
if (this.player.list.audios.length > 1) {
|
||||||
if (this.player.options.loop === 'one') {
|
if (this.player.options.loop === 'one') {
|
||||||
this.player.options.loop = 'none';
|
this.player.options.loop = 'none';
|
||||||
this.player.template.loop.innerHTML = Icons.loopNone;
|
this.player.template.loop.innerHTML = Icons.loopNone;
|
||||||
}
|
} else if (this.player.options.loop === 'none') {
|
||||||
else if (this.player.options.loop === 'none') {
|
|
||||||
this.player.options.loop = 'all';
|
this.player.options.loop = 'all';
|
||||||
this.player.template.loop.innerHTML = Icons.loopAll;
|
this.player.template.loop.innerHTML = Icons.loopAll;
|
||||||
}
|
} else if (this.player.options.loop === 'all') {
|
||||||
else if (this.player.options.loop === 'all') {
|
|
||||||
this.player.options.loop = 'one';
|
this.player.options.loop = 'one';
|
||||||
this.player.template.loop.innerHTML = Icons.loopOne;
|
this.player.template.loop.innerHTML = Icons.loopOne;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (this.player.options.loop === 'one' || this.player.options.loop === 'all') {
|
if (this.player.options.loop === 'one' || this.player.options.loop === 'all') {
|
||||||
this.player.options.loop = 'none';
|
this.player.options.loop = 'none';
|
||||||
this.player.template.loop.innerHTML = Icons.loopNone;
|
this.player.template.loop.innerHTML = Icons.loopNone;
|
||||||
}
|
} else if (this.player.options.loop === 'none') {
|
||||||
else if (this.player.options.loop === 'none') {
|
|
||||||
this.player.options.loop = 'all';
|
this.player.options.loop = 'all';
|
||||||
this.player.template.loop.innerHTML = Icons.loopAll;
|
this.player.template.loop.innerHTML = Icons.loopAll;
|
||||||
}
|
}
|
||||||
@@ -132,19 +124,19 @@ class Controller {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initMenuButton () {
|
initMenuButton() {
|
||||||
this.player.template.menu.addEventListener('click', () => {
|
this.player.template.menu.addEventListener('click', () => {
|
||||||
this.player.list.toggle();
|
this.player.list.toggle();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initMiniSwitcher () {
|
initMiniSwitcher() {
|
||||||
this.player.template.miniSwitcher.addEventListener('click', () => {
|
this.player.template.miniSwitcher.addEventListener('click', () => {
|
||||||
this.player.setMode(this.player.mode === 'mini' ? 'normal' : 'mini');
|
this.player.setMode(this.player.mode === 'mini' ? 'normal' : 'mini');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initSkipButton () {
|
initSkipButton() {
|
||||||
this.player.template.skipBackButton.addEventListener('click', () => {
|
this.player.template.skipBackButton.addEventListener('click', () => {
|
||||||
this.player.skipBack();
|
this.player.skipBack();
|
||||||
});
|
});
|
||||||
@@ -156,13 +148,12 @@ class Controller {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initLrcButton () {
|
initLrcButton() {
|
||||||
this.player.template.lrcButton.addEventListener('click', () => {
|
this.player.template.lrcButton.addEventListener('click', () => {
|
||||||
if (this.player.template.lrcButton.classList.contains('aplayer-icon-lrc-inactivity')) {
|
if (this.player.template.lrcButton.classList.contains('aplayer-icon-lrc-inactivity')) {
|
||||||
this.player.template.lrcButton.classList.remove('aplayer-icon-lrc-inactivity');
|
this.player.template.lrcButton.classList.remove('aplayer-icon-lrc-inactivity');
|
||||||
this.player.lrc && this.player.lrc.show();
|
this.player.lrc && this.player.lrc.show();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.player.template.lrcButton.classList.add('aplayer-icon-lrc-inactivity');
|
this.player.template.lrcButton.classList.add('aplayer-icon-lrc-inactivity');
|
||||||
this.player.lrc && this.player.lrc.hide();
|
this.player.lrc && this.player.lrc.hide();
|
||||||
}
|
}
|
||||||
@@ -170,4 +161,4 @@ class Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Controller;
|
export default Controller;
|
||||||
|
|||||||
+29
-16
@@ -1,22 +1,36 @@
|
|||||||
class Events {
|
class Events {
|
||||||
constructor () {
|
constructor() {
|
||||||
this.events = {};
|
this.events = {};
|
||||||
|
|
||||||
this.audioEvents = [
|
this.audioEvents = [
|
||||||
'abort', 'canplay', 'canplaythrough', 'durationchange', 'emptied', 'ended', 'error',
|
'abort',
|
||||||
'loadeddata', 'loadedmetadata', 'loadstart', 'mozaudioavailable', 'pause', 'play',
|
'canplay',
|
||||||
'playing', 'progress', 'ratechange', 'seeked', 'seeking', 'stalled', 'suspend',
|
'canplaythrough',
|
||||||
'timeupdate', 'volumechange', 'waiting'
|
'durationchange',
|
||||||
];
|
'emptied',
|
||||||
this.playerEvents = [
|
'ended',
|
||||||
'destroy',
|
'error',
|
||||||
'listshow', 'listhide', 'listadd', 'listremove', 'listswitch', 'listclear',
|
'loadeddata',
|
||||||
'noticeshow', 'noticehide',
|
'loadedmetadata',
|
||||||
'lrcshow', 'lrchide',
|
'loadstart',
|
||||||
|
'mozaudioavailable',
|
||||||
|
'pause',
|
||||||
|
'play',
|
||||||
|
'playing',
|
||||||
|
'progress',
|
||||||
|
'ratechange',
|
||||||
|
'seeked',
|
||||||
|
'seeking',
|
||||||
|
'stalled',
|
||||||
|
'suspend',
|
||||||
|
'timeupdate',
|
||||||
|
'volumechange',
|
||||||
|
'waiting',
|
||||||
];
|
];
|
||||||
|
this.playerEvents = ['destroy', 'listshow', 'listhide', 'listadd', 'listremove', 'listswitch', 'listclear', 'noticeshow', 'noticehide', 'lrcshow', 'lrchide'];
|
||||||
}
|
}
|
||||||
|
|
||||||
on (name, callback) {
|
on(name, callback) {
|
||||||
if (this.type(name) && typeof callback === 'function') {
|
if (this.type(name) && typeof callback === 'function') {
|
||||||
if (!this.events[name]) {
|
if (!this.events[name]) {
|
||||||
this.events[name] = [];
|
this.events[name] = [];
|
||||||
@@ -25,7 +39,7 @@ class Events {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trigger (name, data) {
|
trigger(name, data) {
|
||||||
if (this.events[name] && this.events[name].length) {
|
if (this.events[name] && this.events[name].length) {
|
||||||
for (let i = 0; i < this.events[name].length; i++) {
|
for (let i = 0; i < this.events[name].length; i++) {
|
||||||
this.events[name][i](data);
|
this.events[name][i](data);
|
||||||
@@ -33,11 +47,10 @@ class Events {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type (name) {
|
type(name) {
|
||||||
if (this.playerEvents.indexOf(name) !== -1) {
|
if (this.playerEvents.indexOf(name) !== -1) {
|
||||||
return 'player';
|
return 'player';
|
||||||
}
|
} else if (this.audioEvents.indexOf(name) !== -1) {
|
||||||
else if (this.audioEvents.indexOf(name) !== -1) {
|
|
||||||
return 'audio';
|
return 'audio';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -4,4 +4,4 @@ import APlayer from './player';
|
|||||||
/* global APLAYER_VERSION GIT_HASH */
|
/* global APLAYER_VERSION GIT_HASH */
|
||||||
console.log(`${'\n'} %c APlayer v${APLAYER_VERSION} ${GIT_HASH} %c http://aplayer.js.org ${'\n'}`, 'color: #fadfa3; background: #030307; padding:5px 0;', 'background: #fadfa3; padding:5px 0;');
|
console.log(`${'\n'} %c APlayer v${APLAYER_VERSION} ${GIT_HASH} %c http://aplayer.js.org ${'\n'}`, 'color: #fadfa3; background: #030307; padding:5px 0;', 'background: #fadfa3; padding:5px 0;');
|
||||||
|
|
||||||
export default APlayer;
|
export default APlayer;
|
||||||
|
|||||||
+36
-34
@@ -3,55 +3,59 @@ import utils from './utils';
|
|||||||
import smoothScroll from 'smoothscroll';
|
import smoothScroll from 'smoothscroll';
|
||||||
|
|
||||||
class List {
|
class List {
|
||||||
constructor (player) {
|
constructor(player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.index = 0;
|
this.index = 0;
|
||||||
this.audios = this.player.options.audio;
|
this.audios = this.player.options.audio;
|
||||||
|
this.showing = true;
|
||||||
|
this.player.template.list.style.height = `${Math.min(this.player.template.list.scrollHeight, this.player.options.listMaxHeight)}px`;
|
||||||
|
|
||||||
this.bindEvents();
|
this.bindEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
bindEvents () {
|
bindEvents() {
|
||||||
this.player.template.list.addEventListener('click', (e) => {
|
this.player.template.list.addEventListener('click', (e) => {
|
||||||
let target;
|
let target;
|
||||||
if (e.target.tagName.toUpperCase() === 'LI') {
|
if (e.target.tagName.toUpperCase() === 'LI') {
|
||||||
target = e.target;
|
target = e.target;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
target = e.target.parentElement;
|
target = e.target.parentElement;
|
||||||
}
|
}
|
||||||
const audioIndex = parseInt(target.getElementsByClassName('aplayer-list-index')[0].innerHTML) - 1;
|
const audioIndex = parseInt(target.getElementsByClassName('aplayer-list-index')[0].innerHTML) - 1;
|
||||||
if (audioIndex !== this.index) {
|
if (audioIndex !== this.index) {
|
||||||
this.switch(audioIndex);
|
this.switch(audioIndex);
|
||||||
this.player.play();
|
this.player.play();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.player.toggle();
|
this.player.toggle();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
show () {
|
show() {
|
||||||
|
this.showing = true;
|
||||||
|
this.player.template.list.scrollTop = this.index * 33;
|
||||||
|
this.player.template.list.style.height = `${Math.min(this.player.template.list.scrollHeight, this.player.options.listMaxHeight)}px`;
|
||||||
this.player.events.trigger('listshow');
|
this.player.events.trigger('listshow');
|
||||||
this.player.template.list.classList.remove('aplayer-list-hide');
|
|
||||||
this.player.template.listOl.scrollTop = this.index * 33;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hide () {
|
hide() {
|
||||||
this.player.events.trigger('listhide');
|
this.showing = false;
|
||||||
this.player.template.list.classList.add('aplayer-list-hide');
|
this.player.template.list.style.height = `${Math.min(this.player.template.list.scrollHeight, this.player.options.listMaxHeight)}px`;
|
||||||
|
setTimeout(() => {
|
||||||
|
this.player.template.list.style.height = '0px';
|
||||||
|
this.player.events.trigger('listhide');
|
||||||
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle () {
|
toggle() {
|
||||||
if (!this.player.template.list.classList.contains('aplayer-list-hide')) {
|
if (this.showing) {
|
||||||
this.hide();
|
this.hide();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.show();
|
this.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add (audios) {
|
add(audios) {
|
||||||
this.player.events.trigger('listadd', {
|
this.player.events.trigger('listadd', {
|
||||||
audios: audios,
|
audios: audios,
|
||||||
});
|
});
|
||||||
@@ -70,10 +74,10 @@ class List {
|
|||||||
const wasSingle = !(this.audios.length > 1);
|
const wasSingle = !(this.audios.length > 1);
|
||||||
const wasEmpty = this.audios.length === 0;
|
const wasEmpty = this.audios.length === 0;
|
||||||
|
|
||||||
this.player.template.listOl.innerHTML += tplListItem({
|
this.player.template.list.innerHTML += tplListItem({
|
||||||
theme: this.player.options.theme,
|
theme: this.player.options.theme,
|
||||||
audio: audios,
|
audio: audios,
|
||||||
index: this.audios.length + 1
|
index: this.audios.length + 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.audios = this.audios.concat(audios);
|
this.audios = this.audios.concat(audios);
|
||||||
@@ -90,14 +94,13 @@ class List {
|
|||||||
if (wasEmpty) {
|
if (wasEmpty) {
|
||||||
if (this.player.options.order === 'random') {
|
if (this.player.options.order === 'random') {
|
||||||
this.switch(this.player.randomOrder[0]);
|
this.switch(this.player.randomOrder[0]);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.switch(0);
|
this.switch(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
remove (index) {
|
remove(index) {
|
||||||
this.player.events.trigger('listremove', {
|
this.player.events.trigger('listremove', {
|
||||||
index: index,
|
index: index,
|
||||||
});
|
});
|
||||||
@@ -107,13 +110,12 @@ class List {
|
|||||||
list[index].remove();
|
list[index].remove();
|
||||||
|
|
||||||
this.audios.splice(index, 1);
|
this.audios.splice(index, 1);
|
||||||
this.lrc.parsed.splice(index, 1);
|
this.player.lrc && this.player.lrc.remove(index);
|
||||||
|
|
||||||
if (index === this.index) {
|
if (index === this.index) {
|
||||||
if (this.audios[index]) {
|
if (this.audios[index]) {
|
||||||
this.switch(index);
|
this.switch(index);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.switch(index - 1);
|
this.switch(index - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,14 +131,13 @@ class List {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.player.template.listCurs = this.player.container.querySelectorAll('.aplayer-list-cur');
|
this.player.template.listCurs = this.player.container.querySelectorAll('.aplayer-list-cur');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.clear();
|
this.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (index) {
|
switch(index) {
|
||||||
this.player.events.trigger('listswitch', {
|
this.player.events.trigger('listswitch', {
|
||||||
index: index,
|
index: index,
|
||||||
});
|
});
|
||||||
@@ -158,7 +159,7 @@ class List {
|
|||||||
}
|
}
|
||||||
this.player.container.querySelectorAll('.aplayer-list li')[this.index].classList.add('aplayer-list-light');
|
this.player.container.querySelectorAll('.aplayer-list li')[this.index].classList.add('aplayer-list-light');
|
||||||
|
|
||||||
smoothScroll(this.index * 33, 500, null, this.player.template.listOl);
|
smoothScroll(this.index * 33, 500, null, this.player.template.list);
|
||||||
|
|
||||||
this.player.setAudio(audio);
|
this.player.setAudio(audio);
|
||||||
|
|
||||||
@@ -166,21 +167,22 @@ class List {
|
|||||||
this.player.lrc && this.player.lrc.update(0);
|
this.player.lrc && this.player.lrc.update(0);
|
||||||
|
|
||||||
// set duration time
|
// set duration time
|
||||||
if (this.player.duration !== 1) { // compatibility: Android browsers will output 1 at first
|
if (this.player.duration !== 1) {
|
||||||
|
// compatibility: Android browsers will output 1 at first
|
||||||
this.player.template.dtime.innerHTML = utils.secondToTime(this.player.duration);
|
this.player.template.dtime.innerHTML = utils.secondToTime(this.player.duration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clear () {
|
clear() {
|
||||||
this.player.events.trigger('listclear');
|
this.player.events.trigger('listclear');
|
||||||
this.index = 0;
|
this.index = 0;
|
||||||
this.player.container.classList.remove('aplayer-withlist');
|
this.player.container.classList.remove('aplayer-withlist');
|
||||||
this.player.pause();
|
this.player.pause();
|
||||||
this.audios = [];
|
this.audios = [];
|
||||||
this.lrc.parsed = [];
|
this.player.lrc && this.player.lrc.clear();
|
||||||
this.player.audio.src = '';
|
this.player.audio.src = '';
|
||||||
this.player.template.listOl.innerHTML = '';
|
this.player.template.list.innerHTML = '';
|
||||||
this.player.template.pic.style.backgroundImage = '';
|
this.player.template.pic.style.backgroundImage = '';
|
||||||
this.player.theme(this.player.options.theme, this.index, false);
|
this.player.theme(this.player.options.theme, this.index, false);
|
||||||
this.player.template.title.innerHTML = 'No audio';
|
this.player.template.title.innerHTML = 'No audio';
|
||||||
@@ -190,4 +192,4 @@ class List {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default List;
|
export default List;
|
||||||
|
|||||||
+30
-23
@@ -1,7 +1,7 @@
|
|||||||
import tplLrc from '../template/lrc.art';
|
import tplLrc from '../template/lrc.art';
|
||||||
|
|
||||||
class Lrc {
|
class Lrc {
|
||||||
constructor (options) {
|
constructor(options) {
|
||||||
this.container = options.container;
|
this.container = options.container;
|
||||||
this.async = options.async;
|
this.async = options.async;
|
||||||
this.player = options.player;
|
this.player = options.player;
|
||||||
@@ -10,26 +10,25 @@ class Lrc {
|
|||||||
this.current = [];
|
this.current = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
show () {
|
show() {
|
||||||
this.player.events.trigger('lrcshow');
|
this.player.events.trigger('lrcshow');
|
||||||
this.player.template.lrcWrap.classList.remove('aplayer-lrc-hide');
|
this.player.template.lrcWrap.classList.remove('aplayer-lrc-hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
hide () {
|
hide() {
|
||||||
this.player.events.trigger('lrchide');
|
this.player.events.trigger('lrchide');
|
||||||
this.player.template.lrcWrap.classList.add('aplayer-lrc-hide');
|
this.player.template.lrcWrap.classList.add('aplayer-lrc-hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle () {
|
toggle() {
|
||||||
if (this.player.template.lrcWrap.classList.contains('aplayer-lrc-hide')) {
|
if (this.player.template.lrcWrap.classList.contains('aplayer-lrc-hide')) {
|
||||||
this.show();
|
this.show();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.hide();
|
this.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update (currentTime = this.player.audio.currentTime) {
|
update(currentTime = this.player.audio.currentTime) {
|
||||||
if (this.index > this.current.length - 1 || currentTime < this.current[this.index][0] || (!this.current[this.index + 1] || currentTime >= this.current[this.index + 1][0])) {
|
if (this.index > this.current.length - 1 || currentTime < this.current[this.index][0] || (!this.current[this.index + 1] || currentTime >= this.current[this.index + 1][0])) {
|
||||||
for (let i = 0; i < this.current.length; i++) {
|
for (let i = 0; i < this.current.length; i++) {
|
||||||
if (currentTime >= this.current[i][0] && (!this.current[i + 1] || currentTime < this.current[i + 1][0])) {
|
if (currentTime >= this.current[i][0] && (!this.current[i + 1] || currentTime < this.current[i + 1][0])) {
|
||||||
@@ -43,30 +42,27 @@ class Lrc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (index) {
|
switch(index) {
|
||||||
if (!this.parsed[index]) {
|
if (!this.parsed[index]) {
|
||||||
if (!this.async) {
|
if (!this.async) {
|
||||||
if (this.player.list.audios[index].lrc) {
|
if (this.player.list.audios[index].lrc) {
|
||||||
this.parsed[index] = this.parse(this.player.list.audios[index].lrc);
|
this.parsed[index] = this.parse(this.player.list.audios[index].lrc);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.parsed[index] = [['00:00', 'Not available']];
|
this.parsed[index] = [['00:00', 'Not available']];
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.parsed[index] = [['00:00', 'Loading']];
|
this.parsed[index] = [['00:00', 'Loading']];
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
xhr.onreadystatechange = () => {
|
xhr.onreadystatechange = () => {
|
||||||
if (index === this.player.list.index && xhr.readyState === 4) {
|
if (index === this.player.list.index && xhr.readyState === 4) {
|
||||||
if (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) {
|
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304) {
|
||||||
this.parsed[index] = this.parse(xhr.responseText);
|
this.parsed[index] = this.parse(xhr.responseText);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.player.notice(`LRC file request fails: status ${xhr.status}`);
|
this.player.notice(`LRC file request fails: status ${xhr.status}`);
|
||||||
this.parsed[index] = [['00:00', 'Not available']];
|
this.parsed[index] = [['00:00', 'Not available']];
|
||||||
}
|
}
|
||||||
this.container.innerHTML = tplLrc({
|
this.container.innerHTML = tplLrc({
|
||||||
lyrics: this.parsed[index]
|
lyrics: this.parsed[index],
|
||||||
});
|
});
|
||||||
this.update(0);
|
this.update(0);
|
||||||
this.current = this.parsed[index];
|
this.current = this.parsed[index];
|
||||||
@@ -79,10 +75,10 @@ class Lrc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.container.innerHTML = tplLrc({
|
this.container.innerHTML = tplLrc({
|
||||||
lyrics: this.parsed[index]
|
lyrics: this.parsed[index],
|
||||||
});
|
});
|
||||||
this.update(0);
|
|
||||||
this.current = this.parsed[index];
|
this.current = this.parsed[index];
|
||||||
|
this.update(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,7 +93,7 @@ class Lrc {
|
|||||||
*
|
*
|
||||||
* @return {String} [[time, text], [time, text], [time, text], ...]
|
* @return {String} [[time, text], [time, text], [time, text], ...]
|
||||||
*/
|
*/
|
||||||
parse (lrc_s) {
|
parse(lrc_s) {
|
||||||
if (lrc_s) {
|
if (lrc_s) {
|
||||||
lrc_s = lrc_s.replace(/([^\]^\n])\[/g, (match, p1) => p1 + '\n[');
|
lrc_s = lrc_s.replace(/([^\]^\n])\[/g, (match, p1) => p1 + '\n[');
|
||||||
const lyric = lrc_s.split('\n');
|
const lyric = lrc_s.split('\n');
|
||||||
@@ -107,7 +103,10 @@ class Lrc {
|
|||||||
// match lrc time
|
// match lrc time
|
||||||
const lrcTimes = lyric[i].match(/\[(\d{2}):(\d{2})(\.(\d{2,3}))?]/g);
|
const lrcTimes = lyric[i].match(/\[(\d{2}):(\d{2})(\.(\d{2,3}))?]/g);
|
||||||
// match lrc text
|
// match lrc text
|
||||||
const lrcText = lyric[i].replace(/.*\[(\d{2}):(\d{2})(\.(\d{2,3}))?]/g, '').replace(/<(\d{2}):(\d{2})(\.(\d{2,3}))?>/g, '').replace(/^\s+|\s+$/g, '');
|
const lrcText = lyric[i]
|
||||||
|
.replace(/.*\[(\d{2}):(\d{2})(\.(\d{2,3}))?]/g, '')
|
||||||
|
.replace(/<(\d{2}):(\d{2})(\.(\d{2,3}))?>/g, '')
|
||||||
|
.replace(/^\s+|\s+$/g, '');
|
||||||
|
|
||||||
if (lrcTimes) {
|
if (lrcTimes) {
|
||||||
// handle multiple time tag
|
// handle multiple time tag
|
||||||
@@ -126,11 +125,19 @@ class Lrc {
|
|||||||
lrc = lrc.filter((item) => item[1]);
|
lrc = lrc.filter((item) => item[1]);
|
||||||
lrc.sort((a, b) => a[0] - b[0]);
|
lrc.sort((a, b) => a[0] - b[0]);
|
||||||
return lrc;
|
return lrc;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remove(index) {
|
||||||
|
this.parsed.splice(index, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
clear() {
|
||||||
|
this.parsed = [];
|
||||||
|
this.container.innerHTML = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Lrc;
|
export default Lrc;
|
||||||
|
|||||||
+5
-4
@@ -1,5 +1,4 @@
|
|||||||
export default (options) => {
|
export default (options) => {
|
||||||
|
|
||||||
// default options
|
// default options
|
||||||
const defaultOption = {
|
const defaultOption = {
|
||||||
container: options.element || document.getElementsByClassName('aplayer')[0],
|
container: options.element || document.getElementsByClassName('aplayer')[0],
|
||||||
@@ -8,15 +7,15 @@ export default (options) => {
|
|||||||
autoplay: false,
|
autoplay: false,
|
||||||
mutex: true,
|
mutex: true,
|
||||||
lrcType: options.showlrc || options.lrc || 0,
|
lrcType: options.showlrc || options.lrc || 0,
|
||||||
preload: 'auto',
|
preload: 'metadata',
|
||||||
theme: '#b7daff',
|
theme: '#b7daff',
|
||||||
loop: 'all',
|
loop: 'all',
|
||||||
order: 'list',
|
order: 'list',
|
||||||
volume: 0.7,
|
volume: 0.7,
|
||||||
listFolded: options.fixed,
|
listFolded: options.fixed,
|
||||||
listMaxHeight: options.listmaxheight || '250px',
|
listMaxHeight: options.listmaxheight || 250,
|
||||||
audio: options.music || [],
|
audio: options.music || [],
|
||||||
storageName: 'aplayer-setting'
|
storageName: 'aplayer-setting',
|
||||||
};
|
};
|
||||||
for (const defaultKey in defaultOption) {
|
for (const defaultKey in defaultOption) {
|
||||||
if (defaultOption.hasOwnProperty(defaultKey) && !options.hasOwnProperty(defaultKey)) {
|
if (defaultOption.hasOwnProperty(defaultKey) && !options.hasOwnProperty(defaultKey)) {
|
||||||
@@ -24,6 +23,8 @@ export default (options) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
options.listMaxHeight = parseFloat(options.listMaxHeight);
|
||||||
|
|
||||||
if (Object.prototype.toString.call(options.audio) !== '[object Array]') {
|
if (Object.prototype.toString.call(options.audio) !== '[object Array]') {
|
||||||
options.audio = [options.audio];
|
options.audio = [options.audio];
|
||||||
}
|
}
|
||||||
|
|||||||
+66
-83
@@ -15,14 +15,13 @@ import List from './list';
|
|||||||
const instances = [];
|
const instances = [];
|
||||||
|
|
||||||
class APlayer {
|
class APlayer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APlayer constructor function
|
* APlayer constructor function
|
||||||
*
|
*
|
||||||
* @param {Object} options - See README
|
* @param {Object} options - See README
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
constructor (options) {
|
constructor(options) {
|
||||||
this.options = handleOption(options);
|
this.options = handleOption(options);
|
||||||
this.container = this.options.container;
|
this.container = this.options.container;
|
||||||
this.paused = true;
|
this.paused = true;
|
||||||
@@ -47,7 +46,6 @@ class APlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// save lrc
|
// save lrc
|
||||||
this.container = this.options.container;
|
|
||||||
if (this.options.lrcType === 2 || this.options.lrcType === true) {
|
if (this.options.lrcType === 2 || this.options.lrcType === true) {
|
||||||
const lrcEle = this.container.getElementsByClassName('aplayer-lrc-content');
|
const lrcEle = this.container.getElementsByClassName('aplayer-lrc-content');
|
||||||
for (let i = 0; i < lrcEle.length; i++) {
|
for (let i = 0; i < lrcEle.length; i++) {
|
||||||
@@ -93,8 +91,7 @@ class APlayer {
|
|||||||
this.bindEvents();
|
this.bindEvents();
|
||||||
if (this.options.order === 'random') {
|
if (this.options.order === 'random') {
|
||||||
this.list.switch(this.randomOrder[0]);
|
this.list.switch(this.randomOrder[0]);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.list.switch(0);
|
this.list.switch(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +103,7 @@ class APlayer {
|
|||||||
instances.push(this);
|
instances.push(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
initAudio () {
|
initAudio() {
|
||||||
this.audio = document.createElement('audio');
|
this.audio = document.createElement('audio');
|
||||||
this.audio.preload = this.options.preload;
|
this.audio.preload = this.options.preload;
|
||||||
|
|
||||||
@@ -119,7 +116,7 @@ class APlayer {
|
|||||||
this.volume(this.storage.get('volume'), true);
|
this.volume(this.storage.get('volume'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bindEvents () {
|
bindEvents() {
|
||||||
this.on('play', () => {
|
this.on('play', () => {
|
||||||
if (this.paused) {
|
if (this.paused) {
|
||||||
this.setUIPlaying();
|
this.setUIPlaying();
|
||||||
@@ -145,12 +142,25 @@ class APlayer {
|
|||||||
|
|
||||||
// show audio time: the metadata has loaded or changed
|
// show audio time: the metadata has loaded or changed
|
||||||
this.on('durationchange', () => {
|
this.on('durationchange', () => {
|
||||||
if (this.duration !== 1) { // compatibility: Android browsers will output 1 at first
|
if (this.duration !== 1) {
|
||||||
|
// compatibility: Android browsers will output 1 at first
|
||||||
this.template.dtime.innerHTML = utils.secondToTime(this.duration);
|
this.template.dtime.innerHTML = utils.secondToTime(this.duration);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Can seek now
|
||||||
|
this.on('loadedmetadata', () => {
|
||||||
|
this.seek(0);
|
||||||
|
if (!this.paused) {
|
||||||
|
this.audio.play();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// show audio loaded bar: to inform interested parties of progress downloading the media
|
// show audio loaded bar: to inform interested parties of progress downloading the media
|
||||||
|
this.on('canplay', () => {
|
||||||
|
const percentage = this.audio.buffered.length ? this.audio.buffered.end(this.audio.buffered.length - 1) / this.duration : 0;
|
||||||
|
this.bar.set('loaded', percentage, 'width');
|
||||||
|
});
|
||||||
this.on('progress', () => {
|
this.on('progress', () => {
|
||||||
const percentage = this.audio.buffered.length ? this.audio.buffered.end(this.audio.buffered.length - 1) / this.duration : 0;
|
const percentage = this.audio.buffered.length ? this.audio.buffered.end(this.audio.buffered.length - 1) / this.duration : 0;
|
||||||
this.bar.set('loaded', percentage, 'width');
|
this.bar.set('loaded', percentage, 'width');
|
||||||
@@ -159,7 +169,7 @@ class APlayer {
|
|||||||
// audio download error: an error occurs
|
// audio download error: an error occurs
|
||||||
let skipTime;
|
let skipTime;
|
||||||
this.on('error', () => {
|
this.on('error', () => {
|
||||||
if (this.list.audios.length) {
|
if (this.list.audios.length > 1) {
|
||||||
this.notice('An audio error has occurred, player will skip forward in 2 seconds.');
|
this.notice('An audio error has occurred, player will skip forward in 2 seconds.');
|
||||||
skipTime = setTimeout(() => {
|
skipTime = setTimeout(() => {
|
||||||
this.skipForward();
|
this.skipForward();
|
||||||
@@ -167,8 +177,7 @@ class APlayer {
|
|||||||
this.play();
|
this.play();
|
||||||
}
|
}
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
} else if (this.list.audios.length === 1) {
|
||||||
else {
|
|
||||||
this.notice('An audio error has occurred.');
|
this.notice('An audio error has occurred.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -183,35 +192,30 @@ class APlayer {
|
|||||||
if (this.list.index < this.list.audios.length - 1) {
|
if (this.list.index < this.list.audios.length - 1) {
|
||||||
this.list.switch((this.list.index + 1) % this.list.audios.length);
|
this.list.switch((this.list.index + 1) % this.list.audios.length);
|
||||||
this.play();
|
this.play();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.list.switch((this.list.index + 1) % this.list.audios.length);
|
this.list.switch((this.list.index + 1) % this.list.audios.length);
|
||||||
this.pause();
|
this.pause();
|
||||||
}
|
}
|
||||||
}
|
} else if (this.options.order === 'random') {
|
||||||
else if (this.options.order === 'random') {
|
|
||||||
if (this.randomOrder.indexOf(this.list.index) < this.randomOrder.length - 1) {
|
if (this.randomOrder.indexOf(this.list.index) < this.randomOrder.length - 1) {
|
||||||
this.list.switch(this.nextIndex());
|
this.list.switch(this.nextIndex());
|
||||||
this.play();
|
this.play();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.list.switch(this.nextIndex());
|
this.list.switch(this.nextIndex());
|
||||||
this.pause();
|
this.pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (this.options.loop === 'one') {
|
||||||
else if (this.options.loop === 'one') {
|
|
||||||
this.list.switch(this.list.index);
|
this.list.switch(this.list.index);
|
||||||
this.play();
|
this.play();
|
||||||
}
|
} else if (this.options.loop === 'all') {
|
||||||
else if (this.options.loop === 'all') {
|
|
||||||
this.skipForward();
|
this.skipForward();
|
||||||
this.play();
|
this.play();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setAudio (audio) {
|
setAudio(audio) {
|
||||||
if (this.hls) {
|
if (this.hls) {
|
||||||
this.hls.destroy();
|
this.hls.destroy();
|
||||||
this.hls = null;
|
this.hls = null;
|
||||||
@@ -220,45 +224,34 @@ class APlayer {
|
|||||||
if (this.options.customAudioType && this.options.customAudioType[type]) {
|
if (this.options.customAudioType && this.options.customAudioType[type]) {
|
||||||
if (Object.prototype.toString.call(this.options.customAudioType[type]) === '[object Function]') {
|
if (Object.prototype.toString.call(this.options.customAudioType[type]) === '[object Function]') {
|
||||||
this.options.customAudioType[type](this.audio, audio, this);
|
this.options.customAudioType[type](this.audio, audio, this);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
console.error(`Illegal customType: ${type}`);
|
console.error(`Illegal customType: ${type}`);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (!type || type === 'auto') {
|
if (!type || type === 'auto') {
|
||||||
if (/m3u8(#|\?|$)/i.exec(audio.url)) {
|
if (/m3u8(#|\?|$)/i.exec(audio.url)) {
|
||||||
type = 'hls';
|
type = 'hls';
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
type = 'normal';
|
type = 'normal';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type === 'hls') {
|
if (type === 'hls') {
|
||||||
if (Hls.isSupported()) {
|
if (window.Hls.isSupported()) {
|
||||||
this.hls = new Hls();
|
this.hls = new window.Hls();
|
||||||
this.hls.loadSource(audio.url);
|
this.hls.loadSource(audio.url);
|
||||||
this.hls.attachMedia(this.audio);
|
this.hls.attachMedia(this.audio);
|
||||||
}
|
} else if (this.audio.canPlayType('application/x-mpegURL') || this.audio.canPlayType('application/vnd.apple.mpegURL')) {
|
||||||
else if (this.audio.canPlayType('application/x-mpegURL') || this.audio.canPlayType('application/vnd.apple.mpegURL')) {
|
|
||||||
this.audio.src = audio.url;
|
this.audio.src = audio.url;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.notice('Error: HLS is not supported.');
|
this.notice('Error: HLS is not supported.');
|
||||||
}
|
}
|
||||||
}
|
} else if (type === 'normal') {
|
||||||
else if (type === 'normal') {
|
|
||||||
this.audio.src = audio.url;
|
this.audio.src = audio.url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.seek(0);
|
|
||||||
|
|
||||||
if (!this.paused) {
|
|
||||||
this.audio.play();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
theme (color = this.list.audios[this.list.index].theme || this.options.theme, index = this.list.index, isReset = true) {
|
theme(color = this.list.audios[this.list.index].theme || this.options.theme, index = this.list.index, isReset = true) {
|
||||||
if (isReset) {
|
if (isReset) {
|
||||||
this.list.audios[index] && (this.list.audios[index].theme = color);
|
this.list.audios[index] && (this.list.audios[index].theme = color);
|
||||||
}
|
}
|
||||||
@@ -271,7 +264,7 @@ class APlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
seek (time) {
|
seek(time) {
|
||||||
time = Math.max(time, 0);
|
time = Math.max(time, 0);
|
||||||
time = Math.min(time, this.duration);
|
time = Math.min(time, this.duration);
|
||||||
this.audio.currentTime = time;
|
this.audio.currentTime = time;
|
||||||
@@ -279,11 +272,11 @@ class APlayer {
|
|||||||
this.template.ptime.innerHTML = utils.secondToTime(time);
|
this.template.ptime.innerHTML = utils.secondToTime(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
get duration () {
|
get duration() {
|
||||||
return isNaN(this.audio.duration) ? 0 : this.audio.duration;
|
return isNaN(this.audio.duration) ? 0 : this.audio.duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
setUIPlaying () {
|
setUIPlaying() {
|
||||||
if (this.paused) {
|
if (this.paused) {
|
||||||
this.paused = false;
|
this.paused = false;
|
||||||
this.template.button.classList.remove('aplayer-play');
|
this.template.button.classList.remove('aplayer-play');
|
||||||
@@ -306,7 +299,7 @@ class APlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
play () {
|
play() {
|
||||||
this.setUIPlaying();
|
this.setUIPlaying();
|
||||||
|
|
||||||
const playPromise = this.audio.play();
|
const playPromise = this.audio.play();
|
||||||
@@ -320,7 +313,7 @@ class APlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setUIPaused () {
|
setUIPaused() {
|
||||||
if (!this.paused) {
|
if (!this.paused) {
|
||||||
this.paused = true;
|
this.paused = true;
|
||||||
|
|
||||||
@@ -337,19 +330,17 @@ class APlayer {
|
|||||||
this.timer.disable('loading');
|
this.timer.disable('loading');
|
||||||
}
|
}
|
||||||
|
|
||||||
pause () {
|
pause() {
|
||||||
this.setUIPaused();
|
this.setUIPaused();
|
||||||
this.audio.pause();
|
this.audio.pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
switchVolumeIcon () {
|
switchVolumeIcon() {
|
||||||
if (this.volume() >= 0.95) {
|
if (this.volume() >= 0.95) {
|
||||||
this.template.volumeButton.innerHTML = Icons.volumeUp;
|
this.template.volumeButton.innerHTML = Icons.volumeUp;
|
||||||
}
|
} else if (this.volume() > 0) {
|
||||||
else if (this.volume() > 0) {
|
|
||||||
this.template.volumeButton.innerHTML = Icons.volumeDown;
|
this.template.volumeButton.innerHTML = Icons.volumeDown;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.template.volumeButton.innerHTML = Icons.volumeOff;
|
this.template.volumeButton.innerHTML = Icons.volumeOff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -357,7 +348,7 @@ class APlayer {
|
|||||||
/**
|
/**
|
||||||
* Set volume
|
* Set volume
|
||||||
*/
|
*/
|
||||||
volume (percentage, nostorage) {
|
volume(percentage, nostorage) {
|
||||||
percentage = parseFloat(percentage);
|
percentage = parseFloat(percentage);
|
||||||
if (!isNaN(percentage)) {
|
if (!isNaN(percentage)) {
|
||||||
percentage = Math.max(percentage, 0);
|
percentage = Math.max(percentage, 0);
|
||||||
@@ -381,41 +372,40 @@ class APlayer {
|
|||||||
/**
|
/**
|
||||||
* bind events
|
* bind events
|
||||||
*/
|
*/
|
||||||
on (name, callback) {
|
on(name, callback) {
|
||||||
this.events.on(name, callback);
|
this.events.on(name, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* toggle between play and pause
|
* toggle between play and pause
|
||||||
*/
|
*/
|
||||||
toggle () {
|
toggle() {
|
||||||
if (this.template.button.classList.contains('aplayer-play')) {
|
if (this.template.button.classList.contains('aplayer-play')) {
|
||||||
this.play();
|
this.play();
|
||||||
}
|
} else if (this.template.button.classList.contains('aplayer-pause')) {
|
||||||
else if (this.template.button.classList.contains('aplayer-pause')) {
|
|
||||||
this.pause();
|
this.pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// abandoned
|
// abandoned
|
||||||
switchAudio (index) {
|
switchAudio(index) {
|
||||||
this.list.switch(index);
|
this.list.switch(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
// abandoned
|
// abandoned
|
||||||
addAudio (audios) {
|
addAudio(audios) {
|
||||||
this.list.add(audios);
|
this.list.add(audios);
|
||||||
}
|
}
|
||||||
|
|
||||||
// abandoned
|
// abandoned
|
||||||
removeAudio (index) {
|
removeAudio(index) {
|
||||||
this.list.remove(index);
|
this.list.remove(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* destroy this player
|
* destroy this player
|
||||||
*/
|
*/
|
||||||
destroy () {
|
destroy() {
|
||||||
instances.splice(instances.indexOf(this), 1);
|
instances.splice(instances.indexOf(this), 1);
|
||||||
this.pause();
|
this.pause();
|
||||||
this.container.innerHTML = '';
|
this.container.innerHTML = '';
|
||||||
@@ -424,17 +414,16 @@ class APlayer {
|
|||||||
this.events.trigger('destroy');
|
this.events.trigger('destroy');
|
||||||
}
|
}
|
||||||
|
|
||||||
setMode (mode = 'normal') {
|
setMode(mode = 'normal') {
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
if (mode === 'mini') {
|
if (mode === 'mini') {
|
||||||
this.container.classList.add('aplayer-narrow');
|
this.container.classList.add('aplayer-narrow');
|
||||||
}
|
} else if (mode === 'normal') {
|
||||||
else if (mode === 'normal') {
|
|
||||||
this.container.classList.remove('aplayer-narrow');
|
this.container.classList.remove('aplayer-narrow');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
notice (text, time = 2000, opacity = 0.8) {
|
notice(text, time = 2000, opacity = 0.8) {
|
||||||
this.template.notice.innerHTML = text;
|
this.template.notice.innerHTML = text;
|
||||||
this.template.notice.style.opacity = opacity;
|
this.template.notice.style.opacity = opacity;
|
||||||
if (this.noticeTime) {
|
if (this.noticeTime) {
|
||||||
@@ -451,55 +440,49 @@ class APlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prevIndex () {
|
prevIndex() {
|
||||||
if (this.list.audios.length > 1) {
|
if (this.list.audios.length > 1) {
|
||||||
if (this.options.order === 'list') {
|
if (this.options.order === 'list') {
|
||||||
return this.list.index - 1 < 0 ? this.list.audios.length - 1 : this.list.index - 1;
|
return this.list.index - 1 < 0 ? this.list.audios.length - 1 : this.list.index - 1;
|
||||||
}
|
} else if (this.options.order === 'random') {
|
||||||
else if (this.options.order === 'random') {
|
|
||||||
const index = this.randomOrder.indexOf(this.list.index);
|
const index = this.randomOrder.indexOf(this.list.index);
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
return this.randomOrder[this.randomOrder.length - 1];
|
return this.randomOrder[this.randomOrder.length - 1];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return this.randomOrder[index - 1];
|
return this.randomOrder[index - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nextIndex () {
|
nextIndex() {
|
||||||
if (this.list.audios.length > 1) {
|
if (this.list.audios.length > 1) {
|
||||||
if (this.options.order === 'list') {
|
if (this.options.order === 'list') {
|
||||||
return (this.list.index + 1) % this.list.audios.length;
|
return (this.list.index + 1) % this.list.audios.length;
|
||||||
}
|
} else if (this.options.order === 'random') {
|
||||||
else if (this.options.order === 'random') {
|
|
||||||
const index = this.randomOrder.indexOf(this.list.index);
|
const index = this.randomOrder.indexOf(this.list.index);
|
||||||
if (index === this.randomOrder.length - 1) {
|
if (index === this.randomOrder.length - 1) {
|
||||||
return this.randomOrder[0];
|
return this.randomOrder[0];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return this.randomOrder[index + 1];
|
return this.randomOrder[index + 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
skipBack () {
|
skipBack() {
|
||||||
this.list.switch(this.prevIndex());
|
this.list.switch(this.prevIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
skipForward () {
|
skipForward() {
|
||||||
this.list.switch(this.nextIndex());
|
this.list.switch(this.nextIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
static get version () {
|
static get version() {
|
||||||
/* global APLAYER_VERSION */
|
/* global APLAYER_VERSION */
|
||||||
return APLAYER_VERSION;
|
return APLAYER_VERSION;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -1,7 +1,7 @@
|
|||||||
import utils from './utils';
|
import utils from './utils';
|
||||||
|
|
||||||
class Storage {
|
class Storage {
|
||||||
constructor (player) {
|
constructor(player) {
|
||||||
this.storageName = player.options.storageName;
|
this.storageName = player.options.storageName;
|
||||||
|
|
||||||
this.data = JSON.parse(utils.storage.get(this.storageName));
|
this.data = JSON.parse(utils.storage.get(this.storageName));
|
||||||
@@ -11,14 +11,14 @@ class Storage {
|
|||||||
this.data.volume = this.data.volume || player.options.volume;
|
this.data.volume = this.data.volume || player.options.volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
get (key) {
|
get(key) {
|
||||||
return this.data[key];
|
return this.data[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
set (key, value) {
|
set(key, value) {
|
||||||
this.data[key] = value;
|
this.data[key] = value;
|
||||||
utils.storage.set(this.storageName, JSON.stringify(this.data));
|
utils.storage.set(this.storageName, JSON.stringify(this.data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Storage;
|
export default Storage;
|
||||||
|
|||||||
+3
-5
@@ -2,20 +2,19 @@ import Icons from './icons';
|
|||||||
import tplPlayer from '../template/player.art';
|
import tplPlayer from '../template/player.art';
|
||||||
|
|
||||||
class Template {
|
class Template {
|
||||||
constructor (options) {
|
constructor(options) {
|
||||||
this.container = options.container;
|
this.container = options.container;
|
||||||
this.options = options.options;
|
this.options = options.options;
|
||||||
this.randomOrder = options.randomOrder;
|
this.randomOrder = options.randomOrder;
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
init () {
|
init() {
|
||||||
let cover = '';
|
let cover = '';
|
||||||
if (this.options.audio.length) {
|
if (this.options.audio.length) {
|
||||||
if (this.options.order === 'random') {
|
if (this.options.order === 'random') {
|
||||||
cover = this.options.audio[this.randomOrder[0]].cover;
|
cover = this.options.audio[this.randomOrder[0]].cover;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
cover = this.options.audio[0].cover;
|
cover = this.options.audio[0].cover;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,7 +35,6 @@ class Template {
|
|||||||
this.button = this.container.querySelector('.aplayer-button');
|
this.button = this.container.querySelector('.aplayer-button');
|
||||||
this.body = this.container.querySelector('.aplayer-body');
|
this.body = this.container.querySelector('.aplayer-body');
|
||||||
this.list = this.container.querySelector('.aplayer-list');
|
this.list = this.container.querySelector('.aplayer-list');
|
||||||
this.listOl = this.container.querySelector('.aplayer-list ol');
|
|
||||||
this.listCurs = this.container.querySelectorAll('.aplayer-list-cur');
|
this.listCurs = this.container.querySelectorAll('.aplayer-list-cur');
|
||||||
this.played = this.container.querySelector('.aplayer-played');
|
this.played = this.container.querySelector('.aplayer-played');
|
||||||
this.loaded = this.container.querySelector('.aplayer-loaded');
|
this.loaded = this.container.querySelector('.aplayer-loaded');
|
||||||
|
|||||||
+11
-17
@@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
class Timer {
|
class Timer {
|
||||||
constructor (player) {
|
constructor(player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
||||||
window.requestAnimationFrame = (() =>
|
window.requestAnimationFrame = (() =>
|
||||||
@@ -9,23 +8,22 @@ class Timer {
|
|||||||
window.mozRequestAnimationFrame ||
|
window.mozRequestAnimationFrame ||
|
||||||
window.oRequestAnimationFrame ||
|
window.oRequestAnimationFrame ||
|
||||||
window.msRequestAnimationFrame ||
|
window.msRequestAnimationFrame ||
|
||||||
function (callback) {
|
function(callback) {
|
||||||
window.setTimeout(callback, 1000 / 60);
|
window.setTimeout(callback, 1000 / 60);
|
||||||
}
|
})();
|
||||||
)();
|
|
||||||
|
|
||||||
this.types = ['loading'];
|
this.types = ['loading'];
|
||||||
|
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
init () {
|
init() {
|
||||||
this.types.forEach((item) => {
|
this.types.forEach((item) => {
|
||||||
this[`init${item}Checker`]();
|
this[`init${item}Checker`]();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initloadingChecker () {
|
initloadingChecker() {
|
||||||
let lastPlayPos = 0;
|
let lastPlayPos = 0;
|
||||||
let currentPlayPos = 0;
|
let currentPlayPos = 0;
|
||||||
let bufferingDetected = false;
|
let bufferingDetected = false;
|
||||||
@@ -33,15 +31,11 @@ class Timer {
|
|||||||
if (this.enableloadingChecker) {
|
if (this.enableloadingChecker) {
|
||||||
// whether the audio is buffering
|
// whether the audio is buffering
|
||||||
currentPlayPos = this.player.audio.currentTime;
|
currentPlayPos = this.player.audio.currentTime;
|
||||||
if (!bufferingDetected
|
if (!bufferingDetected && currentPlayPos === lastPlayPos && !this.player.audio.paused) {
|
||||||
&& currentPlayPos === lastPlayPos
|
|
||||||
&& !this.player.audio.paused) {
|
|
||||||
this.player.container.classList.add('aplayer-loading');
|
this.player.container.classList.add('aplayer-loading');
|
||||||
bufferingDetected = true;
|
bufferingDetected = true;
|
||||||
}
|
}
|
||||||
if (bufferingDetected
|
if (bufferingDetected && currentPlayPos > lastPlayPos && !this.player.audio.paused) {
|
||||||
&& currentPlayPos > lastPlayPos
|
|
||||||
&& !this.player.audio.paused) {
|
|
||||||
this.player.container.classList.remove('aplayer-loading');
|
this.player.container.classList.remove('aplayer-loading');
|
||||||
bufferingDetected = false;
|
bufferingDetected = false;
|
||||||
}
|
}
|
||||||
@@ -50,7 +44,7 @@ class Timer {
|
|||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
enable (type) {
|
enable(type) {
|
||||||
this[`enable${type}Checker`] = true;
|
this[`enable${type}Checker`] = true;
|
||||||
|
|
||||||
if (type === 'fps') {
|
if (type === 'fps') {
|
||||||
@@ -58,11 +52,11 @@ class Timer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
disable (type) {
|
disable(type) {
|
||||||
this[`enable${type}Checker`] = false;
|
this[`enable${type}Checker`] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy () {
|
destroy() {
|
||||||
this.types.forEach((item) => {
|
this.types.forEach((item) => {
|
||||||
this[`enable${item}Checker`] = false;
|
this[`enable${item}Checker`] = false;
|
||||||
this[`${item}Checker`] && clearInterval(this[`${item}Checker`]);
|
this[`${item}Checker`] && clearInterval(this[`${item}Checker`]);
|
||||||
@@ -70,4 +64,4 @@ class Timer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Timer;
|
export default Timer;
|
||||||
|
|||||||
+16
-50
@@ -1,56 +1,20 @@
|
|||||||
const isMobile = /mobile/i.test(window.navigator.userAgent);
|
const isMobile = /mobile/i.test(window.navigator.userAgent);
|
||||||
|
|
||||||
const utils = {
|
const utils = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse second to time string
|
* Parse second to time string
|
||||||
*
|
*
|
||||||
* @param {Number} second
|
* @param {Number} second
|
||||||
* @return {String} 00:00 or 00:00:00
|
* @return {String} 00:00 or 00:00:00
|
||||||
*/
|
*/
|
||||||
secondToTime: (second) => {
|
secondToTime: (second) => {
|
||||||
const add0 = (num) => num < 10 ? '0' + num : '' + num;
|
const add0 = (num) => (num < 10 ? '0' + num : '' + num);
|
||||||
const hour = Math.floor(second / 3600);
|
const hour = Math.floor(second / 3600);
|
||||||
const min = Math.floor((second - hour * 3600) / 60);
|
const min = Math.floor((second - hour * 3600) / 60);
|
||||||
const sec = Math.floor(second - hour * 3600 - min * 60);
|
const sec = Math.floor(second - hour * 3600 - min * 60);
|
||||||
return (hour > 0 ? [hour, min, sec] : [min, sec]).map(add0).join(':');
|
return (hour > 0 ? [hour, min, sec] : [min, sec]).map(add0).join(':');
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* control play progress
|
|
||||||
*/
|
|
||||||
// get element's view position
|
|
||||||
getElementViewLeft: (element) => {
|
|
||||||
let actualLeft = element.offsetLeft;
|
|
||||||
let current = element.offsetParent;
|
|
||||||
const elementScrollLeft = document.body.scrollLeft + document.documentElement.scrollLeft;
|
|
||||||
if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement) {
|
|
||||||
while (current !== null) {
|
|
||||||
actualLeft += current.offsetLeft;
|
|
||||||
current = current.offsetParent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
while (current !== null && current !== element) {
|
|
||||||
actualLeft += current.offsetLeft;
|
|
||||||
current = current.offsetParent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return actualLeft - elementScrollLeft;
|
|
||||||
},
|
|
||||||
|
|
||||||
getElementViewTop: (element, noScrollTop) => {
|
|
||||||
let actualTop = element.offsetTop;
|
|
||||||
let current = element.offsetParent;
|
|
||||||
let elementScrollTop = 0;
|
|
||||||
while (current !== null) {
|
|
||||||
actualTop += current.offsetTop;
|
|
||||||
current = current.offsetParent;
|
|
||||||
}
|
|
||||||
elementScrollTop = document.body.scrollTop + document.documentElement.scrollTop;
|
|
||||||
return noScrollTop ? actualTop : actualTop - elementScrollTop;
|
|
||||||
},
|
|
||||||
|
|
||||||
isMobile: isMobile,
|
isMobile: isMobile,
|
||||||
|
|
||||||
storage: {
|
storage: {
|
||||||
@@ -58,20 +22,20 @@ const utils = {
|
|||||||
localStorage.setItem(key, value);
|
localStorage.setItem(key, value);
|
||||||
},
|
},
|
||||||
|
|
||||||
get: (key) => localStorage.getItem(key)
|
get: (key) => localStorage.getItem(key),
|
||||||
},
|
},
|
||||||
|
|
||||||
nameMap: {
|
nameMap: {
|
||||||
dragStart: isMobile ? 'touchstart' : 'mousedown',
|
dragStart: isMobile ? 'touchstart' : 'mousedown',
|
||||||
dragMove: isMobile ? 'touchmove' : 'mousemove',
|
dragMove: isMobile ? 'touchmove' : 'mousemove',
|
||||||
dragEnd: isMobile ? 'touchend' : 'mouseup'
|
dragEnd: isMobile ? 'touchend' : 'mouseup',
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get random order, using Fisher–Yates shuffle
|
* get random order, using Fisher–Yates shuffle
|
||||||
*/
|
*/
|
||||||
randomOrder: (length) => {
|
randomOrder: (length) => {
|
||||||
function shuffle (arr) {
|
function shuffle(arr) {
|
||||||
for (let i = arr.length - 1; i >= 0; i--) {
|
for (let i = arr.length - 1; i >= 0; i--) {
|
||||||
const randomIndex = Math.floor(Math.random() * (i + 1));
|
const randomIndex = Math.floor(Math.random() * (i + 1));
|
||||||
const itemAtIndex = arr[randomIndex];
|
const itemAtIndex = arr[randomIndex];
|
||||||
@@ -80,10 +44,12 @@ const utils = {
|
|||||||
}
|
}
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
return shuffle([...Array(length)].map(function (item, i) {
|
return shuffle(
|
||||||
return i;
|
[...Array(length)].map(function(item, i) {
|
||||||
}));
|
return i;
|
||||||
}
|
})
|
||||||
|
);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default utils;
|
export default utils;
|
||||||
|
|||||||
+14
-18
@@ -63,25 +63,21 @@
|
|||||||
<div class="aplayer-notice"></div>
|
<div class="aplayer-notice"></div>
|
||||||
<div class="aplayer-miniswitcher"><button class="aplayer-icon">{{@ icons.right }}</button></div>
|
<div class="aplayer-miniswitcher"><button class="aplayer-icon">{{@ icons.right }}</button></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="aplayer-list{{ if options.listFolded }} aplayer-list-hide{{ /if }}"{{ if options.listMaxHeight }} style="max-height: {{ options.listMaxHeight }}"{{ /if }}>
|
<ol class="aplayer-list{{ if options.listFolded }} aplayer-list-hide{{ /if }}">
|
||||||
<ol{{ if options.listMaxHeight }} style="max-height: {{ options.listMaxHeight }}"{{ /if }}>
|
{{ include './list-item.art' getObject({
|
||||||
{{ include './list-item.art' getObject({
|
theme: options.theme,
|
||||||
theme: options.theme,
|
audio: options.audio,
|
||||||
audio: options.audio,
|
index: 1
|
||||||
index: 1
|
}) }}
|
||||||
}) }}
|
</ol>
|
||||||
</ol>
|
|
||||||
</div>
|
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<div class="aplayer-list{{ if options.listFolded }} aplayer-list-hide{{ /if }}"{{ if options.listMaxHeight }} style="max-height: {{ options.listMaxHeight }}"{{ /if }}>
|
<ol class="aplayer-list{{ if options.listFolded }} aplayer-list-hide{{ /if }}">
|
||||||
<ol{{ if options.listMaxHeight }} style="max-height: {{ options.listMaxHeight }}"{{ /if }}>
|
{{ include './list-item.art' getObject({
|
||||||
{{ include './list-item.art' getObject({
|
theme: options.theme,
|
||||||
theme: options.theme,
|
audio: options.audio,
|
||||||
audio: options.audio,
|
index: 1
|
||||||
index: 1
|
}) }}
|
||||||
}) }}
|
</ol>
|
||||||
</ol>
|
|
||||||
</div>
|
|
||||||
<div class="aplayer-body">
|
<div class="aplayer-body">
|
||||||
<div class="aplayer-pic" style="{{ if cover }}background-image: url("{{ cover }}");{{ /if }}background-color: {{ options.theme }};">
|
<div class="aplayer-pic" style="{{ if cover }}background-image: url("{{ cover }}");{{ /if }}background-color: {{ options.theme }};">
|
||||||
<div class="aplayer-button aplayer-play">{{@ icons.play }}</div>
|
<div class="aplayer-button aplayer-play">{{@ icons.play }}</div>
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# https://tea.xyz/what-is-this-file
|
||||||
|
---
|
||||||
|
version: 1.0.0
|
||||||
|
codeOwners:
|
||||||
|
- '0x185bfcef7b37010e2511309048a130f477f54fBf'
|
||||||
|
quorum: 1
|
||||||
+29
-38
@@ -1,17 +1,17 @@
|
|||||||
/* eslint-disable no-undef */
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
const GitRevisionPlugin = require('git-revision-webpack-plugin');
|
const GitRevisionPlugin = require('git-revision-webpack-plugin');
|
||||||
const gitRevisionPlugin = new GitRevisionPlugin();
|
const gitRevisionPlugin = new GitRevisionPlugin();
|
||||||
|
const autoprefixer = require('autoprefixer');
|
||||||
|
const cssnano = require('cssnano');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
mode: 'development',
|
mode: 'development',
|
||||||
|
|
||||||
devtool: 'cheap-module-source-map',
|
devtool: 'cheap-module-source-map',
|
||||||
|
|
||||||
entry: {
|
entry: {
|
||||||
'APlayer': './src/js/index.js'
|
APlayer: './src/js/index.js',
|
||||||
},
|
},
|
||||||
|
|
||||||
output: {
|
output: {
|
||||||
@@ -21,23 +21,17 @@ module.exports = {
|
|||||||
libraryTarget: 'umd',
|
libraryTarget: 'umd',
|
||||||
libraryExport: 'default',
|
libraryExport: 'default',
|
||||||
umdNamedDefine: true,
|
umdNamedDefine: true,
|
||||||
publicPath: '/'
|
publicPath: '/',
|
||||||
},
|
},
|
||||||
|
|
||||||
resolve: {
|
resolve: {
|
||||||
modules: ['node_modules'],
|
modules: ['node_modules'],
|
||||||
extensions: ['.js', '.scss']
|
extensions: ['.js', '.scss'],
|
||||||
},
|
},
|
||||||
|
|
||||||
module: {
|
module: {
|
||||||
strictExportPresence: true,
|
strictExportPresence: true,
|
||||||
rules: [
|
rules: [
|
||||||
{
|
|
||||||
test: /\.js$/,
|
|
||||||
enforce: 'pre',
|
|
||||||
loader: 'eslint-loader',
|
|
||||||
include: path.resolve(__dirname, '../src/js'),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
test: /\.js$/,
|
test: /\.js$/,
|
||||||
use: [
|
use: [
|
||||||
@@ -45,10 +39,10 @@ module.exports = {
|
|||||||
loader: 'babel-loader',
|
loader: 'babel-loader',
|
||||||
options: {
|
options: {
|
||||||
cacheDirectory: true,
|
cacheDirectory: true,
|
||||||
presets: ['env']
|
presets: ['@babel/preset-env'],
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.scss$/,
|
test: /\.scss$/,
|
||||||
@@ -57,36 +51,34 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
loader: 'css-loader',
|
loader: 'css-loader',
|
||||||
options: {
|
options: {
|
||||||
importLoaders: 1
|
importLoaders: 1,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
loader: 'postcss-loader',
|
loader: 'postcss-loader',
|
||||||
options: {
|
options: {
|
||||||
config: {
|
plugins: [autoprefixer, cssnano],
|
||||||
path: path.join(__dirname, 'postcss.config.js')
|
},
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
'sass-loader'
|
'sass-loader',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.(png|jpg)$/,
|
test: /\.(png|jpg)$/,
|
||||||
loader: 'url-loader',
|
loader: 'url-loader',
|
||||||
options: {
|
options: {
|
||||||
'limit': 40000
|
limit: 40000,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.svg$/,
|
test: /\.svg$/,
|
||||||
loader: 'svg-inline-loader'
|
loader: 'svg-inline-loader',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.art$/,
|
test: /\.art$/,
|
||||||
loader: 'art-template-loader'
|
loader: 'art-template-loader',
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
devServer: {
|
devServer: {
|
||||||
@@ -96,29 +88,28 @@ module.exports = {
|
|||||||
quiet: false,
|
quiet: false,
|
||||||
open: true,
|
open: true,
|
||||||
historyApiFallback: {
|
historyApiFallback: {
|
||||||
disableDotRule: true
|
disableDotRule: true,
|
||||||
},
|
},
|
||||||
watchOptions: {
|
watchOptions: {
|
||||||
ignored: /node_modules/
|
ignored: /node_modules/,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
APLAYER_VERSION: `"${require('../package.json').version}"`,
|
APLAYER_VERSION: `"${require('../package.json').version}"`,
|
||||||
GIT_HASH: JSON.stringify(gitRevisionPlugin.version())
|
GIT_HASH: JSON.stringify(gitRevisionPlugin.version()),
|
||||||
})
|
}),
|
||||||
],
|
],
|
||||||
|
|
||||||
node: {
|
node: {
|
||||||
dgram: 'empty',
|
dgram: 'empty',
|
||||||
fs: 'empty',
|
fs: 'empty',
|
||||||
net: 'empty',
|
net: 'empty',
|
||||||
tls: 'empty'
|
tls: 'empty',
|
||||||
},
|
},
|
||||||
|
|
||||||
performance: {
|
performance: {
|
||||||
hints: false
|
hints: false,
|
||||||
}
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
plugins: {
|
|
||||||
'autoprefixer': {}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
+23
-38
@@ -1,12 +1,11 @@
|
|||||||
/* eslint-disable no-undef */
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
||||||
const GitRevisionPlugin = require('git-revision-webpack-plugin');
|
const GitRevisionPlugin = require('git-revision-webpack-plugin');
|
||||||
const gitRevisionPlugin = new GitRevisionPlugin();
|
const gitRevisionPlugin = new GitRevisionPlugin();
|
||||||
|
const autoprefixer = require('autoprefixer');
|
||||||
|
const cssnano = require('cssnano');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
mode: 'production',
|
mode: 'production',
|
||||||
|
|
||||||
bail: true,
|
bail: true,
|
||||||
@@ -14,7 +13,7 @@ module.exports = {
|
|||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
|
|
||||||
entry: {
|
entry: {
|
||||||
'APlayer': './src/js/index.js'
|
APlayer: './src/js/index.js',
|
||||||
},
|
},
|
||||||
|
|
||||||
output: {
|
output: {
|
||||||
@@ -24,23 +23,17 @@ module.exports = {
|
|||||||
libraryTarget: 'umd',
|
libraryTarget: 'umd',
|
||||||
libraryExport: 'default',
|
libraryExport: 'default',
|
||||||
umdNamedDefine: true,
|
umdNamedDefine: true,
|
||||||
publicPath: '/'
|
publicPath: '/',
|
||||||
},
|
},
|
||||||
|
|
||||||
resolve: {
|
resolve: {
|
||||||
modules: ['node_modules'],
|
modules: ['node_modules'],
|
||||||
extensions: ['.js', '.scss']
|
extensions: ['.js', '.scss'],
|
||||||
},
|
},
|
||||||
|
|
||||||
module: {
|
module: {
|
||||||
strictExportPresence: true,
|
strictExportPresence: true,
|
||||||
rules: [
|
rules: [
|
||||||
{
|
|
||||||
test: /\.js$/,
|
|
||||||
enforce: 'pre',
|
|
||||||
loader: 'eslint-loader',
|
|
||||||
include: path.resolve(__dirname, '../src/js'),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
test: /\.js$/,
|
test: /\.js$/,
|
||||||
use: [
|
use: [
|
||||||
@@ -48,61 +41,54 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
loader: 'babel-loader',
|
loader: 'babel-loader',
|
||||||
options: {
|
options: {
|
||||||
compact: true,
|
cacheDirectory: true,
|
||||||
presets: ['env']
|
presets: ['@babel/preset-env'],
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.scss$/,
|
test: /\.scss$/,
|
||||||
use: [
|
use: [
|
||||||
MiniCssExtractPlugin.loader,
|
'style-loader',
|
||||||
{
|
{
|
||||||
loader: 'css-loader',
|
loader: 'css-loader',
|
||||||
options: {
|
options: {
|
||||||
importLoaders: 1,
|
importLoaders: 1,
|
||||||
minimize: true,
|
},
|
||||||
sourceMap: true
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
loader: 'postcss-loader',
|
loader: 'postcss-loader',
|
||||||
options: {
|
options: {
|
||||||
config: {
|
plugins: [autoprefixer, cssnano],
|
||||||
path: path.join(__dirname, 'postcss.config.js')
|
},
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
'sass-loader',
|
'sass-loader',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.(png|jpg)$/,
|
test: /\.(png|jpg)$/,
|
||||||
loader: 'url-loader',
|
loader: 'url-loader',
|
||||||
options: {
|
options: {
|
||||||
'limit': 40000
|
limit: 40000,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.svg$/,
|
test: /\.svg$/,
|
||||||
loader: 'svg-inline-loader'
|
loader: 'svg-inline-loader',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.art$/,
|
test: /\.art$/,
|
||||||
loader: 'art-template-loader'
|
loader: 'art-template-loader',
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
APLAYER_VERSION: `"${require('../package.json').version}"`,
|
APLAYER_VERSION: `"${require('../package.json').version}"`,
|
||||||
GIT_HASH: JSON.stringify(gitRevisionPlugin.version())
|
GIT_HASH: JSON.stringify(gitRevisionPlugin.version()),
|
||||||
}),
|
}),
|
||||||
new MiniCssExtractPlugin({
|
|
||||||
filename: '[name].min.css'
|
|
||||||
})
|
|
||||||
],
|
],
|
||||||
|
|
||||||
node: {
|
node: {
|
||||||
@@ -110,6 +96,5 @@ module.exports = {
|
|||||||
fs: 'empty',
|
fs: 'empty',
|
||||||
net: 'empty',
|
net: 'empty',
|
||||||
tls: 'empty',
|
tls: 'empty',
|
||||||
}
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user