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,74 +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?
|
||||||
|
|
||||||
- [Jelly Rue](http://jellyrue.com/): Jelly Rue, an indie pop-rock band from Tartu.
|
- [bilibili](https://www.bilibili.com/): 国内知名的视频弹幕网站
|
||||||
- [LLSupport](https://www.lovelivesupport.com/): This site provides a lot of information about LoveLive
|
- [黑客派](https://hacpai.com/): 程序员和设计师的聚集地,一个活跃的小众社区
|
||||||
- [站长之家](http://www.chinaz.com/15year/index.html): 针对中文站点提供资讯、技术、资源、服务
|
- [浙江大学 CC98 论坛](https://zh.wikipedia.org/wiki/CC98%E8%AE%BA%E5%9D%9B): 浙江大学校网内规模最大的论坛,中国各大学中较活跃的 BBS 之一
|
||||||
- [Justice_Eternal吧曲谱资源站](http://lightmoon.pw): 一个非营利的、兴趣驱动的曲谱编辑、发布与整理解决方案
|
- [Jelly Rue](http://jellyrue.com/): Jelly Rue, an indie pop-rock band from Tartu.
|
||||||
- [Justice_Eternal吧曲谱资源站(移动端)](http://jefun.top/): 一个非营利的、兴趣驱动的曲谱编辑、发布与整理解决方案
|
- [Opus](http://www.opusopus.co/): An artist-exploration data visualization application
|
||||||
- [歌词千寻](https://www.lrcgc.com/diy): 歌词千寻LRC歌词编辑器
|
- [站长之家](http://www.chinaz.com/15year/index.html): 针对中文站点提供资讯、技术、资源、服务
|
||||||
- [iSearch](http://i.oppsu.cn): 一个提供 iTunes 搜索,试听,高清专辑封面获取,查看最新音乐动态等综合性平台
|
- [LLSupport](https://www.lovelivesupport.com/): This site provides a lot of information about LoveLive
|
||||||
- [LRC歌词编辑器](https://github.com/MoeFE/Lyric): 一款非常实用的在线LRC歌词编辑器
|
- [歌词千寻](https://www.lrcgc.com/diy): 每日更新的 LRC 歌词网站
|
||||||
- [Аэростатика](https://aerostatica.ru/)
|
- [iSearch](http://i.oppsu.cn): 一个提供 iTunes 搜索,试听,高清专辑封面获取,查看最新音乐动态等综合性平台
|
||||||
|
- [LRC 歌词编辑器](https://github.com/MoeFE/Lyric): 一款非常实用的在线 LRC 歌词编辑器
|
||||||
## Donate
|
- [Аэростатика](https://aerostatica.ru/)
|
||||||
|
- [HealthDig](https://healthdig.co): 每天只需两分钟的重点新闻资讯
|
||||||
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.
|
- 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
|
||||||
|
|
||||||
@@ -112,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>
|
||||||
|
|||||||
+68
-38
@@ -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,34 +114,49 @@ 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();
|
||||||
ap5.on('switchaudio', (index) => {
|
const image = new Image();
|
||||||
if (!ap5.options.audio[index].theme) {
|
const xhr = new XMLHttpRequest();
|
||||||
colorThief.getColorAsync(ap5.options.audio[index].cover, function (color) {
|
const setTheme = (index) => {
|
||||||
ap5.theme(`rgb(${color[0]}, ${color[1]}, ${color[2]})`, index);
|
if (!ap5.list.audios[index].theme) {
|
||||||
});
|
xhr.onload = function(){
|
||||||
|
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);
|
||||||
|
ap5.on('listswitch', (data) => {
|
||||||
|
setTheme(data.index);
|
||||||
});
|
});
|
||||||
|
|
||||||
const ap6 = new APlayer({
|
const ap6 = new APlayer({
|
||||||
@@ -150,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'
|
||||||
}]
|
}]
|
||||||
@@ -162,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',
|
||||||
}],
|
}],
|
||||||
@@ -183,3 +198,18 @@ const ap7 = new APlayer({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const ap8 = new APlayer({
|
||||||
|
element: document.getElementById('player8'),
|
||||||
|
mutex: true,
|
||||||
|
theme: '#ad7a86',
|
||||||
|
order: 'random',
|
||||||
|
lrcType: 3,
|
||||||
|
fixed: true,
|
||||||
|
});
|
||||||
|
$.ajax({
|
||||||
|
url: 'https://api.i-meto.com/meting/api?server=netease&type=playlist&id=35798529',
|
||||||
|
success: function (list) {
|
||||||
|
ap8.list.add(JSON.parse(list));
|
||||||
|
}
|
||||||
|
});
|
||||||
+15
-7
@@ -12,7 +12,7 @@
|
|||||||
max-width: 32rem;
|
max-width: 32rem;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
margin-bottom: 50px;
|
margin-bottom: 150px;
|
||||||
}
|
}
|
||||||
h1 {
|
h1 {
|
||||||
font-size: 54px;
|
font-size: 54px;
|
||||||
@@ -43,6 +43,7 @@
|
|||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/vconsole/dist/vconsole.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/hls.js/dist/hls.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/hls.js/dist/hls.min.js"></script>
|
||||||
<script src="APlayer.js"></script>
|
<script src="APlayer.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/color-thief-don@2.0.2/src/color-thief.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/color-thief-don@2.0.2/src/color-thief.js"></script>
|
||||||
@@ -65,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>
|
||||||
@@ -95,7 +96,14 @@
|
|||||||
<h3>HLS</h3>
|
<h3>HLS</h3>
|
||||||
<div id="player6" class="aplayer"></div>
|
<div id="player6" class="aplayer"></div>
|
||||||
<div id="player7" class="aplayer"></div>
|
<div id="player7" class="aplayer"></div>
|
||||||
|
<div id="player8" class="aplayer"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
if (/mobile/i.test(window.navigator.userAgent)) {
|
||||||
|
new VConsole();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/jquery"></script>
|
||||||
<script src="demo.js"></script>
|
<script src="demo.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Vendored
+2
-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
+110
-48
@@ -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);
|
||||||
```
|
```
|
||||||
@@ -67,6 +64,7 @@ const ap = new APlayer(options);
|
|||||||
Name | Default | Description
|
Name | Default | Description
|
||||||
----|-------|----
|
----|-------|----
|
||||||
container | document.querySelector('.aplayer') | player container
|
container | document.querySelector('.aplayer') | player container
|
||||||
|
fixed | false | enable fixed mode, [see more details](https://aplayer.js.org/#/home?id=fixed-mode)
|
||||||
mini | false | enable mini mode, [see more details](https://aplayer.js.org/#/home?id=mini-mode)
|
mini | false | enable mini mode, [see more details](https://aplayer.js.org/#/home?id=mini-mode)
|
||||||
autoplay | false | audio autoplay
|
autoplay | false | audio autoplay
|
||||||
theme | '#b7daff' | main color
|
theme | '#b7daff' | main color
|
||||||
@@ -87,6 +85,7 @@ mutex | true | prevent to play multiple player at the same time, pause other pla
|
|||||||
lrcType | 0 | [see more details](https://aplayer.js.org/#/home?id=lrc)
|
lrcType | 0 | [see more details](https://aplayer.js.org/#/home?id=lrc)
|
||||||
listFolded | false | indicate whether list should folded at first
|
listFolded | false | indicate whether list should folded at first
|
||||||
listMaxHeight | - | list max height
|
listMaxHeight | - | list max height
|
||||||
|
storageName | 'aplayer-setting' | localStorage key that store player setting
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
@@ -106,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: [
|
||||||
{
|
{
|
||||||
@@ -147,33 +146,6 @@ const ap = new APlayer({
|
|||||||
|
|
||||||
+ `ap.on(event: string, handler: function)`: bind audio and player events, [see more details](https://aplayer.js.org/#/home?id=event-binding)
|
+ `ap.on(event: string, handler: function)`: bind audio and player events, [see more details](https://aplayer.js.org/#/home?id=event-binding)
|
||||||
|
|
||||||
+ `ap.switchAudio(index: number)`: switch audio list
|
|
||||||
|
|
||||||
```js
|
|
||||||
ap.switchAudio(1);
|
|
||||||
```
|
|
||||||
|
|
||||||
+ `ap.addAudio(audio)`: add new audios to the list
|
|
||||||
|
|
||||||
```js
|
|
||||||
ap.addAudio([
|
|
||||||
{
|
|
||||||
name: 'name',
|
|
||||||
artist: 'artist',
|
|
||||||
url: 'url.mp3',
|
|
||||||
cover: 'cover.jpg',
|
|
||||||
lrc: 'lrc.lrc',
|
|
||||||
theme: '#ebd0c2'
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
```
|
|
||||||
|
|
||||||
+ `ap.removeAudio(index: number)`: remove audio from the list
|
|
||||||
|
|
||||||
```js
|
|
||||||
ap.removeAudio(1);
|
|
||||||
```
|
|
||||||
|
|
||||||
+ `ap.volume(percentage: number, nostorage: boolean)`: set audio volume
|
+ `ap.volume(percentage: number, nostorage: boolean)`: set audio volume
|
||||||
|
|
||||||
```js
|
```js
|
||||||
@@ -196,8 +168,55 @@ const ap = new APlayer({
|
|||||||
ap.notice('Amazing player', 2000, 0.8);
|
ap.notice('Amazing player', 2000, 0.8);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
+ `ap.skipBack()`: skip to previous audio
|
||||||
|
|
||||||
|
+ `ap.skipForward()`: skip to next audio
|
||||||
|
|
||||||
+ `ap.destroy()`: destroy player
|
+ `ap.destroy()`: destroy player
|
||||||
|
|
||||||
|
+ `ap.lrc`
|
||||||
|
|
||||||
|
+ `ap.lrc.show()`: show lrc
|
||||||
|
|
||||||
|
+ `ap.lrc.hide()`: hide lrc
|
||||||
|
|
||||||
|
+ `ap.lrc.toggle()`: toggle lrc between show and hide
|
||||||
|
|
||||||
|
+ `ap.list`
|
||||||
|
|
||||||
|
+ `ap.list.show()`: show list
|
||||||
|
|
||||||
|
+ `ap.list.hide()`: hide list
|
||||||
|
|
||||||
|
+ `ap.list.toggle()`: toggle list between show and hide
|
||||||
|
|
||||||
|
+ `ap.list.add(audios: array | object)`: add new audios to the list
|
||||||
|
|
||||||
|
```js
|
||||||
|
ap.list.add([{
|
||||||
|
name: 'name',
|
||||||
|
artist: 'artist',
|
||||||
|
url: 'url.mp3',
|
||||||
|
cover: 'cover.jpg',
|
||||||
|
lrc: 'lrc.lrc',
|
||||||
|
theme: '#ebd0c2'
|
||||||
|
}]);
|
||||||
|
```
|
||||||
|
|
||||||
|
+ `ap.list.remove(index: number)`: remove an audio from the list
|
||||||
|
|
||||||
|
```js
|
||||||
|
ap.list.remove(1);
|
||||||
|
```
|
||||||
|
|
||||||
|
+ `ap.list.switch()`: switch to an audio in the list
|
||||||
|
|
||||||
|
```js
|
||||||
|
ap.list.switch(1);
|
||||||
|
```
|
||||||
|
|
||||||
|
+ `ap.list.clear()`: remove all audios from the list
|
||||||
|
|
||||||
+ `ap.audio`: native audio
|
+ `ap.audio`: native audio
|
||||||
|
|
||||||
+ `ap.audio.currentTime`: returns the current playback position
|
+ `ap.audio.currentTime`: returns the current playback position
|
||||||
@@ -218,7 +237,7 @@ ap.on('ended', function () {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
Video events
|
Audio events
|
||||||
|
|
||||||
- abort
|
- abort
|
||||||
- canplay
|
- canplay
|
||||||
@@ -246,12 +265,17 @@ Video events
|
|||||||
|
|
||||||
Player events
|
Player events
|
||||||
|
|
||||||
- switchaudio
|
- listshow
|
||||||
- addaudio
|
- listhide
|
||||||
- removeaudio
|
- listadd
|
||||||
|
- listremove
|
||||||
|
- listswitch
|
||||||
|
- listclear
|
||||||
|
- noticeshow
|
||||||
|
- noticehide
|
||||||
- destroy
|
- destroy
|
||||||
- notice_show
|
- lrcshow
|
||||||
- notice_hide
|
- lrchide
|
||||||
|
|
||||||
## LRC
|
## LRC
|
||||||
|
|
||||||
@@ -369,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: [
|
||||||
{
|
{
|
||||||
@@ -392,10 +416,33 @@ const ap = new APlayer({
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Fixed mode
|
||||||
|
|
||||||
|
APlayer can be fixed to page bottom via fixed mode, fixed mode is a very different mode, enjoy it!
|
||||||
|
|
||||||
|
<div class="aplayer-wrap">
|
||||||
|
<div id="aplayer9"><button class="docute-button load">Click to load player</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
```js
|
||||||
|
const ap = new APlayer({
|
||||||
|
container: document.getElementById('player'),
|
||||||
|
fixed: true,
|
||||||
|
audio: [{
|
||||||
|
name: 'name',
|
||||||
|
artist: 'artist',
|
||||||
|
url: 'url.mp3',
|
||||||
|
cover: 'cover.jpg',
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
## Mini mode
|
## Mini mode
|
||||||
|
|
||||||
If you don't have enough space for normal player, mini mode might be your choice.
|
If you don't have enough space for normal player, mini mode might be your choice.
|
||||||
|
|
||||||
|
Please note that mini mode is conflicted with fixed mode.
|
||||||
|
|
||||||
<div class="aplayer-wrap">
|
<div class="aplayer-wrap">
|
||||||
<div id="aplayer6"><button class="docute-button load">Click to load player</div>
|
<div id="aplayer6"><button class="docute-button load">Click to load player</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -505,12 +552,27 @@ const ap = new APlayer({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const colorThief = new ColorThief();
|
const colorThief = new ColorThief();
|
||||||
ap.on('switchaudio', (index) => {
|
const image = new Image();
|
||||||
if (!ap.options.audio[index].theme) {
|
const xhr = new XMLHttpRequest();
|
||||||
colorThief.getColorAsync(ap.options.audio[index].cover, (color) => {
|
const setTheme = (index) => {
|
||||||
ap.theme(`rgb(${color[0]}, ${color[1]}, ${color[2]})`, index);
|
if (!ap.list.audios[index].theme) {
|
||||||
});
|
xhr.onload = function(){
|
||||||
|
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);
|
||||||
|
ap.on('listswitch', (index) => {
|
||||||
|
setTheme(index);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -524,4 +586,4 @@ ap.on('switchaudio', (index) => {
|
|||||||
|
|
||||||
### 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.
|
||||||
+122
-52
@@ -47,15 +47,25 @@ 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 () {
|
||||||
console.log('landing:updated');
|
console.log('landing:updated');
|
||||||
clearPlayer();
|
clearPlayer();
|
||||||
|
aplayer0();
|
||||||
aplayer1();
|
aplayer1();
|
||||||
});
|
});
|
||||||
context.event.on('content:updated', function () {
|
context.event.on('content:updated', function () {
|
||||||
@@ -72,8 +82,8 @@ function player () {
|
|||||||
|
|
||||||
function clearPlayer () {
|
function clearPlayer () {
|
||||||
for (let i = 0; i < 10; i++) {
|
for (let i = 0; i < 10; i++) {
|
||||||
if (window['ap' + (i + 1)]) {
|
if (window['ap' + i]) {
|
||||||
window['ap' + (i + 1)].destroy();
|
window['ap' + i].destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,36 +96,66 @@ 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'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function aplayer0 () {
|
||||||
|
window.ap0 = new APlayer({
|
||||||
|
container: document.getElementById('aplayer0'),
|
||||||
|
fixed: true,
|
||||||
|
lrcType: 3,
|
||||||
|
audio: [{
|
||||||
|
name: '前前前世',
|
||||||
|
artist: 'RADWIMPS',
|
||||||
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.mp3',
|
||||||
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.jpg',
|
||||||
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.lrc',
|
||||||
|
theme: '#505d6b'
|
||||||
|
}, {
|
||||||
|
name: 'トリカゴ',
|
||||||
|
artist: 'XX:me',
|
||||||
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.mp3',
|
||||||
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.jpg',
|
||||||
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.lrc',
|
||||||
|
theme: '#46718b'
|
||||||
|
}, {
|
||||||
|
name: '光るなら',
|
||||||
|
artist: 'Goose house',
|
||||||
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.mp3',
|
||||||
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||||
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.lrc',
|
||||||
|
theme: '#ebd0c2'
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function aplayer2 () {
|
function aplayer2 () {
|
||||||
window.ap2 = new APlayer({
|
window.ap2 = new APlayer({
|
||||||
container: document.getElementById('aplayer2'),
|
container: document.getElementById('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'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
@@ -132,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'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
@@ -166,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'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
@@ -181,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'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
@@ -210,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'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
@@ -223,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'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
@@ -256,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',
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -280,3 +320,33 @@ function aplayer8 () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function aplayer9 () {
|
||||||
|
window.ap9 = new APlayer({
|
||||||
|
container: document.getElementById('aplayer9'),
|
||||||
|
fixed: true,
|
||||||
|
lrcType: 3,
|
||||||
|
audio: [{
|
||||||
|
name: '光るなら',
|
||||||
|
artist: 'Goose house',
|
||||||
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.mp3',
|
||||||
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.jpg',
|
||||||
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/hikarunara.lrc',
|
||||||
|
theme: '#ebd0c2'
|
||||||
|
}, {
|
||||||
|
name: 'トリカゴ',
|
||||||
|
artist: 'XX:me',
|
||||||
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.mp3',
|
||||||
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.jpg',
|
||||||
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/darling.lrc',
|
||||||
|
theme: '#46718b'
|
||||||
|
}, {
|
||||||
|
name: '前前前世',
|
||||||
|
artist: 'RADWIMPS',
|
||||||
|
url: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.mp3',
|
||||||
|
cover: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.jpg',
|
||||||
|
lrc: 'https://cn-south-17-aplayer-46154810.oss.dogecdn.com/yourname.lrc',
|
||||||
|
theme: '#505d6b'
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
}
|
||||||
+9
-5
@@ -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
|
||||||
|
|
||||||
@@ -38,12 +39,15 @@ 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/): 国内知名的视频弹幕网站
|
||||||
|
- [黑客派](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): 针对中文站点提供资讯、技术、资源、服务
|
||||||
- [Justice_Eternal吧曲谱资源站](http://lightmoon.pw): 一个非营利的、兴趣驱动的曲谱编辑、发布与整理解决方案
|
- [LLSupport](https://www.lovelivesupport.com/): This site provides a lot of information about LoveLive
|
||||||
- [Justice_Eternal吧曲谱资源站(移动端)](http://jefun.top/): 一个非营利的、兴趣驱动的曲谱编辑、发布与整理解决方案
|
- [歌词千寻](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): 每天只需两分钟的重点新闻资讯
|
||||||
+9
-6
@@ -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>
|
||||||
@@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
gtag('config', 'UA-48084758-8');
|
gtag('config', 'UA-48084758-8');
|
||||||
</script>
|
</script>
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer@1.9.1/dist/APlayer.min.css">
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer@1.10.0/dist/APlayer.min.css">
|
||||||
<script src="https://cdn.jsdelivr.net/npm/hls.js/dist/hls.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/hls.js/dist/hls.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/aplayer@1.9.1/dist/APlayer.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/aplayer@1.10.0/dist/APlayer.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/color-thief-don@2.0.2/src/color-thief.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/color-thief-don@2.0.2/src/color-thief.js"></script>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
@@ -31,14 +31,17 @@
|
|||||||
max-width: 700px;
|
max-width: 700px;
|
||||||
margin: 20px 0;
|
margin: 20px 0;
|
||||||
}
|
}
|
||||||
|
.sidebar-toggle {
|
||||||
|
z-index: 90;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<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 -->
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<div class="aplayer-wrap">
|
<div class="aplayer-wrap">
|
||||||
<div id="aplayer1"></div>
|
<div id="aplayer1"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="aplayer0"></div>
|
||||||
|
|
||||||
<div class="landing-buttons">
|
<div class="landing-buttons">
|
||||||
<a class="landing-button" target="_blank" href="https://github.com/MoePlayer/APlayer">
|
<a class="landing-button" target="_blank" href="https://github.com/MoePlayer/APlayer">
|
||||||
|
|||||||
+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
|
||||||
|
|
||||||
|
|||||||
+106
-45
@@ -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>
|
||||||
|
|
||||||
## 安装
|
## 安装
|
||||||
@@ -68,6 +65,7 @@ const ap = new APlayer(options);
|
|||||||
名称 | 默认值 | 描述
|
名称 | 默认值 | 描述
|
||||||
----|-------|----
|
----|-------|----
|
||||||
container | document.querySelector('.aplayer') | 播放器容器元素
|
container | document.querySelector('.aplayer') | 播放器容器元素
|
||||||
|
fixed | false | 开启吸底模式, [详情](https://aplayer.js.org/#/home?id=fixed-mode)
|
||||||
mini | false | 开启迷你模式, [详情](https://aplayer.js.org/#/home?id=mini-mode)
|
mini | false | 开启迷你模式, [详情](https://aplayer.js.org/#/home?id=mini-mode)
|
||||||
autoplay | false | 音频自动播放
|
autoplay | false | 音频自动播放
|
||||||
theme | '#b7daff' | 主题色
|
theme | '#b7daff' | 主题色
|
||||||
@@ -88,6 +86,7 @@ mutex | true | 互斥,阻止多个播放器同时播放,当前播放器播
|
|||||||
lrcType | 0 | [详情](https://aplayer.js.org/#/home?id=lrc)
|
lrcType | 0 | [详情](https://aplayer.js.org/#/home?id=lrc)
|
||||||
listFolded | false | 列表默认折叠
|
listFolded | false | 列表默认折叠
|
||||||
listMaxHeight | - | 列表最大高度
|
listMaxHeight | - | 列表最大高度
|
||||||
|
storageName | 'aplayer-setting' | 存储播放器设置的 localStorage key
|
||||||
|
|
||||||
例如:
|
例如:
|
||||||
|
|
||||||
@@ -107,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: [
|
||||||
{
|
{
|
||||||
@@ -148,33 +147,6 @@ const ap = new APlayer({
|
|||||||
|
|
||||||
+ `ap.on(event: string, handler: function)`: 绑定音频和播放器事件,[详情](https://aplayer.js.org/#/home?id=event-binding)
|
+ `ap.on(event: string, handler: function)`: 绑定音频和播放器事件,[详情](https://aplayer.js.org/#/home?id=event-binding)
|
||||||
|
|
||||||
+ `ap.switchAudio(index: number)`: 切换音频列表
|
|
||||||
|
|
||||||
```js
|
|
||||||
ap.switchAudio(1);
|
|
||||||
```
|
|
||||||
|
|
||||||
+ `ap.addAudio(audio)`: 向列表添加新的音频
|
|
||||||
|
|
||||||
```js
|
|
||||||
ap.addAudio([
|
|
||||||
{
|
|
||||||
name: 'name',
|
|
||||||
artist: 'artist',
|
|
||||||
url: 'url.mp3',
|
|
||||||
cover: 'cover.jpg',
|
|
||||||
lrc: 'lrc.lrc',
|
|
||||||
theme: '#ebd0c2'
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
```
|
|
||||||
|
|
||||||
+ `ap.removeAudio(index: number)`: 从列表删除音频
|
|
||||||
|
|
||||||
```js
|
|
||||||
ap.removeAudio(1);
|
|
||||||
```
|
|
||||||
|
|
||||||
+ `ap.volume(percentage: number, nostorage: boolean)`: 设置音频音量
|
+ `ap.volume(percentage: number, nostorage: boolean)`: 设置音频音量
|
||||||
|
|
||||||
```js
|
```js
|
||||||
@@ -197,9 +169,56 @@ const ap = new APlayer({
|
|||||||
ap.notice('Amazing player', 2000, 0.8);
|
ap.notice('Amazing player', 2000, 0.8);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
+ `ap.skipBack()`: 切换到上一首音频
|
||||||
|
|
||||||
|
+ `ap.skipForward()`: 切换到下一首音频
|
||||||
|
|
||||||
+ `ap.destroy()`: 销毁播放器
|
+ `ap.destroy()`: 销毁播放器
|
||||||
|
|
||||||
+ `ap.audio`: 原生 video
|
+ `ap.lrc`
|
||||||
|
|
||||||
|
+ `ap.lrc.show()`: 显示歌词
|
||||||
|
|
||||||
|
+ `ap.lrc.hide()`: 隐藏歌词
|
||||||
|
|
||||||
|
+ `ap.lrc.toggle()`: 显示/隐藏歌词
|
||||||
|
|
||||||
|
+ `ap.list`
|
||||||
|
|
||||||
|
+ `ap.list.show()`: 显示播放列表
|
||||||
|
|
||||||
|
+ `ap.list.hide()`: 隐藏播放列表
|
||||||
|
|
||||||
|
+ `ap.list.toggle()`: 显示/隐藏播放列表
|
||||||
|
|
||||||
|
+ `ap.list.add(audios: array | object)`: 添加一个或几个新音频到播放列表
|
||||||
|
|
||||||
|
```js
|
||||||
|
ap.list.add([{
|
||||||
|
name: 'name',
|
||||||
|
artist: 'artist',
|
||||||
|
url: 'url.mp3',
|
||||||
|
cover: 'cover.jpg',
|
||||||
|
lrc: 'lrc.lrc',
|
||||||
|
theme: '#ebd0c2'
|
||||||
|
}]);
|
||||||
|
```
|
||||||
|
|
||||||
|
+ `ap.list.remove(index: number)`: 移除播放列表中的一个音频
|
||||||
|
|
||||||
|
```js
|
||||||
|
ap.list.remove(1);
|
||||||
|
```
|
||||||
|
|
||||||
|
+ `ap.list.switch()`: 切换到播放列表里的其他音频
|
||||||
|
|
||||||
|
```js
|
||||||
|
ap.list.switch(1);
|
||||||
|
```
|
||||||
|
|
||||||
|
+ `ap.list.clear()`: 清空播放列表
|
||||||
|
|
||||||
|
+ `ap.audio`: 原生 audio
|
||||||
|
|
||||||
+ `ap.audio.currentTime`: 返回音频当前播放时间
|
+ `ap.audio.currentTime`: 返回音频当前播放时间
|
||||||
|
|
||||||
@@ -247,12 +266,17 @@ ap.on('ended', function () {
|
|||||||
|
|
||||||
播放器事件
|
播放器事件
|
||||||
|
|
||||||
- switchaudio
|
- listshow
|
||||||
- addaudio
|
- listhide
|
||||||
- removeaudio
|
- listadd
|
||||||
|
- listremove
|
||||||
|
- listswitch
|
||||||
|
- listclear
|
||||||
|
- noticeshow
|
||||||
|
- noticehide
|
||||||
- destroy
|
- destroy
|
||||||
- notice_show
|
- lrcshow
|
||||||
- notice_hide
|
- lrchide
|
||||||
|
|
||||||
## 歌词
|
## 歌词
|
||||||
|
|
||||||
@@ -370,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: [
|
||||||
{
|
{
|
||||||
@@ -392,11 +416,33 @@ const ap = new APlayer({
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
## 吸底模式
|
||||||
|
|
||||||
|
APlayer 可以通过吸底模式固定在页面底部,这种模式跟普通模式有很大不同。
|
||||||
|
|
||||||
|
<div class="aplayer-wrap">
|
||||||
|
<div id="aplayer9"><button class="docute-button load">点击加载播放器</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
```js
|
||||||
|
const ap = new APlayer({
|
||||||
|
container: document.getElementById('player'),
|
||||||
|
fixed: true,
|
||||||
|
audio: [{
|
||||||
|
name: 'name',
|
||||||
|
artist: 'artist',
|
||||||
|
url: 'url.mp3',
|
||||||
|
cover: 'cover.jpg',
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
## 迷你模式
|
## 迷你模式
|
||||||
|
|
||||||
如果你没有足够空间来放置正常模式的播放器,那么你可以考虑使用迷你模式。
|
如果你没有足够空间来放置正常模式的播放器,那么你可以考虑使用迷你模式。
|
||||||
|
|
||||||
|
请注意迷你模式与吸底模式冲突。
|
||||||
|
|
||||||
<div class="aplayer-wrap">
|
<div class="aplayer-wrap">
|
||||||
<div id="aplayer6"><button class="docute-button load">点击加载播放器</div>
|
<div id="aplayer6"><button class="docute-button load">点击加载播放器</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -506,12 +552,27 @@ const ap = new APlayer({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const colorThief = new ColorThief();
|
const colorThief = new ColorThief();
|
||||||
ap.on('switchaudio', (index) => {
|
const image = new Image();
|
||||||
if (!ap.options.audio[index].theme) {
|
const xhr = new XMLHttpRequest();
|
||||||
colorThief.getColorAsync(ap.options.audio[index].cover, (color) => {
|
const setTheme = (index) => {
|
||||||
ap.theme(`rgb(${color[0]}, ${color[1]}, ${color[2]})`, index);
|
if (!ap.list.audios[index].theme) {
|
||||||
});
|
xhr.onload = function(){
|
||||||
|
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);
|
||||||
|
ap.on('listswitch', (index) => {
|
||||||
|
setTheme(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
|
||||||
|
|
||||||
@@ -39,12 +39,14 @@ search: zh-Hans
|
|||||||
|
|
||||||
## 谁在用 APlayer?
|
## 谁在用 APlayer?
|
||||||
|
|
||||||
|
- [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): 针对中文站点提供资讯、技术、资源、服务
|
||||||
- [Justice_Eternal吧曲谱资源站](http://lightmoon.pw): 一个非营利的、兴趣驱动的曲谱编辑、发布与整理解决方案
|
- [LLSupport](https://www.lovelivesupport.com/): This site provides a lot of information about LoveLive
|
||||||
- [Justice_Eternal吧曲谱资源站(移动端)](http://jefun.top/): 一个非营利的、兴趣驱动的曲谱编辑、发布与整理解决方案
|
- [歌词千寻](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/)
|
||||||
+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
-59
@@ -1,61 +1,80 @@
|
|||||||
{
|
{
|
||||||
"name": "aplayer",
|
"name": "aplayer",
|
||||||
"version": "1.9.1",
|
"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": "^7.2.5",
|
"url": "https://github.com/DIYgod/APlayer/issues"
|
||||||
"babel-core": "^6.26.0",
|
},
|
||||||
"babel-loader": "^7.1.2",
|
"homepage": "https://github.com/DIYgod/APlayer#readme",
|
||||||
"babel-preset-env": "^1.6.1",
|
"devDependencies": {
|
||||||
"cross-env": "^5.1.3",
|
"@babel/core": "^7.6.0",
|
||||||
"css-loader": "^0.28.9",
|
"@babel/preset-env": "^7.4.5",
|
||||||
"eslint": "^4.17.0",
|
"@vuepress/plugin-back-to-top": "1.7.1",
|
||||||
"eslint-loader": "^1.9.0",
|
"@vuepress/plugin-google-analytics": "1.7.1",
|
||||||
"exports-loader": "^0.6.4",
|
"@vuepress/plugin-pwa": "1.7.1",
|
||||||
"extract-text-webpack-plugin": "^3.0.2",
|
"art-template": "4.13.2",
|
||||||
"file-loader": "^1.1.6",
|
"art-template-loader": "1.4.3",
|
||||||
"git-revision-webpack-plugin": "^2.5.1",
|
"autoprefixer": "^9.6.1",
|
||||||
"node-sass": "^4.7.2",
|
"babel-loader": "^8.0.6",
|
||||||
"postcss-loader": "^2.1.0",
|
"cross-env": "^7.0.0",
|
||||||
"sass-loader": "^6.0.6",
|
"css-loader": "^5.0.0",
|
||||||
"strip-loader": "^0.1.2",
|
"cssnano": "^4.1.10",
|
||||||
"style-loader": "^0.20.1",
|
"eslint": "^7.0.0",
|
||||||
"svg-inline-loader": "0.8.0",
|
"eslint-config-prettier": "^6.3.0",
|
||||||
"template-string-optimize-loader": "^2.2.3",
|
"eslint-loader": "^4.0.0",
|
||||||
"url-loader": "^0.6.2",
|
"eslint-plugin-prettier": "^3.1.1",
|
||||||
"webpack": "^3.10.0",
|
"exports-loader": "^1.0.0",
|
||||||
"webpack-dev-server": "^2.11.1"
|
"file-loader": "^6.0.0",
|
||||||
},
|
"git-revision-webpack-plugin": "^3.0.3",
|
||||||
"dependencies": {
|
"mini-css-extract-plugin": "1.3.0",
|
||||||
"balloon-css": "^0.5.0",
|
"node-sass": "^5.0.0",
|
||||||
"promise-polyfill": "7.1.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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 32 32">
|
||||||
|
<path d="M26.667 5.333h-21.333c-0 0-0.001 0-0.001 0-1.472 0-2.666 1.194-2.666 2.666 0 0 0 0.001 0 0.001v-0 16c0 0 0 0.001 0 0.001 0 1.472 1.194 2.666 2.666 2.666 0 0 0.001 0 0.001 0h21.333c0 0 0.001 0 0.001 0 1.472 0 2.666-1.194 2.666-2.666 0-0 0-0.001 0-0.001v0-16c0-0 0-0.001 0-0.001 0-1.472-1.194-2.666-2.666-2.666-0 0-0.001 0-0.001 0h0zM5.333 16h5.333v2.667h-5.333v-2.667zM18.667 24h-13.333v-2.667h13.333v2.667zM26.667 24h-5.333v-2.667h5.333v2.667zM26.667 18.667h-13.333v-2.667h13.333v2.667z"></path>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 590 B |
@@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 32 32">
|
||||||
|
<path d="M22 16l-10.105-10.6-1.895 1.987 8.211 8.613-8.211 8.612 1.895 1.988 8.211-8.613z"></path>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 184 B |
@@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 32 32">
|
||||||
|
<path d="M25.468 6.947c-0.326-0.172-0.724-0.151-1.030 0.057l-6.438 4.38v-3.553c0-0.371-0.205-0.71-0.532-0.884-0.326-0.172-0.724-0.151-1.030 0.057l-12 8.164c-0.274 0.186-0.438 0.496-0.438 0.827s0.164 0.641 0.438 0.827l12 8.168c0.169 0.115 0.365 0.174 0.562 0.174 0.16 0 0.321-0.038 0.468-0.116 0.327-0.173 0.532-0.514 0.532-0.884v-3.556l6.438 4.382c0.169 0.115 0.365 0.174 0.562 0.174 0.16 0 0.321-0.038 0.468-0.116 0.327-0.173 0.532-0.514 0.532-0.884v-16.333c0-0.371-0.205-0.71-0.532-0.884z"></path>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 585 B |
+220
-64
@@ -37,6 +37,9 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height - 6;
|
|||||||
.aplayer-info .aplayer-controller .aplayer-time .aplayer-icon.aplayer-icon-menu {
|
.aplayer-info .aplayer-controller .aplayer-time .aplayer-icon.aplayer-icon-menu {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
.aplayer-icon-order {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.aplayer-withlrc {
|
&.aplayer-withlrc {
|
||||||
@@ -70,6 +73,117 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height - 6;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.aplayer-fixed {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
margin: 0;
|
||||||
|
z-index: 99;
|
||||||
|
overflow: visible;
|
||||||
|
max-width: 400px;
|
||||||
|
box-shadow: none;
|
||||||
|
|
||||||
|
.aplayer-list {
|
||||||
|
margin-bottom: 65px;
|
||||||
|
border: 1px solid #eee;
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.aplayer-body {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
margin: 0;
|
||||||
|
z-index: 99;
|
||||||
|
background: #fff;
|
||||||
|
padding-right: 18px;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
max-width: 400px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.aplayer-lrc {
|
||||||
|
display: block;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 10px;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
margin: 0;
|
||||||
|
z-index: 98;
|
||||||
|
pointer-events: none;
|
||||||
|
text-shadow: -1px -1px 0 #fff;
|
||||||
|
|
||||||
|
&:before,
|
||||||
|
&:after {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.aplayer-info {
|
||||||
|
transform: scaleX(1);
|
||||||
|
transform-origin: 0 0;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
border-bottom: none;
|
||||||
|
border-top: 1px solid #e9e9e9;
|
||||||
|
|
||||||
|
.aplayer-music {
|
||||||
|
width: calc(100% - 105px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.aplayer-miniswitcher {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.aplayer-narrow {
|
||||||
|
.aplayer-info {
|
||||||
|
display: block;
|
||||||
|
transform: scaleX(0);
|
||||||
|
}
|
||||||
|
.aplayer-body {
|
||||||
|
width: $aplayer-height !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.aplayer-miniswitcher .aplayer-icon {
|
||||||
|
transform: rotateY(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.aplayer-icon-back,
|
||||||
|
.aplayer-icon-play,
|
||||||
|
.aplayer-icon-forward,
|
||||||
|
.aplayer-icon-lrc {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.aplayer-icon-back,
|
||||||
|
.aplayer-icon-play,
|
||||||
|
.aplayer-icon-forward,
|
||||||
|
.aplayer-icon-menu {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 27px;
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.aplayer-icon-back {
|
||||||
|
right: 75px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.aplayer-icon-play {
|
||||||
|
right: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.aplayer-icon-forward {
|
||||||
|
right: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.aplayer-icon-menu {
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&.aplayer-mobile {
|
&.aplayer-mobile {
|
||||||
.aplayer-icon-volume-down {
|
.aplayer-icon-volume-down {
|
||||||
display: none;
|
display: none;
|
||||||
@@ -109,13 +223,31 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height - 6;
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
display: inline;
|
display: inline-block;
|
||||||
|
|
||||||
path {
|
path {
|
||||||
transition: all .2s ease-in-out;
|
transition: all .2s ease-in-out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.aplayer-icon-order,
|
||||||
|
.aplayer-icon-back,
|
||||||
|
.aplayer-icon-play,
|
||||||
|
.aplayer-icon-forward,
|
||||||
|
.aplayer-icon-lrc {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.aplayer-icon-lrc-inactivity {
|
||||||
|
svg {
|
||||||
|
opacity: 0.4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.aplayer-icon-forward {
|
||||||
|
transform: rotate(180deg);
|
||||||
|
}
|
||||||
|
|
||||||
.aplayer-lrc-content {
|
.aplayer-lrc-content {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@@ -198,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;
|
||||||
@@ -421,9 +554,14 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height - 6;
|
|||||||
opacity: 1;
|
opacity: 1;
|
||||||
overflow: visible;
|
overflow: visible;
|
||||||
height: initial !important;
|
height: initial !important;
|
||||||
|
min-height: 16px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.aplayer-lrc-hide {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.aplayer-lrc-contents {
|
.aplayer-lrc-contents {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
transition: all 0.5s ease-out;
|
transition: all 0.5s ease-out;
|
||||||
@@ -438,82 +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 {
|
||||||
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-track {
|
&:hover {
|
||||||
background-color: #f9f9f9;
|
background: #efefef;
|
||||||
}
|
}
|
||||||
|
|
||||||
&::-webkit-scrollbar-thumb {
|
&.aplayer-list-light {
|
||||||
border-radius: 3px;
|
background: #e9e9e9;
|
||||||
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;
|
|
||||||
|
|
||||||
&: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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -533,6 +660,35 @@ $aplayer-height-lrc: $aplayer-height + $lrc-height - 6;
|
|||||||
background-color: #f4f4f5;
|
background-color: #f4f4f5;
|
||||||
color: #909399;
|
color: #909399;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.aplayer-miniswitcher {
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
height: 100%;
|
||||||
|
background: #e6e6e6;
|
||||||
|
width: 18px;
|
||||||
|
border-radius: 0 2px 2px 0;
|
||||||
|
|
||||||
|
.aplayer-icon {
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
transform: rotateY(180deg);
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
|
||||||
|
path {
|
||||||
|
fill: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
path {
|
||||||
|
fill: #000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes aplayer-roll {
|
@keyframes aplayer-roll {
|
||||||
|
|||||||
+3
-3
@@ -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,13 +13,13 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+56
-61
@@ -2,66 +2,46 @@ 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();
|
||||||
this.initList();
|
|
||||||
this.initPlayBar();
|
this.initPlayBar();
|
||||||
if (this.player.isMultiple()) {
|
this.initOrderButton();
|
||||||
this.initOrderButton();
|
|
||||||
}
|
|
||||||
this.initLoopButton();
|
this.initLoopButton();
|
||||||
this.initMenuButton();
|
this.initMenuButton();
|
||||||
if (!utils.isMobile) {
|
if (!utils.isMobile) {
|
||||||
this.initVolumeButton();
|
this.initVolumeButton();
|
||||||
}
|
}
|
||||||
|
this.initMiniSwitcher();
|
||||||
|
this.initSkipButton();
|
||||||
|
this.initLrcButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
initPlayButton () {
|
initPlayButton() {
|
||||||
this.player.template.pic.addEventListener('click', () => {
|
this.player.template.pic.addEventListener('click', () => {
|
||||||
this.player.toggle();
|
this.player.toggle();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initList () {
|
initPlayBar() {
|
||||||
this.player.template.list.addEventListener('click', (e) => {
|
|
||||||
let target;
|
|
||||||
if (e.target.tagName.toUpperCase() === 'LI') {
|
|
||||||
target = e.target;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
target = e.target.parentElement;
|
|
||||||
}
|
|
||||||
const audioIndex = parseInt(target.getElementsByClassName('aplayer-list-index')[0].innerHTML) - 1;
|
|
||||||
if (audioIndex !== this.player.playIndex) {
|
|
||||||
this.player.switchAudio(audioIndex);
|
|
||||||
this.player.play();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.player.toggle();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
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');
|
||||||
this.player.lrc && this.player.lrc.update(percentage * this.player.audio.duration);
|
this.player.lrc && this.player.lrc.update(percentage * this.player.duration);
|
||||||
this.player.template.ptime.innerHTML = utils.secondToTime(percentage * this.player.audio.duration);
|
this.player.template.ptime.innerHTML = utils.secondToTime(percentage * this.player.duration);
|
||||||
};
|
};
|
||||||
|
|
||||||
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.audio.duration);
|
this.player.seek(percentage * this.player.duration);
|
||||||
this.player.disableTimeupdate = false;
|
this.player.disableTimeupdate = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -72,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');
|
||||||
@@ -87,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.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);
|
||||||
@@ -97,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.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);
|
||||||
@@ -110,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.isMultiple()) {
|
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;
|
||||||
}
|
}
|
||||||
@@ -152,15 +124,38 @@ class Controller {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initMenuButton () {
|
initMenuButton() {
|
||||||
this.player.template.list.style.height = 33 * this.player.options.audio.length - 1 + 'px';
|
|
||||||
this.player.template.listOl.style.height = 33 * this.player.options.audio.length - 1 + 'px';
|
|
||||||
this.player.template.menu.addEventListener('click', () => {
|
this.player.template.menu.addEventListener('click', () => {
|
||||||
if (!this.player.template.list.classList.contains('aplayer-list-hide')) {
|
this.player.list.toggle();
|
||||||
this.player.template.list.classList.add('aplayer-list-hide');
|
});
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
this.player.template.list.classList.remove('aplayer-list-hide');
|
initMiniSwitcher() {
|
||||||
|
this.player.template.miniSwitcher.addEventListener('click', () => {
|
||||||
|
this.player.setMode(this.player.mode === 'mini' ? 'normal' : 'mini');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
initSkipButton() {
|
||||||
|
this.player.template.skipBackButton.addEventListener('click', () => {
|
||||||
|
this.player.skipBack();
|
||||||
|
});
|
||||||
|
this.player.template.skipForwardButton.addEventListener('click', () => {
|
||||||
|
this.player.skipForward();
|
||||||
|
});
|
||||||
|
this.player.template.skipPlayButton.addEventListener('click', () => {
|
||||||
|
this.player.toggle();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
initLrcButton() {
|
||||||
|
this.player.template.lrcButton.addEventListener('click', () => {
|
||||||
|
if (this.player.template.lrcButton.classList.contains('aplayer-icon-lrc-inactivity')) {
|
||||||
|
this.player.template.lrcButton.classList.remove('aplayer-icon-lrc-inactivity');
|
||||||
|
this.player.lrc && this.player.lrc.show();
|
||||||
|
} else {
|
||||||
|
this.player.template.lrcButton.classList.add('aplayer-icon-lrc-inactivity');
|
||||||
|
this.player.lrc && this.player.lrc.hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-14
@@ -1,19 +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', 'switchaudio', 'addaudio', 'removeaudio', 'notice_show', 'notice_hide'
|
'error',
|
||||||
|
'loadeddata',
|
||||||
|
'loadedmetadata',
|
||||||
|
'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] = [];
|
||||||
@@ -22,19 +39,18 @@ class Events {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trigger (name, info) {
|
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](info);
|
this.events[name][i](data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ import loopAll from '../assets/loop-all.svg';
|
|||||||
import loopOne from '../assets/loop-one.svg';
|
import loopOne from '../assets/loop-one.svg';
|
||||||
import loopNone from '../assets/loop-none.svg';
|
import loopNone from '../assets/loop-none.svg';
|
||||||
import loading from '../assets/loading.svg';
|
import loading from '../assets/loading.svg';
|
||||||
|
import right from '../assets/right.svg';
|
||||||
|
import skip from '../assets/skip.svg';
|
||||||
|
import lrc from '../assets/lrc.svg';
|
||||||
|
|
||||||
const Icons = {
|
const Icons = {
|
||||||
play: play,
|
play: play,
|
||||||
@@ -24,6 +27,9 @@ const Icons = {
|
|||||||
loopOne: loopOne,
|
loopOne: loopOne,
|
||||||
loopNone: loopNone,
|
loopNone: loopNone,
|
||||||
loading: loading,
|
loading: loading,
|
||||||
|
right: right,
|
||||||
|
skip: skip,
|
||||||
|
lrc: lrc,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Icons;
|
export default Icons;
|
||||||
|
|||||||
+1
-1
@@ -2,6 +2,6 @@ import '../css/index.scss';
|
|||||||
import APlayer from './player';
|
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'}${'\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;
|
||||||
+195
@@ -0,0 +1,195 @@
|
|||||||
|
import tplListItem from '../template/list-item.art';
|
||||||
|
import utils from './utils';
|
||||||
|
import smoothScroll from 'smoothscroll';
|
||||||
|
|
||||||
|
class List {
|
||||||
|
constructor(player) {
|
||||||
|
this.player = player;
|
||||||
|
this.index = 0;
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
bindEvents() {
|
||||||
|
this.player.template.list.addEventListener('click', (e) => {
|
||||||
|
let target;
|
||||||
|
if (e.target.tagName.toUpperCase() === 'LI') {
|
||||||
|
target = e.target;
|
||||||
|
} else {
|
||||||
|
target = e.target.parentElement;
|
||||||
|
}
|
||||||
|
const audioIndex = parseInt(target.getElementsByClassName('aplayer-list-index')[0].innerHTML) - 1;
|
||||||
|
if (audioIndex !== this.index) {
|
||||||
|
this.switch(audioIndex);
|
||||||
|
this.player.play();
|
||||||
|
} else {
|
||||||
|
this.player.toggle();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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');
|
||||||
|
}
|
||||||
|
|
||||||
|
hide() {
|
||||||
|
this.showing = false;
|
||||||
|
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() {
|
||||||
|
if (this.showing) {
|
||||||
|
this.hide();
|
||||||
|
} else {
|
||||||
|
this.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
add(audios) {
|
||||||
|
this.player.events.trigger('listadd', {
|
||||||
|
audios: audios,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (Object.prototype.toString.call(audios) !== '[object Array]') {
|
||||||
|
audios = [audios];
|
||||||
|
}
|
||||||
|
audios.map((item) => {
|
||||||
|
item.name = item.name || item.title || 'Audio name';
|
||||||
|
item.artist = item.artist || item.author || 'Audio artist';
|
||||||
|
item.cover = item.cover || item.pic;
|
||||||
|
item.type = item.type || 'normal';
|
||||||
|
return item;
|
||||||
|
});
|
||||||
|
|
||||||
|
const wasSingle = !(this.audios.length > 1);
|
||||||
|
const wasEmpty = this.audios.length === 0;
|
||||||
|
|
||||||
|
this.player.template.list.innerHTML += tplListItem({
|
||||||
|
theme: this.player.options.theme,
|
||||||
|
audio: audios,
|
||||||
|
index: this.audios.length + 1,
|
||||||
|
});
|
||||||
|
|
||||||
|
this.audios = this.audios.concat(audios);
|
||||||
|
|
||||||
|
if (wasSingle && this.audios.length > 1) {
|
||||||
|
this.player.container.classList.add('aplayer-withlist');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.player.randomOrder = utils.randomOrder(this.audios.length);
|
||||||
|
this.player.template.listCurs = this.player.container.querySelectorAll('.aplayer-list-cur');
|
||||||
|
|
||||||
|
this.player.template.listCurs[this.audios.length - 1].style.backgroundColor = audios.theme || this.player.options.theme;
|
||||||
|
|
||||||
|
if (wasEmpty) {
|
||||||
|
if (this.player.options.order === 'random') {
|
||||||
|
this.switch(this.player.randomOrder[0]);
|
||||||
|
} else {
|
||||||
|
this.switch(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
remove(index) {
|
||||||
|
this.player.events.trigger('listremove', {
|
||||||
|
index: index,
|
||||||
|
});
|
||||||
|
if (this.audios[index]) {
|
||||||
|
if (this.audios.length > 1) {
|
||||||
|
const list = this.player.container.querySelectorAll('.aplayer-list li');
|
||||||
|
list[index].remove();
|
||||||
|
|
||||||
|
this.audios.splice(index, 1);
|
||||||
|
this.player.lrc && this.player.lrc.remove(index);
|
||||||
|
|
||||||
|
if (index === this.index) {
|
||||||
|
if (this.audios[index]) {
|
||||||
|
this.switch(index);
|
||||||
|
} else {
|
||||||
|
this.switch(index - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.index > index) {
|
||||||
|
this.index--;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = index; i < list.length; i++) {
|
||||||
|
list[i].getElementsByClassName('aplayer-list-index')[0].textContent = i;
|
||||||
|
}
|
||||||
|
if (this.audios.length === 1) {
|
||||||
|
this.player.container.classList.remove('aplayer-withlist');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.player.template.listCurs = this.player.container.querySelectorAll('.aplayer-list-cur');
|
||||||
|
} else {
|
||||||
|
this.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(index) {
|
||||||
|
this.player.events.trigger('listswitch', {
|
||||||
|
index: index,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (typeof index !== 'undefined' && this.audios[index]) {
|
||||||
|
this.index = index;
|
||||||
|
|
||||||
|
const audio = this.audios[this.index];
|
||||||
|
|
||||||
|
// set html
|
||||||
|
this.player.template.pic.style.backgroundImage = audio.cover ? `url('${audio.cover}')` : '';
|
||||||
|
this.player.theme(this.audios[this.index].theme || this.player.options.theme, this.index, false);
|
||||||
|
this.player.template.title.innerHTML = audio.name;
|
||||||
|
this.player.template.author.innerHTML = audio.artist ? ' - ' + audio.artist : '';
|
||||||
|
|
||||||
|
const light = this.player.container.getElementsByClassName('aplayer-list-light')[0];
|
||||||
|
if (light) {
|
||||||
|
light.classList.remove('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.list);
|
||||||
|
|
||||||
|
this.player.setAudio(audio);
|
||||||
|
|
||||||
|
this.player.lrc && this.player.lrc.switch(this.index);
|
||||||
|
this.player.lrc && this.player.lrc.update(0);
|
||||||
|
|
||||||
|
// set duration time
|
||||||
|
if (this.player.duration !== 1) {
|
||||||
|
// compatibility: Android browsers will output 1 at first
|
||||||
|
this.player.template.dtime.innerHTML = utils.secondToTime(this.player.duration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
clear() {
|
||||||
|
this.player.events.trigger('listclear');
|
||||||
|
this.index = 0;
|
||||||
|
this.player.container.classList.remove('aplayer-withlist');
|
||||||
|
this.player.pause();
|
||||||
|
this.audios = [];
|
||||||
|
this.player.lrc && this.player.lrc.clear();
|
||||||
|
this.player.audio.src = '';
|
||||||
|
this.player.template.list.innerHTML = '';
|
||||||
|
this.player.template.pic.style.backgroundImage = '';
|
||||||
|
this.player.theme(this.player.options.theme, this.index, false);
|
||||||
|
this.player.template.title.innerHTML = 'No audio';
|
||||||
|
this.player.template.author.innerHTML = '';
|
||||||
|
this.player.bar.set('loaded', 0, 'width');
|
||||||
|
this.player.template.dtime.innerHTML = utils.secondToTime(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default List;
|
||||||
+49
-24
@@ -1,17 +1,34 @@
|
|||||||
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;
|
||||||
this.content = options.content;
|
|
||||||
this.parsed = [];
|
this.parsed = [];
|
||||||
this.index = 0;
|
this.index = 0;
|
||||||
this.current = [];
|
this.current = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
update (currentTime = this.player.audio.currentTime) {
|
show() {
|
||||||
|
this.player.events.trigger('lrcshow');
|
||||||
|
this.player.template.lrcWrap.classList.remove('aplayer-lrc-hide');
|
||||||
|
}
|
||||||
|
|
||||||
|
hide() {
|
||||||
|
this.player.events.trigger('lrchide');
|
||||||
|
this.player.template.lrcWrap.classList.add('aplayer-lrc-hide');
|
||||||
|
}
|
||||||
|
|
||||||
|
toggle() {
|
||||||
|
if (this.player.template.lrcWrap.classList.contains('aplayer-lrc-hide')) {
|
||||||
|
this.show();
|
||||||
|
} else {
|
||||||
|
this.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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])) {
|
||||||
@@ -25,47 +42,43 @@ class Lrc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (index) {
|
switch(index) {
|
||||||
if (!this.parsed[index]) {
|
if (!this.parsed[index]) {
|
||||||
if (!this.async) {
|
if (!this.async) {
|
||||||
if (this.content[index]) {
|
if (this.player.list.audios[index].lrc) {
|
||||||
this.parsed[index] = this.parse(this.content[index]);
|
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.playIndex && 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];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const apiurl = this.content[index];
|
const apiurl = this.player.list.audios[index].lrc;
|
||||||
xhr.open('get', apiurl, true);
|
xhr.open('get', apiurl, true);
|
||||||
xhr.send(null);
|
xhr.send(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,17 +93,20 @@ 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');
|
||||||
const lrc = [];
|
let lrc = [];
|
||||||
const lyricLen = lyric.length;
|
const lyricLen = lyric.length;
|
||||||
for (let i = 0; i < lyricLen; i++) {
|
for (let i = 0; i < lyricLen; i++) {
|
||||||
// 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
|
||||||
@@ -106,13 +122,22 @@ class Lrc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// sort by time
|
// sort by time
|
||||||
|
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;
|
||||||
+11
-8
@@ -1,20 +1,21 @@
|
|||||||
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],
|
||||||
mini: options.narrow || false,
|
mini: options.narrow || options.fixed || false,
|
||||||
|
fixed: false,
|
||||||
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: false,
|
listFolded: options.fixed,
|
||||||
listMaxHeight: options.listmaxheight,
|
listMaxHeight: options.listmaxheight || 250,
|
||||||
audio: options.music
|
audio: options.music || [],
|
||||||
|
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)) {
|
||||||
@@ -22,13 +23,15 @@ 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];
|
||||||
}
|
}
|
||||||
|
|
||||||
options.audio.map((item) => {
|
options.audio.map((item) => {
|
||||||
item.name = item.name || item.title;
|
item.name = item.name || item.title || 'Audio name';
|
||||||
item.artist = item.artist || item.author;
|
item.artist = item.artist || item.author || 'Audio artist';
|
||||||
item.cover = item.cover || item.pic;
|
item.cover = item.cover || item.pic;
|
||||||
item.type = item.type || 'normal';
|
item.type = item.type || 'normal';
|
||||||
return item;
|
return item;
|
||||||
|
|||||||
+228
-299
@@ -5,26 +5,25 @@ import Icons from './icons';
|
|||||||
import handleOption from './options';
|
import handleOption from './options';
|
||||||
import Template from './template';
|
import Template from './template';
|
||||||
import Bar from './bar';
|
import Bar from './bar';
|
||||||
import User from './user';
|
import Storage from './storage';
|
||||||
import Lrc from './lrc';
|
import Lrc from './lrc';
|
||||||
import Controller from './controller';
|
import Controller from './controller';
|
||||||
import Timer from './timer';
|
import Timer from './timer';
|
||||||
import Events from './events';
|
import Events from './events';
|
||||||
|
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.playIndex = 0;
|
|
||||||
this.paused = true;
|
this.paused = true;
|
||||||
this.playedPromise = Promise.resolve();
|
this.playedPromise = Promise.resolve();
|
||||||
this.mode = 'normal';
|
this.mode = 'normal';
|
||||||
@@ -32,7 +31,7 @@ class APlayer {
|
|||||||
this.randomOrder = utils.randomOrder(this.options.audio.length);
|
this.randomOrder = utils.randomOrder(this.options.audio.length);
|
||||||
|
|
||||||
this.container.classList.add('aplayer');
|
this.container.classList.add('aplayer');
|
||||||
if (this.options.lrcType) {
|
if (this.options.lrcType && !this.options.fixed) {
|
||||||
this.container.classList.add('aplayer-withlrc');
|
this.container.classList.add('aplayer-withlrc');
|
||||||
}
|
}
|
||||||
if (this.options.audio.length > 1) {
|
if (this.options.audio.length > 1) {
|
||||||
@@ -45,12 +44,8 @@ class APlayer {
|
|||||||
if (this.arrow) {
|
if (this.arrow) {
|
||||||
this.container.classList.add('aplayer-arrow');
|
this.container.classList.add('aplayer-arrow');
|
||||||
}
|
}
|
||||||
if (this.options.mini) {
|
|
||||||
this.setMode('mini');
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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++) {
|
||||||
@@ -66,6 +61,14 @@ class APlayer {
|
|||||||
randomOrder: this.randomOrder,
|
randomOrder: this.randomOrder,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this.options.fixed) {
|
||||||
|
this.container.classList.add('aplayer-fixed');
|
||||||
|
this.template.body.style.width = this.template.body.offsetWidth - 18 + 'px';
|
||||||
|
}
|
||||||
|
if (this.options.mini) {
|
||||||
|
this.setMode('mini');
|
||||||
|
this.template.info.style.display = 'block';
|
||||||
|
}
|
||||||
if (this.template.info.offsetWidth < 200) {
|
if (this.template.info.offsetWidth < 200) {
|
||||||
this.template.time.classList.add('aplayer-time-narrow');
|
this.template.time.classList.add('aplayer-time-narrow');
|
||||||
}
|
}
|
||||||
@@ -74,22 +77,22 @@ class APlayer {
|
|||||||
this.lrc = new Lrc({
|
this.lrc = new Lrc({
|
||||||
container: this.template.lrc,
|
container: this.template.lrc,
|
||||||
async: this.options.lrcType === 3,
|
async: this.options.lrcType === 3,
|
||||||
content: this.options.audio.map((item) => item.lrc),
|
|
||||||
player: this,
|
player: this,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.events = new Events();
|
this.events = new Events();
|
||||||
this.user = new User(this);
|
this.storage = new Storage(this);
|
||||||
this.bar = new Bar(this.template);
|
this.bar = new Bar(this.template);
|
||||||
this.controller = new Controller(this);
|
this.controller = new Controller(this);
|
||||||
this.timer = new Timer(this);
|
this.timer = new Timer(this);
|
||||||
|
this.list = new List(this);
|
||||||
|
|
||||||
this.initAudio();
|
this.initAudio();
|
||||||
|
this.bindEvents();
|
||||||
if (this.options.order === 'random') {
|
if (this.options.order === 'random') {
|
||||||
this.switchAudio(this.randomOrder[0]);
|
this.list.switch(this.randomOrder[0]);
|
||||||
}
|
} else {
|
||||||
else {
|
this.list.switch(0);
|
||||||
this.switchAudio(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// autoplay
|
// autoplay
|
||||||
@@ -100,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;
|
||||||
|
|
||||||
@@ -110,21 +113,25 @@ class APlayer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.volume(this.storage.get('volume'), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bindEvents() {
|
||||||
this.on('play', () => {
|
this.on('play', () => {
|
||||||
if (this.paused) {
|
if (this.paused) {
|
||||||
this.play();
|
this.setUIPlaying();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.on('pause', () => {
|
this.on('pause', () => {
|
||||||
if (!this.paused) {
|
if (!this.paused) {
|
||||||
this.pause();
|
this.setUIPaused();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.on('timeupdate', () => {
|
this.on('timeupdate', () => {
|
||||||
if (!this.disableTimeupdate) {
|
if (!this.disableTimeupdate) {
|
||||||
this.bar.set('played', this.audio.currentTime / this.audio.duration, 'width');
|
this.bar.set('played', this.audio.currentTime / this.duration, 'width');
|
||||||
this.lrc && this.lrc.update();
|
this.lrc && this.lrc.update();
|
||||||
const currentTime = utils.secondToTime(this.audio.currentTime);
|
const currentTime = utils.secondToTime(this.audio.currentTime);
|
||||||
if (this.template.ptime.innerHTML !== currentTime) {
|
if (this.template.ptime.innerHTML !== currentTime) {
|
||||||
@@ -135,156 +142,121 @@ 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.audio.duration !== 1) { // compatibility: Android browsers will output 1 at first
|
if (this.duration !== 1) {
|
||||||
this.template.dtime.innerHTML = utils.secondToTime(this.audio.duration);
|
// compatibility: Android browsers will output 1 at first
|
||||||
|
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.audio.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');
|
||||||
});
|
});
|
||||||
|
|
||||||
// audio download error: an error occurs
|
// audio download error: an error occurs
|
||||||
|
let skipTime;
|
||||||
this.on('error', () => {
|
this.on('error', () => {
|
||||||
this.notice('An audio error has occurred.');
|
if (this.list.audios.length > 1) {
|
||||||
|
this.notice('An audio error has occurred, player will skip forward in 2 seconds.');
|
||||||
|
skipTime = setTimeout(() => {
|
||||||
|
this.skipForward();
|
||||||
|
if (!this.paused) {
|
||||||
|
this.play();
|
||||||
|
}
|
||||||
|
}, 2000);
|
||||||
|
} else if (this.list.audios.length === 1) {
|
||||||
|
this.notice('An audio error has occurred.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.events.on('listswitch', () => {
|
||||||
|
skipTime && clearTimeout(skipTime);
|
||||||
});
|
});
|
||||||
|
|
||||||
// multiple audio play
|
// multiple audio play
|
||||||
this.on('ended', () => {
|
this.on('ended', () => {
|
||||||
if (this.options.loop === 'none') {
|
if (this.options.loop === 'none') {
|
||||||
if (this.options.order === 'list') {
|
if (this.options.order === 'list') {
|
||||||
if (this.playIndex < this.options.audio.length - 1) {
|
if (this.list.index < this.list.audios.length - 1) {
|
||||||
this.switchAudio((this.playIndex + 1) % this.options.audio.length);
|
this.list.switch((this.list.index + 1) % this.list.audios.length);
|
||||||
this.play();
|
this.play();
|
||||||
|
} else {
|
||||||
|
this.list.switch((this.list.index + 1) % this.list.audios.length);
|
||||||
|
this.pause();
|
||||||
}
|
}
|
||||||
else {
|
} else if (this.options.order === 'random') {
|
||||||
this.switchAudio((this.playIndex + 1) % this.options.audio.length);
|
if (this.randomOrder.indexOf(this.list.index) < this.randomOrder.length - 1) {
|
||||||
|
this.list.switch(this.nextIndex());
|
||||||
|
this.play();
|
||||||
|
} else {
|
||||||
|
this.list.switch(this.nextIndex());
|
||||||
this.pause();
|
this.pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (this.options.order === 'random') {
|
} else if (this.options.loop === 'one') {
|
||||||
if (this.randomOrder.indexOf(this.playIndex) < this.randomOrder.length - 1) {
|
this.list.switch(this.list.index);
|
||||||
this.switchAudio(this.nextRandomNum());
|
|
||||||
this.play();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.switchAudio(this.nextRandomNum());
|
|
||||||
this.pause();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (this.options.loop === 'one') {
|
|
||||||
this.switchAudio(this.playIndex);
|
|
||||||
this.play();
|
this.play();
|
||||||
}
|
} else if (this.options.loop === 'all') {
|
||||||
else if (this.options.loop === 'all') {
|
this.skipForward();
|
||||||
if (this.options.order === 'list') {
|
|
||||||
this.switchAudio((this.playIndex + 1) % this.options.audio.length);
|
|
||||||
}
|
|
||||||
else if (this.options.order === 'random') {
|
|
||||||
this.switchAudio(this.nextRandomNum());
|
|
||||||
}
|
|
||||||
this.play();
|
this.play();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.volume(this.user.get('volume'), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switchAudio (index) {
|
setAudio(audio) {
|
||||||
this.handlePlayPromise(() => {
|
if (this.hls) {
|
||||||
this.events.trigger('switchaudio', index);
|
this.hls.destroy();
|
||||||
if (typeof index !== 'undefined') {
|
this.hls = null;
|
||||||
this.playIndex = index;
|
}
|
||||||
|
let type = audio.type;
|
||||||
|
if (this.options.customAudioType && this.options.customAudioType[type]) {
|
||||||
|
if (Object.prototype.toString.call(this.options.customAudioType[type]) === '[object Function]') {
|
||||||
|
this.options.customAudioType[type](this.audio, audio, this);
|
||||||
|
} else {
|
||||||
|
console.error(`Illegal customType: ${type}`);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
const audio = this.options.audio[this.playIndex];
|
if (!type || type === 'auto') {
|
||||||
// set html
|
if (/m3u8(#|\?|$)/i.exec(audio.url)) {
|
||||||
if (audio.cover) {
|
type = 'hls';
|
||||||
this.template.pic.style.backgroundImage = `url('${audio.cover}')`;
|
} else {
|
||||||
}
|
type = 'normal';
|
||||||
else {
|
|
||||||
this.template.pic.style.backgroundImage = '';
|
|
||||||
}
|
|
||||||
this.theme();
|
|
||||||
this.template.title.innerHTML = audio.name;
|
|
||||||
this.template.author.innerHTML = audio.artist ? ' - ' + audio.artist : '';
|
|
||||||
const light = this.container.getElementsByClassName('aplayer-list-light')[0];
|
|
||||||
if (light) {
|
|
||||||
light.classList.remove('aplayer-list-light');
|
|
||||||
}
|
|
||||||
this.container.querySelectorAll('.aplayer-list li')[this.playIndex].classList.add('aplayer-list-light');
|
|
||||||
|
|
||||||
this.template.list.scrollTop = this.playIndex * 33;
|
|
||||||
|
|
||||||
// mse
|
|
||||||
if (this.hls) {
|
|
||||||
this.hls.destroy();
|
|
||||||
this.hls = null;
|
|
||||||
}
|
|
||||||
let type = audio.type;
|
|
||||||
if (this.options.customAudioType && this.options.customAudioType[type]) {
|
|
||||||
if (Object.prototype.toString.call(this.options.customAudioType[type]) === '[object Function]') {
|
|
||||||
this.options.customAudioType[type](this.audio, audio, this);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.error(`Illegal customType: ${type}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
if (type === 'hls') {
|
||||||
if (!type || type === 'auto') {
|
if (window.Hls.isSupported()) {
|
||||||
if (/m3u8(#|\?|$)/i.exec(audio.url)) {
|
this.hls = new window.Hls();
|
||||||
type = 'hls';
|
this.hls.loadSource(audio.url);
|
||||||
}
|
this.hls.attachMedia(this.audio);
|
||||||
else {
|
} else if (this.audio.canPlayType('application/x-mpegURL') || this.audio.canPlayType('application/vnd.apple.mpegURL')) {
|
||||||
type = 'normal';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (type === 'hls') {
|
|
||||||
if (Hls.isSupported()) {
|
|
||||||
this.hls = new Hls();
|
|
||||||
this.hls.loadSource(audio.url);
|
|
||||||
this.hls.attachMedia(this.audio);
|
|
||||||
}
|
|
||||||
else if (this.audio.canPlayType('application/x-mpegURL') || this.audio.canPlayType('application/vnd.apple.mpegURL')) {
|
|
||||||
this.audio.src = audio.url;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.notice('Error: HLS is not supported.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (type === 'normal') {
|
|
||||||
this.audio.src = audio.url;
|
this.audio.src = audio.url;
|
||||||
|
} else {
|
||||||
|
this.notice('Error: HLS is not supported.');
|
||||||
}
|
}
|
||||||
|
} else if (type === 'normal') {
|
||||||
|
this.audio.src = audio.url;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.seek(0);
|
|
||||||
|
|
||||||
let playPromise;
|
|
||||||
if (!this.paused) {
|
|
||||||
playPromise = Promise.resolve(this.audio.play()).catch((err) => {
|
|
||||||
console.error(err);
|
|
||||||
this.pause();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.lrc && this.lrc.switch(this.playIndex);
|
|
||||||
|
|
||||||
// set duration time
|
|
||||||
if (this.audio.duration !== 1) { // compatibility: Android browsers will output 1 at first
|
|
||||||
this.template.dtime.innerHTML = this.audio.duration ? utils.secondToTime(this.audio.duration) : '00:00';
|
|
||||||
}
|
|
||||||
|
|
||||||
return playPromise;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
theme (color = this.options.audio[this.playIndex].theme, index = this.playIndex) {
|
theme(color = this.list.audios[this.list.index].theme || this.options.theme, index = this.list.index, isReset = true) {
|
||||||
this.options.audio[index].theme = color;
|
if (isReset) {
|
||||||
this.template.listCurs[index].style.backgroundColor = color;
|
this.list.audios[index] && (this.list.audios[index].theme = color);
|
||||||
if (index === this.playIndex) {
|
}
|
||||||
|
this.template.listCurs[index] && (this.template.listCurs[index].style.backgroundColor = color);
|
||||||
|
if (index === this.list.index) {
|
||||||
this.template.pic.style.backgroundColor = color;
|
this.template.pic.style.backgroundColor = color;
|
||||||
this.template.played.style.background = color;
|
this.template.played.style.background = color;
|
||||||
this.template.thumb.style.background = color;
|
this.template.thumb.style.background = color;
|
||||||
@@ -292,82 +264,83 @@ class APlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
seek (time) {
|
seek(time) {
|
||||||
time = Math.max(time, 0);
|
time = Math.max(time, 0);
|
||||||
if (this.audio.duration) {
|
time = Math.min(time, this.duration);
|
||||||
time = Math.min(time, this.audio.duration);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.audio.currentTime = time;
|
this.audio.currentTime = time;
|
||||||
|
this.bar.set('played', time / this.duration, 'width');
|
||||||
if (isNaN(this.audio.duration)) {
|
|
||||||
this.bar.set('played', 0, 'width');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.bar.set('played', time / this.audio.duration, 'width');
|
|
||||||
}
|
|
||||||
this.template.ptime.innerHTML = utils.secondToTime(time);
|
this.template.ptime.innerHTML = utils.secondToTime(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
play () {
|
get duration() {
|
||||||
this.handlePlayPromise(() => {
|
return isNaN(this.audio.duration) ? 0 : this.audio.duration;
|
||||||
if (this.paused) {
|
}
|
||||||
this.paused = false;
|
|
||||||
this.template.button.classList.remove('aplayer-play');
|
|
||||||
this.template.button.classList.add('aplayer-pause');
|
|
||||||
this.template.button.innerHTML = '';
|
|
||||||
setTimeout(() => {
|
|
||||||
this.template.button.innerHTML = Icons.pause;
|
|
||||||
}, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
const playPromise = Promise.resolve(this.audio.play()).catch((err) => {
|
setUIPlaying() {
|
||||||
console.error(err);
|
if (this.paused) {
|
||||||
this.pause();
|
this.paused = false;
|
||||||
});
|
this.template.button.classList.remove('aplayer-play');
|
||||||
|
this.template.button.classList.add('aplayer-pause');
|
||||||
|
this.template.button.innerHTML = '';
|
||||||
|
setTimeout(() => {
|
||||||
|
this.template.button.innerHTML = Icons.pause;
|
||||||
|
}, 100);
|
||||||
|
this.template.skipPlayButton.innerHTML = Icons.pause;
|
||||||
|
}
|
||||||
|
|
||||||
this.timer.enable('loading');
|
this.timer.enable('loading');
|
||||||
|
|
||||||
if (this.options.mutex) {
|
if (this.options.mutex) {
|
||||||
for (let i = 0; i < instances.length; i++) {
|
for (let i = 0; i < instances.length; i++) {
|
||||||
if (this !== instances[i]) {
|
if (this !== instances[i]) {
|
||||||
instances[i].pause();
|
instances[i].pause();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return playPromise;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pause () {
|
play() {
|
||||||
this.handlePlayPromise(() => {
|
this.setUIPlaying();
|
||||||
if (!this.paused) {
|
|
||||||
this.paused = true;
|
|
||||||
|
|
||||||
this.template.button.classList.remove('aplayer-pause');
|
const playPromise = this.audio.play();
|
||||||
this.template.button.classList.add('aplayer-play');
|
if (playPromise) {
|
||||||
this.template.button.innerHTML = '';
|
playPromise.catch((e) => {
|
||||||
setTimeout(() => {
|
console.warn(e);
|
||||||
this.template.button.innerHTML = Icons.play;
|
if (e.name === 'NotAllowedError') {
|
||||||
}, 100);
|
this.setUIPaused();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
this.audio.pause();
|
}
|
||||||
|
|
||||||
this.container.classList.remove('aplayer-loading');
|
|
||||||
this.timer.disable('loading');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switchVolumeIcon () {
|
setUIPaused() {
|
||||||
|
if (!this.paused) {
|
||||||
|
this.paused = true;
|
||||||
|
|
||||||
|
this.template.button.classList.remove('aplayer-pause');
|
||||||
|
this.template.button.classList.add('aplayer-play');
|
||||||
|
this.template.button.innerHTML = '';
|
||||||
|
setTimeout(() => {
|
||||||
|
this.template.button.innerHTML = Icons.play;
|
||||||
|
}, 100);
|
||||||
|
this.template.skipPlayButton.innerHTML = Icons.play;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.container.classList.remove('aplayer-loading');
|
||||||
|
this.timer.disable('loading');
|
||||||
|
}
|
||||||
|
|
||||||
|
pause() {
|
||||||
|
this.setUIPaused();
|
||||||
|
this.audio.pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -375,14 +348,14 @@ 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);
|
||||||
percentage = Math.min(percentage, 1);
|
percentage = Math.min(percentage, 1);
|
||||||
this.bar.set('volume', percentage, 'height');
|
this.bar.set('volume', percentage, 'height');
|
||||||
if (!nostorage) {
|
if (!nostorage) {
|
||||||
this.user.set('volume', percentage);
|
this.storage.set('volume', percentage);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.audio.volume = percentage;
|
this.audio.volume = percentage;
|
||||||
@@ -399,121 +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
|
||||||
* get whether multiple audio definitions are loaded
|
switchAudio(index) {
|
||||||
*/
|
this.list.switch(index);
|
||||||
isMultiple () {
|
|
||||||
return this.options.audio.length > 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// abandoned
|
||||||
* get next random number
|
addAudio(audios) {
|
||||||
*/
|
this.list.add(audios);
|
||||||
nextRandomNum () {
|
|
||||||
if (this.isMultiple()) {
|
|
||||||
const index = this.randomOrder.indexOf(this.playIndex);
|
|
||||||
if (index === this.randomOrder.length - 1) {
|
|
||||||
return this.randomOrder[0];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return this.randomOrder[index + 1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// abandoned
|
||||||
* add audio dynamically
|
removeAudio(index) {
|
||||||
*
|
this.list.remove(index);
|
||||||
* @param {Array} newMusic
|
|
||||||
*/
|
|
||||||
addAudio (newMusic) {
|
|
||||||
this.events.trigger('addaudio', newMusic);
|
|
||||||
const wasSingle = !this.isMultiple();
|
|
||||||
|
|
||||||
this.options.audio = this.options.audio.concat(newMusic);
|
|
||||||
|
|
||||||
let newItemHTML = ``;
|
|
||||||
for (let i = 0; i < newMusic.length; i++) {
|
|
||||||
newItemHTML += `
|
|
||||||
<li>
|
|
||||||
<span class="aplayer-list-cur" style="background: ${newMusic[i].theme || this.options.theme};"></span>
|
|
||||||
<span class="aplayer-list-index">${this.options.audio.length - newMusic.length + i + 1}</span>
|
|
||||||
<span class="aplayer-list-title">${newMusic[i].name}</span>
|
|
||||||
<span class="aplayer-list-author">${newMusic[i].artist}</span>
|
|
||||||
</li>`;
|
|
||||||
}
|
|
||||||
this.template.listOl.innerHTML += newItemHTML;
|
|
||||||
|
|
||||||
if (wasSingle && this.isMultiple()) {
|
|
||||||
this.container.classList.add('aplayer-withlist');
|
|
||||||
this.audio.loop = false;
|
|
||||||
}
|
|
||||||
this.template.list.style.height = this.options.audio.length * 33 - 1 + 'px';
|
|
||||||
this.template.listOl.style.height = this.options.audio.length * 33 - 1 + 'px';
|
|
||||||
|
|
||||||
this.randomOrder = utils.randomOrder(this.options.audio.length);
|
|
||||||
this.template.listCurs = this.container.querySelectorAll('.aplayer-list-cur');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove song from playlist
|
|
||||||
*/
|
|
||||||
removeAudio (index) {
|
|
||||||
this.events.trigger('removeaudio', index);
|
|
||||||
if (this.options.audio[index] && this.options.audio.length > 1) {
|
|
||||||
const list = this.container.querySelectorAll('.aplayer-list li');
|
|
||||||
|
|
||||||
this.options.audio.splice(index, 1);
|
|
||||||
|
|
||||||
if (index === this.playIndex) {
|
|
||||||
if (this.options.audio[index + 1]) {
|
|
||||||
this.switchAudio(index);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.switchAudio(index - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.playIndex > index) {
|
|
||||||
this.playIndex--;
|
|
||||||
}
|
|
||||||
|
|
||||||
list[index].remove();
|
|
||||||
for (let i = index; i < list.length; i++) {
|
|
||||||
list[i].getElementsByClassName('aplayer-list-index')[0].textContent = i;
|
|
||||||
}
|
|
||||||
if (this.options.audio.length === 1) {
|
|
||||||
this.container.classList.remove('aplayer-withlist');
|
|
||||||
}
|
|
||||||
this.template.list.style.height = this.options.audio.length * 33 - 1 + 'px';
|
|
||||||
this.template.listOl.style.height = this.options.audio.length * 33 - 1 + 'px';
|
|
||||||
|
|
||||||
this.template.listCurs = this.container.querySelectorAll('.aplayer-list-cur');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 = '';
|
||||||
@@ -522,38 +414,75 @@ 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) {
|
||||||
clearTimeout(this.noticeTime);
|
clearTimeout(this.noticeTime);
|
||||||
}
|
}
|
||||||
this.events.trigger('notice_show', text);
|
this.events.trigger('noticeshow', {
|
||||||
|
text: text,
|
||||||
|
});
|
||||||
if (time) {
|
if (time) {
|
||||||
this.noticeTime = setTimeout(() => {
|
this.noticeTime = setTimeout(() => {
|
||||||
this.template.notice.style.opacity = 0;
|
this.template.notice.style.opacity = 0;
|
||||||
this.events.trigger('notice_hide');
|
this.events.trigger('noticehide');
|
||||||
}, time);
|
}, time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePlayPromise (callback) {
|
prevIndex() {
|
||||||
this.playedPromise = this.playedPromise.then(callback).catch((err) => {
|
if (this.list.audios.length > 1) {
|
||||||
console.error(err);
|
if (this.options.order === 'list') {
|
||||||
});
|
return this.list.index - 1 < 0 ? this.list.audios.length - 1 : this.list.index - 1;
|
||||||
|
} else if (this.options.order === 'random') {
|
||||||
|
const index = this.randomOrder.indexOf(this.list.index);
|
||||||
|
if (index === 0) {
|
||||||
|
return this.randomOrder[this.randomOrder.length - 1];
|
||||||
|
} else {
|
||||||
|
return this.randomOrder[index - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static get version () {
|
nextIndex() {
|
||||||
|
if (this.list.audios.length > 1) {
|
||||||
|
if (this.options.order === 'list') {
|
||||||
|
return (this.list.index + 1) % this.list.audios.length;
|
||||||
|
} else if (this.options.order === 'random') {
|
||||||
|
const index = this.randomOrder.indexOf(this.list.index);
|
||||||
|
if (index === this.randomOrder.length - 1) {
|
||||||
|
return this.randomOrder[0];
|
||||||
|
} else {
|
||||||
|
return this.randomOrder[index + 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
skipBack() {
|
||||||
|
this.list.switch(this.prevIndex());
|
||||||
|
}
|
||||||
|
|
||||||
|
skipForward() {
|
||||||
|
this.list.switch(this.nextIndex());
|
||||||
|
}
|
||||||
|
|
||||||
|
static get version() {
|
||||||
/* global APLAYER_VERSION */
|
/* global APLAYER_VERSION */
|
||||||
return APLAYER_VERSION;
|
return APLAYER_VERSION;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import utils from './utils';
|
||||||
|
|
||||||
|
class Storage {
|
||||||
|
constructor(player) {
|
||||||
|
this.storageName = player.options.storageName;
|
||||||
|
|
||||||
|
this.data = JSON.parse(utils.storage.get(this.storageName));
|
||||||
|
if (!this.data) {
|
||||||
|
this.data = {};
|
||||||
|
}
|
||||||
|
this.data.volume = this.data.volume || player.options.volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
get(key) {
|
||||||
|
return this.data[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
set(key, value) {
|
||||||
|
this.data[key] = value;
|
||||||
|
utils.storage.set(this.storageName, JSON.stringify(this.data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Storage;
|
||||||
+17
-9
@@ -2,36 +2,39 @@ 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.order === 'random') {
|
if (this.options.audio.length) {
|
||||||
cover = this.options.audio[this.randomOrder[0]].cover;
|
if (this.options.order === 'random') {
|
||||||
}
|
cover = this.options.audio[this.randomOrder[0]].cover;
|
||||||
else {
|
} else {
|
||||||
cover = this.options.audio[0].cover;
|
cover = this.options.audio[0].cover;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.container.innerHTML = tplPlayer({
|
this.container.innerHTML = tplPlayer({
|
||||||
options: this.options,
|
options: this.options,
|
||||||
icons: Icons,
|
icons: Icons,
|
||||||
cover: cover,
|
cover: cover,
|
||||||
|
getObject: (obj) => obj,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.lrc = this.container.querySelector('.aplayer-lrc-contents');
|
this.lrc = this.container.querySelector('.aplayer-lrc-contents');
|
||||||
|
this.lrcWrap = this.container.querySelector('.aplayer-lrc');
|
||||||
this.ptime = this.container.querySelector('.aplayer-ptime');
|
this.ptime = this.container.querySelector('.aplayer-ptime');
|
||||||
this.info = this.container.querySelector('.aplayer-info');
|
this.info = this.container.querySelector('.aplayer-info');
|
||||||
this.time = this.container.querySelector('.aplayer-time');
|
this.time = this.container.querySelector('.aplayer-time');
|
||||||
this.barWrap = this.container.querySelector('.aplayer-bar-wrap');
|
this.barWrap = this.container.querySelector('.aplayer-bar-wrap');
|
||||||
this.button = this.container.querySelector('.aplayer-button');
|
this.button = this.container.querySelector('.aplayer-button');
|
||||||
|
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');
|
||||||
@@ -48,6 +51,11 @@ class Template {
|
|||||||
this.author = this.container.querySelector('.aplayer-author');
|
this.author = this.container.querySelector('.aplayer-author');
|
||||||
this.dtime = this.container.querySelector('.aplayer-dtime');
|
this.dtime = this.container.querySelector('.aplayer-dtime');
|
||||||
this.notice = this.container.querySelector('.aplayer-notice');
|
this.notice = this.container.querySelector('.aplayer-notice');
|
||||||
|
this.miniSwitcher = this.container.querySelector('.aplayer-miniswitcher');
|
||||||
|
this.skipBackButton = this.container.querySelector('.aplayer-icon-back');
|
||||||
|
this.skipForwardButton = this.container.querySelector('.aplayer-icon-forward');
|
||||||
|
this.skipPlayButton = this.container.querySelector('.aplayer-icon-play');
|
||||||
|
this.lrcButton = this.container.querySelector('.aplayer-icon-lrc');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-20
@@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
class Timer {
|
class Timer {
|
||||||
constructor (player) {
|
constructor(player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
||||||
window.requestAnimationFrame = (() =>
|
window.requestAnimationFrame = (() =>
|
||||||
@@ -9,24 +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.map((item) => {
|
this.types.forEach((item) => {
|
||||||
this[`init${item}Checker`]();
|
this[`init${item}Checker`]();
|
||||||
return item;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initloadingChecker () {
|
initloadingChecker() {
|
||||||
let lastPlayPos = 0;
|
let lastPlayPos = 0;
|
||||||
let currentPlayPos = 0;
|
let currentPlayPos = 0;
|
||||||
let bufferingDetected = false;
|
let bufferingDetected = false;
|
||||||
@@ -34,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;
|
||||||
}
|
}
|
||||||
@@ -51,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') {
|
||||||
@@ -59,15 +52,14 @@ class Timer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
disable (type) {
|
disable(type) {
|
||||||
this[`enable${type}Checker`] = false;
|
this[`enable${type}Checker`] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy () {
|
destroy() {
|
||||||
this.types.map((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`]);
|
||||||
return item;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
import utils from './utils';
|
|
||||||
|
|
||||||
class User {
|
|
||||||
constructor (player) {
|
|
||||||
this.storageName = {
|
|
||||||
volume: 'aplayer-volume',
|
|
||||||
};
|
|
||||||
this.default = {
|
|
||||||
volume: player.options.volume || 0.7,
|
|
||||||
};
|
|
||||||
this.data = {};
|
|
||||||
|
|
||||||
this.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
init () {
|
|
||||||
for (const item in this.storageName) {
|
|
||||||
const name = this.storageName[item];
|
|
||||||
this.data[item] = parseFloat(utils.storage.get(name) || this.default[item]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
get (key) {
|
|
||||||
return this.data[key];
|
|
||||||
}
|
|
||||||
|
|
||||||
set (key, value) {
|
|
||||||
this.data[key] = value;
|
|
||||||
utils.storage.set(this.storageName[key], value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default User;
|
|
||||||
+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) => {
|
|
||||||
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 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 = this.options.audio.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;
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{{each audio}}
|
||||||
|
<li>
|
||||||
|
<span class="aplayer-list-cur" style="background-color: {{ $value.theme || theme }};"></span>
|
||||||
|
<span class="aplayer-list-index">{{ $index + index }}</span>
|
||||||
|
<span class="aplayer-list-title">{{ $value.name }}</span>
|
||||||
|
<span class="aplayer-list-author">{{ $value.artist }}</span>
|
||||||
|
</li>
|
||||||
|
{{/each}}
|
||||||
+94
-14
@@ -1,10 +1,11 @@
|
|||||||
|
{{ if !options.fixed }}
|
||||||
<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>
|
||||||
</div>
|
</div>
|
||||||
<div class="aplayer-info">
|
<div class="aplayer-info">
|
||||||
<div class="aplayer-music">
|
<div class="aplayer-music">
|
||||||
<span class="aplayer-title"></span>
|
<span class="aplayer-title">No audio</span>
|
||||||
<span class="aplayer-author"></span>
|
<span class="aplayer-author"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="aplayer-lrc">
|
<div class="aplayer-lrc">
|
||||||
@@ -25,6 +26,15 @@
|
|||||||
<span class="aplayer-time-inner">
|
<span class="aplayer-time-inner">
|
||||||
<span class="aplayer-ptime">00:00</span> / <span class="aplayer-dtime">00:00</span>
|
<span class="aplayer-ptime">00:00</span> / <span class="aplayer-dtime">00:00</span>
|
||||||
</span>
|
</span>
|
||||||
|
<span class="aplayer-icon aplayer-icon-back">
|
||||||
|
{{@ icons.skip }}
|
||||||
|
</span>
|
||||||
|
<span class="aplayer-icon aplayer-icon-play">
|
||||||
|
{{@ icons.play }}
|
||||||
|
</span>
|
||||||
|
<span class="aplayer-icon aplayer-icon-forward">
|
||||||
|
{{@ icons.skip }}
|
||||||
|
</span>
|
||||||
<div class="aplayer-volume-wrap">
|
<div class="aplayer-volume-wrap">
|
||||||
<button type="button" class="aplayer-icon aplayer-icon-volume-down">
|
<button type="button" class="aplayer-icon aplayer-icon-volume-down">
|
||||||
{{@ icons.volumeDown }}
|
{{@ icons.volumeDown }}
|
||||||
@@ -35,31 +45,101 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{ if options.audio.length > 1 }}
|
|
||||||
<button type="button" class="aplayer-icon aplayer-icon-order">
|
<button type="button" class="aplayer-icon aplayer-icon-order">
|
||||||
{{ if options.order === 'list' }}{{@ icons.orderList }}{{ else if options.order === 'random' }}{{@ icons.orderRandom }}{{ /if }}
|
{{ if options.order === 'list' }}{{@ icons.orderList }}{{ else if options.order === 'random' }}{{@ icons.orderRandom }}{{ /if }}
|
||||||
</button>
|
</button>
|
||||||
{{ /if }}
|
|
||||||
<button type="button" class="aplayer-icon aplayer-icon-loop">
|
<button type="button" class="aplayer-icon aplayer-icon-loop">
|
||||||
{{ if options.loop === 'one' }}{{@ icons.loopOne }}{{ else if options.loop === 'all' }}{{@ icons.loopAll }}{{ else if options.loop === 'none' }}{{@ icons.loopNone }}{{ /if }}
|
{{ if options.loop === 'one' }}{{@ icons.loopOne }}{{ else if options.loop === 'all' }}{{@ icons.loopAll }}{{ else if options.loop === 'none' }}{{@ icons.loopNone }}{{ /if }}
|
||||||
</button>
|
</button>
|
||||||
<button type="button" class="aplayer-icon aplayer-icon-menu">
|
<button type="button" class="aplayer-icon aplayer-icon-menu">
|
||||||
{{@ icons.menu }}
|
{{@ icons.menu }}
|
||||||
</button>
|
</button>
|
||||||
|
<button type="button" class="aplayer-icon aplayer-icon-lrc">
|
||||||
|
{{@ icons.lrc }}
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="aplayer-notice"></div>
|
<div class="aplayer-notice"></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({
|
||||||
{{each options.audio}}
|
theme: options.theme,
|
||||||
<li>
|
audio: options.audio,
|
||||||
<span class="aplayer-list-cur" style="background-color: {{ $value.theme || options.theme }};"></span>
|
index: 1
|
||||||
<span class="aplayer-list-index">{{ $index + 1 }}</span>
|
}) }}
|
||||||
<span class="aplayer-list-title">{{ $value.name }}</span>
|
</ol>
|
||||||
<span class="aplayer-list-author">{{ $value.artist }}</span>
|
{{ else }}
|
||||||
</li>
|
<ol class="aplayer-list{{ if options.listFolded }} aplayer-list-hide{{ /if }}">
|
||||||
{{/each}}
|
{{ include './list-item.art' getObject({
|
||||||
</ol>
|
theme: options.theme,
|
||||||
|
audio: options.audio,
|
||||||
|
index: 1
|
||||||
|
}) }}
|
||||||
|
</ol>
|
||||||
|
<div class="aplayer-body">
|
||||||
|
<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>
|
||||||
|
<div class="aplayer-info" style="display: none;">
|
||||||
|
<div class="aplayer-music">
|
||||||
|
<span class="aplayer-title">No audio</span>
|
||||||
|
<span class="aplayer-author"></span>
|
||||||
|
</div>
|
||||||
|
<div class="aplayer-controller">
|
||||||
|
<div class="aplayer-bar-wrap">
|
||||||
|
<div class="aplayer-bar">
|
||||||
|
<div class="aplayer-loaded" style="width: 0"></div>
|
||||||
|
<div class="aplayer-played" style="width: 0; background: {{ options.theme }};">
|
||||||
|
<span class="aplayer-thumb" style="background: {{ options.theme }};">
|
||||||
|
<span class="aplayer-loading-icon">{{@ icons.loading }}</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="aplayer-time">
|
||||||
|
<span class="aplayer-time-inner">
|
||||||
|
<span class="aplayer-ptime">00:00</span> / <span class="aplayer-dtime">00:00</span>
|
||||||
|
</span>
|
||||||
|
<span class="aplayer-icon aplayer-icon-back">
|
||||||
|
{{@ icons.skip }}
|
||||||
|
</span>
|
||||||
|
<span class="aplayer-icon aplayer-icon-play">
|
||||||
|
{{@ icons.play }}
|
||||||
|
</span>
|
||||||
|
<span class="aplayer-icon aplayer-icon-forward">
|
||||||
|
{{@ icons.skip }}
|
||||||
|
</span>
|
||||||
|
<div class="aplayer-volume-wrap">
|
||||||
|
<button type="button" class="aplayer-icon aplayer-icon-volume-down">
|
||||||
|
{{@ icons.volumeDown }}
|
||||||
|
</button>
|
||||||
|
<div class="aplayer-volume-bar-wrap">
|
||||||
|
<div class="aplayer-volume-bar">
|
||||||
|
<div class="aplayer-volume" style="height: 80%; background: {{ options.theme }};"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="aplayer-icon aplayer-icon-order">
|
||||||
|
{{ if options.order === 'list' }}{{@ icons.orderList }}{{ else if options.order === 'random' }}{{@ icons.orderRandom }}{{ /if }}
|
||||||
|
</button>
|
||||||
|
<button type="button" class="aplayer-icon aplayer-icon-loop">
|
||||||
|
{{ if options.loop === 'one' }}{{@ icons.loopOne }}{{ else if options.loop === 'all' }}{{@ icons.loopAll }}{{ else if options.loop === 'none' }}{{@ icons.loopNone }}{{ /if }}
|
||||||
|
</button>
|
||||||
|
<button type="button" class="aplayer-icon aplayer-icon-menu">
|
||||||
|
{{@ icons.menu }}
|
||||||
|
</button>
|
||||||
|
<button type="button" class="aplayer-icon aplayer-icon-lrc">
|
||||||
|
{{@ icons.lrc }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="aplayer-notice"></div>
|
||||||
|
<div class="aplayer-miniswitcher"><button class="aplayer-icon">{{@ icons.right }}</button></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="aplayer-lrc">
|
||||||
|
<div class="aplayer-lrc-contents" style="transform: translateY(0); -webkit-transform: translateY(0);"></div>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# https://tea.xyz/what-is-this-file
|
||||||
|
---
|
||||||
|
version: 1.0.0
|
||||||
|
codeOwners:
|
||||||
|
- '0x185bfcef7b37010e2511309048a130f477f54fBf'
|
||||||
|
quorum: 1
|
||||||
+35
-43
@@ -1,15 +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',
|
||||||
|
|
||||||
devtool: 'cheap-module-source-map',
|
devtool: 'cheap-module-source-map',
|
||||||
|
|
||||||
entry: {
|
entry: {
|
||||||
'APlayer': './src/js/index.js'
|
APlayer: './src/js/index.js',
|
||||||
},
|
},
|
||||||
|
|
||||||
output: {
|
output: {
|
||||||
@@ -19,72 +21,64 @@ 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: require.resolve('eslint-loader'),
|
|
||||||
include: path.resolve(__dirname, '../src/js'),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
test: /\.js$/,
|
test: /\.js$/,
|
||||||
use: [
|
use: [
|
||||||
{
|
{
|
||||||
loader: require.resolve('babel-loader'),
|
loader: 'babel-loader',
|
||||||
options: {
|
options: {
|
||||||
cacheDirectory: true,
|
cacheDirectory: true,
|
||||||
presets: ['env']
|
presets: ['@babel/preset-env'],
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.scss$/,
|
test: /\.scss$/,
|
||||||
use: [
|
use: [
|
||||||
require.resolve('style-loader'),
|
'style-loader',
|
||||||
{
|
{
|
||||||
loader: require.resolve('css-loader'),
|
loader: 'css-loader',
|
||||||
options: {
|
options: {
|
||||||
importLoaders: 1
|
importLoaders: 1,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
loader: require.resolve('postcss-loader'),
|
loader: 'postcss-loader',
|
||||||
options: {
|
options: {
|
||||||
config: {
|
plugins: [autoprefixer, cssnano],
|
||||||
path: path.join(__dirname, 'postcss.config.js')
|
},
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
require.resolve('sass-loader')
|
'sass-loader',
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.(png|jpg)$/,
|
test: /\.(png|jpg)$/,
|
||||||
loader: require.resolve('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: {
|
||||||
@@ -94,30 +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.NamedModulesPlugin(),
|
|
||||||
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': {}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
+36
-61
@@ -1,18 +1,19 @@
|
|||||||
/* eslint-disable no-undef */
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
const ExtractTextPlugin = require('extract-text-webpack-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',
|
||||||
|
|
||||||
bail: true,
|
bail: true,
|
||||||
|
|
||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
|
|
||||||
entry: {
|
entry: {
|
||||||
'APlayer': './src/js/index.js'
|
APlayer: './src/js/index.js',
|
||||||
},
|
},
|
||||||
|
|
||||||
output: {
|
output: {
|
||||||
@@ -22,97 +23,72 @@ 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: require.resolve('eslint-loader'),
|
|
||||||
include: path.resolve(__dirname, '../src/js'),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
test: /\.js$/,
|
test: /\.js$/,
|
||||||
use: [
|
use: [
|
||||||
require.resolve('template-string-optimize-loader'),
|
'template-string-optimize-loader',
|
||||||
{
|
{
|
||||||
loader: require.resolve('babel-loader'),
|
loader: 'babel-loader',
|
||||||
options: {
|
options: {
|
||||||
compact: true,
|
cacheDirectory: true,
|
||||||
presets: ['env']
|
presets: ['@babel/preset-env'],
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.scss$/,
|
test: /\.scss$/,
|
||||||
use: ExtractTextPlugin.extract({
|
use: [
|
||||||
fallback: require.resolve('style-loader'),
|
'style-loader',
|
||||||
use: [
|
{
|
||||||
{
|
loader: 'css-loader',
|
||||||
loader: require.resolve('css-loader'),
|
options: {
|
||||||
options: {
|
importLoaders: 1,
|
||||||
importLoaders: 1,
|
|
||||||
minimize: true,
|
|
||||||
sourceMap: true
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
},
|
||||||
loader: require.resolve('postcss-loader'),
|
{
|
||||||
options: {
|
loader: 'postcss-loader',
|
||||||
config: {
|
options: {
|
||||||
path: path.join(__dirname, 'postcss.config.js')
|
plugins: [autoprefixer, cssnano],
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
require.resolve('sass-loader')
|
},
|
||||||
]
|
'sass-loader',
|
||||||
})
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.(png|jpg)$/,
|
test: /\.(png|jpg)$/,
|
||||||
loader: require.resolve('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 webpack.optimize.UglifyJsPlugin({
|
|
||||||
compress: {
|
|
||||||
warnings: false
|
|
||||||
},
|
|
||||||
output: {
|
|
||||||
comments: false,
|
|
||||||
ascii_only: true
|
|
||||||
},
|
|
||||||
sourceMap: true
|
|
||||||
}),
|
|
||||||
new ExtractTextPlugin({
|
|
||||||
filename: '[name].min.css'
|
|
||||||
})
|
|
||||||
],
|
],
|
||||||
|
|
||||||
node: {
|
node: {
|
||||||
@@ -120,6 +96,5 @@ module.exports = {
|
|||||||
fs: 'empty',
|
fs: 'empty',
|
||||||
net: 'empty',
|
net: 'empty',
|
||||||
tls: 'empty',
|
tls: 'empty',
|
||||||
}
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user