Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
008552940f | ||
|
|
40d95344fd | ||
|
|
da71e49dc0 | ||
|
|
b019271309 | ||
|
|
5206eed8e5 | ||
|
|
82b7f777f6 |
@@ -13,7 +13,7 @@ Wow, such a beautiful html5 music player
|
|||||||
|
|
||||||
UI 参考网易云音乐外链播放器
|
UI 参考网易云音乐外链播放器
|
||||||
|
|
||||||
[Demo](https://www.anotherhome.net/file/APlayer)
|
[Demo](http://diygod.github.io/APlayer/demo)
|
||||||
|
|
||||||
Screenshot
|
Screenshot
|
||||||

|

|
||||||
@@ -57,6 +57,7 @@ var option = {
|
|||||||
showlrc: 0, // Optional, show lrc, can be 0, 1, 2, see: ###With lrc
|
showlrc: 0, // Optional, show lrc, can be 0, 1, 2, see: ###With lrc
|
||||||
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
|
||||||
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
|
||||||
|
|||||||
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.2",
|
"version": "1.4.3",
|
||||||
"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": {
|
||||||
|
|||||||
+22
-15
@@ -1,5 +1,4 @@
|
|||||||
(() => {
|
((instances) => {
|
||||||
let APlayers = [];
|
|
||||||
|
|
||||||
class APlayer {
|
class APlayer {
|
||||||
/**
|
/**
|
||||||
@@ -23,7 +22,8 @@
|
|||||||
autoplay: false,
|
autoplay: false,
|
||||||
mutex: true,
|
mutex: true,
|
||||||
showlrc: 0,
|
showlrc: 0,
|
||||||
theme: '#b7daff'
|
theme: '#b7daff',
|
||||||
|
loop: true
|
||||||
};
|
};
|
||||||
for (let defaultKey in defaultOption) {
|
for (let defaultKey in defaultOption) {
|
||||||
if (defaultOption.hasOwnProperty(defaultKey) && !option.hasOwnProperty(defaultKey)) {
|
if (defaultOption.hasOwnProperty(defaultKey) && !option.hasOwnProperty(defaultKey)) {
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
this.option = option;
|
this.option = option;
|
||||||
this.audios = [];
|
this.audios = [];
|
||||||
this.loop = true;
|
this.loop = option.loop;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse second to 00:00 format
|
* Parse second to 00:00 format
|
||||||
@@ -207,7 +207,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<i class="demo-icon aplayer-icon-loop"></i>${(this.multiple ? `<i class="demo-icon aplayer-icon-menu"></i>` : ``)}
|
<i class="demo-icon aplayer-icon-loop${(this.loop ? `` : ` aplayer-noloop`)}"></i>${(this.multiple ? `<i class="demo-icon aplayer-icon-menu"></i>` : ``)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
@@ -304,7 +304,14 @@
|
|||||||
document.removeEventListener('mouseup', thumbUp);
|
document.removeEventListener('mouseup', thumbUp);
|
||||||
document.removeEventListener('mousemove', thumbMove);
|
document.removeEventListener('mousemove', thumbMove);
|
||||||
this.audio.currentTime = parseFloat(this.playedBar.style.width) / 100 * this.audio.duration;
|
this.audio.currentTime = parseFloat(this.playedBar.style.width) / 100 * this.audio.duration;
|
||||||
this.play();
|
this.playedTime = setInterval(() => {
|
||||||
|
this.updateBar('played', this.audio.currentTime / this.audio.duration, 'width');
|
||||||
|
if (this.option.showlrc) {
|
||||||
|
this.updateLrc();
|
||||||
|
}
|
||||||
|
this.element.getElementsByClassName('aplayer-ptime')[0].innerHTML = this.secondToTime(this.audio.currentTime);
|
||||||
|
this.trigger('playing');
|
||||||
|
}, 100);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.thumb.addEventListener('mousedown', () => {
|
this.thumb.addEventListener('mousedown', () => {
|
||||||
@@ -404,8 +411,8 @@
|
|||||||
|
|
||||||
this.setMusic(0);
|
this.setMusic(0);
|
||||||
|
|
||||||
APlayers.push(this);
|
instances.push(this);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set music
|
* Set music
|
||||||
@@ -541,7 +548,7 @@
|
|||||||
if (this.isMobile) {
|
if (this.isMobile) {
|
||||||
this.pause();
|
this.pause();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Play music
|
* Play music
|
||||||
@@ -557,9 +564,9 @@
|
|||||||
|
|
||||||
// pause other players (Thanks @Aprikyblue)
|
// pause other players (Thanks @Aprikyblue)
|
||||||
if (this.option.mutex) {
|
if (this.option.mutex) {
|
||||||
for (let i = 0; i < APlayers.length; i++) {
|
for (let i = 0; i < instances.length; i++) {
|
||||||
if (this != APlayers[i]) {
|
if (this != instances[i]) {
|
||||||
APlayers[i].pause();
|
instances[i].pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -577,7 +584,7 @@
|
|||||||
}, 100);
|
}, 100);
|
||||||
this.trigger('play');
|
this.trigger('play');
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pause music
|
* Pause music
|
||||||
@@ -595,7 +602,7 @@
|
|||||||
clearInterval(this.playedTime);
|
clearInterval(this.playedTime);
|
||||||
this.trigger('pause');
|
this.trigger('pause');
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* attach event
|
* attach event
|
||||||
@@ -613,4 +620,4 @@
|
|||||||
else {
|
else {
|
||||||
window.APlayer = APlayer;
|
window.APlayer = APlayer;
|
||||||
}
|
}
|
||||||
})();
|
})([]);
|
||||||
Reference in New Issue
Block a user