fix drag bug, new option: loop

This commit is contained in:
DIYgod 2016-05-05 20:57:30 +08:00
parent da71e49dc0
commit 40d95344fd
No known key found for this signature in database
GPG Key ID: F8797DD1088C6506
5 changed files with 16 additions and 7 deletions

View File

@ -57,6 +57,7 @@ var option = {
showlrc: 0, // Optional, show lrc, can be 0, 1, 2, see: ###With lrc
mutex: true, // Optional, pause other players when this player playing
theme: '#e6d0b2', // Optional, theme color, default: #b7daff
loop: true, // Optional, loop play music, default: true
music: { // Required, music info, see: ###With playlist
title: 'Preparation', // Required, music title
author: 'Hans Zimmer/Richard Harvey', // Required, music author

2
dist/APlayer.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "aplayer",
"version": "1.4.2",
"version": "1.4.3",
"description": "Wow, such a beautiful html5 music player",
"main": "dist/APlayer.min.js",
"scripts": {

View File

@ -22,7 +22,8 @@
autoplay: false,
mutex: true,
showlrc: 0,
theme: '#b7daff'
theme: '#b7daff',
loop: true
};
for (let defaultKey in defaultOption) {
if (defaultOption.hasOwnProperty(defaultKey) && !option.hasOwnProperty(defaultKey)) {
@ -35,7 +36,7 @@
this.option = option;
this.audios = [];
this.loop = true;
this.loop = option.loop;
/**
* Parse second to 00:00 format
@ -206,7 +207,7 @@
</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>`;
@ -303,7 +304,14 @@
document.removeEventListener('mouseup', thumbUp);
document.removeEventListener('mousemove', thumbMove);
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', () => {