Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12fc04957d | ||
|
|
c5776b2a78 | ||
|
|
548faa4bf3 | ||
|
|
91566de67a | ||
|
|
7b8ad10c04 |
@@ -7,7 +7,7 @@
|
|||||||
[](https://travis-ci.org/DIYgod/APlayer)
|
[](https://travis-ci.org/DIYgod/APlayer)
|
||||||
[](https://www.anotherhome.net/)
|
[](https://www.anotherhome.net/)
|
||||||
|
|
||||||
Wow, such a beautiful html5 music player
|
> Wow, such a beautiful html5 music player
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
@@ -58,6 +58,7 @@ var option = {
|
|||||||
mutex: true, // Optional, pause other players when this player playing
|
mutex: true, // Optional, pause other players when this player playing
|
||||||
theme: '#e6d0b2', // Optional, theme color, default: #b7daff
|
theme: '#e6d0b2', // Optional, theme color, default: #b7daff
|
||||||
loop: true, // Optional, loop play music, default: true
|
loop: true, // Optional, loop play music, default: true
|
||||||
|
preload: 'metadata', // Optional, the way to load music, can be 'none' 'metadata' 'auto', default: 'metadata' in Desktop, 'none' in mobile
|
||||||
music: { // Required, music info, see: ###With playlist
|
music: { // Required, music info, see: ###With playlist
|
||||||
title: 'Preparation', // Required, music title
|
title: 'Preparation', // Required, music title
|
||||||
author: 'Hans Zimmer/Richard Harvey', // Required, music author
|
author: 'Hans Zimmer/Richard Harvey', // Required, music author
|
||||||
@@ -191,9 +192,11 @@ $ npm run build
|
|||||||
|
|
||||||
## Related Projects
|
## Related Projects
|
||||||
|
|
||||||
+ [APlayer-Typecho-Plugin](https://github.com/zgq354/APlayer-Typecho-Plugin)
|
- [APlayer-Typecho-Plugin](https://github.com/zgq354/APlayer-Typecho-Plugin)
|
||||||
|
|
||||||
+ [hexo-tag-aplayer](https://github.com/grzhan/hexo-tag-aplayer)
|
- [hexo-tag-aplayer](https://github.com/grzhan/hexo-tag-aplayer)
|
||||||
|
|
||||||
|
- [163music-APlayer-you-get-docker](https://github.com/YUX-IO/163music-APlayer-you-get-docker)
|
||||||
|
|
||||||
|
|
||||||
## LICENSE
|
## LICENSE
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ var ap1 = new APlayer({
|
|||||||
showlrc: false,
|
showlrc: false,
|
||||||
mutex: true,
|
mutex: true,
|
||||||
theme: '#e6d0b2',
|
theme: '#e6d0b2',
|
||||||
|
preload: 'metadata',
|
||||||
music: {
|
music: {
|
||||||
title: 'Preparation',
|
title: 'Preparation',
|
||||||
author: 'Hans Zimmer/Richard Harvey',
|
author: 'Hans Zimmer/Richard Harvey',
|
||||||
|
|||||||
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
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "aplayer",
|
"name": "aplayer",
|
||||||
"version": "1.4.4",
|
"version": "1.4.6",
|
||||||
"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",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
+29
-12
@@ -175,7 +175,7 @@
|
|||||||
|
|
||||||
// fill in HTML
|
// fill in HTML
|
||||||
let eleHTML = `
|
let eleHTML = `
|
||||||
<div class="aplayer-pic" ${(this.music.pic ? (`style="background-image: url("${encodeURI(this.music.pic)}");"`) : ``)}>
|
<div class="aplayer-pic" ${(this.music.pic ? (`style="background-image: url(${encodeURI(this.music.pic)});"`) : ``)}>
|
||||||
<div class="aplayer-button aplayer-play">
|
<div class="aplayer-button aplayer-play">
|
||||||
<i class="demo-icon aplayer-icon-play"></i>
|
<i class="demo-icon aplayer-icon-play"></i>
|
||||||
</div>
|
</div>
|
||||||
@@ -263,7 +263,12 @@
|
|||||||
if (musicIndex !== this.playIndex) {
|
if (musicIndex !== this.playIndex) {
|
||||||
this.setMusic(musicIndex);
|
this.setMusic(musicIndex);
|
||||||
}
|
}
|
||||||
this.play();
|
if (this.isMobile) {
|
||||||
|
this.pause();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.play();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -450,7 +455,12 @@
|
|||||||
if ((this.multiple && !this.audios[indexMusic]) || this.playIndex === -1) {
|
if ((this.multiple && !this.audios[indexMusic]) || this.playIndex === -1) {
|
||||||
this.audio = document.createElement("audio");
|
this.audio = document.createElement("audio");
|
||||||
this.audio.src = this.music.url;
|
this.audio.src = this.music.url;
|
||||||
this.audio.preload = this.isMobile ? 'none' : 'metadata';
|
if (this.option.preload) {
|
||||||
|
this.audio.preload = this.option.preload;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.audio.preload = this.isMobile ? 'none' : 'metadata';
|
||||||
|
}
|
||||||
|
|
||||||
// show audio time: the metadata has loaded or changed
|
// show audio time: the metadata has loaded or changed
|
||||||
this.audio.addEventListener('durationchange', () => {
|
this.audio.addEventListener('durationchange', () => {
|
||||||
@@ -480,16 +490,23 @@
|
|||||||
this.ended = false;
|
this.ended = false;
|
||||||
if (this.multiple) {
|
if (this.multiple) {
|
||||||
this.audio.addEventListener('ended', () => {
|
this.audio.addEventListener('ended', () => {
|
||||||
if (this.playIndex < this.option.music.length - 1) {
|
if (this.isMobile) {
|
||||||
this.setMusic(++this.playIndex);
|
|
||||||
}
|
|
||||||
else if (this.loop) {
|
|
||||||
this.setMusic(0);
|
|
||||||
}
|
|
||||||
else if (!this.loop) {
|
|
||||||
this.ended = true;
|
this.ended = true;
|
||||||
this.pause();
|
this.pause();
|
||||||
this.trigger('ended');
|
return;
|
||||||
|
}
|
||||||
|
if (this.audio.currentTime !== 0) {
|
||||||
|
if (this.playIndex < this.option.music.length - 1) {
|
||||||
|
this.setMusic(++this.playIndex);
|
||||||
|
}
|
||||||
|
else if (this.loop) {
|
||||||
|
this.setMusic(0);
|
||||||
|
}
|
||||||
|
else if (!this.loop) {
|
||||||
|
this.ended = true;
|
||||||
|
this.pause();
|
||||||
|
this.trigger('ended');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -617,7 +634,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
|
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
|
||||||
module.exports = APlayer
|
module.exports = APlayer;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
window.APlayer = APlayer;
|
window.APlayer = APlayer;
|
||||||
|
|||||||
Reference in New Issue
Block a user