Skip to content

Commit 40d9534

Browse files
committed
fix drag bug, new option: loop
1 parent da71e49 commit 40d9534

5 files changed

Lines changed: 16 additions & 7 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ var option = {
5757
showlrc: 0, // Optional, show lrc, can be 0, 1, 2, see: ###With lrc
5858
mutex: true, // Optional, pause other players when this player playing
5959
theme: '#e6d0b2', // Optional, theme color, default: #b7daff
60+
loop: true, // Optional, loop play music, default: true
6061
music: { // Required, music info, see: ###With playlist
6162
title: 'Preparation', // Required, music title
6263
author: 'Hans Zimmer/Richard Harvey', // Required, music author

dist/APlayer.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/APlayer.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aplayer",
3-
"version": "1.4.2",
3+
"version": "1.4.3",
44
"description": "Wow, such a beautiful html5 music player",
55
"main": "dist/APlayer.min.js",
66
"scripts": {

src/APlayer.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
autoplay: false,
2323
mutex: true,
2424
showlrc: 0,
25-
theme: '#b7daff'
25+
theme: '#b7daff',
26+
loop: true
2627
};
2728
for (let defaultKey in defaultOption) {
2829
if (defaultOption.hasOwnProperty(defaultKey) && !option.hasOwnProperty(defaultKey)) {
@@ -35,7 +36,7 @@
3536

3637
this.option = option;
3738
this.audios = [];
38-
this.loop = true;
39+
this.loop = option.loop;
3940

4041
/**
4142
* Parse second to 00:00 format
@@ -206,7 +207,7 @@
206207
</div>
207208
</div>
208209
</div>
209-
<i class="demo-icon aplayer-icon-loop"></i>${(this.multiple ? `<i class="demo-icon aplayer-icon-menu"></i>` : ``)}
210+
<i class="demo-icon aplayer-icon-loop${(this.loop ? `` : ` aplayer-noloop`)}"></i>${(this.multiple ? `<i class="demo-icon aplayer-icon-menu"></i>` : ``)}
210211
</div>
211212
</div>
212213
</div>`;
@@ -303,7 +304,14 @@
303304
document.removeEventListener('mouseup', thumbUp);
304305
document.removeEventListener('mousemove', thumbMove);
305306
this.audio.currentTime = parseFloat(this.playedBar.style.width) / 100 * this.audio.duration;
306-
this.play();
307+
this.playedTime = setInterval(() => {
308+
this.updateBar('played', this.audio.currentTime / this.audio.duration, 'width');
309+
if (this.option.showlrc) {
310+
this.updateLrc();
311+
}
312+
this.element.getElementsByClassName('aplayer-ptime')[0].innerHTML = this.secondToTime(this.audio.currentTime);
313+
this.trigger('playing');
314+
}, 100);
307315
};
308316

309317
this.thumb.addEventListener('mousedown', () => {

0 commit comments

Comments
 (0)