|
1 | | -console.log("\n %c APlayer 1.6.0 %c http://aplayer.js.org \n\n","color: #fadfa3; background: #030307; padding:5px 0;","background: #fadfa3; padding:5px 0;"); |
| 1 | +console.log("\n %c APlayer 1.6.1 %c http://aplayer.js.org \n\n","color: #fadfa3; background: #030307; padding:5px 0;","background: #fadfa3; padding:5px 0;"); |
2 | 2 |
|
3 | 3 | require('./APlayer.scss'); |
4 | 4 |
|
@@ -460,15 +460,24 @@ class APlayer { |
460 | 460 | this.element.getElementsByClassName('aplayer-list')[0].getElementsByTagName('li')[indexMusic].classList.add('aplayer-list-light'); |
461 | 461 |
|
462 | 462 | // set the previous audio object |
463 | | - if (this.audio) { |
| 463 | + if (!this.isMobile && this.audio) { |
464 | 464 | this.pause(); |
465 | 465 | this.audio.currentTime = 0; |
466 | 466 | } |
467 | 467 |
|
468 | 468 | this.element.getElementsByClassName('aplayer-list')[0].scrollTop = indexMusic * 33; |
469 | 469 |
|
470 | 470 | // get this audio object |
471 | | - if (!this.audios[indexMusic]) { |
| 471 | + if (this.isMobile && this.audio) { |
| 472 | + this.audio.src = this.music.url; |
| 473 | + this.play(); |
| 474 | + } |
| 475 | + else if (!this.isMobile && this.audios[indexMusic]) { |
| 476 | + this.audio = this.audios[indexMusic]; |
| 477 | + this.audio.volume = parseInt(this.element.getElementsByClassName('aplayer-volume')[0].style.height) / 100; |
| 478 | + this.audio.currentTime = 0; |
| 479 | + } |
| 480 | + else { |
472 | 481 | this.audio = document.createElement("audio"); |
473 | 482 | this.audio.src = this.music.url; |
474 | 483 | this.audio.preload = this.option.preload ? this.option.preload : 'auto'; |
@@ -553,11 +562,6 @@ class APlayer { |
553 | 562 | this.ended = false; |
554 | 563 | this.audio.addEventListener('ended', () => { |
555 | 564 | if (this.multiple) { |
556 | | - if (this.isMobile) { |
557 | | - this.ended = true; |
558 | | - this.pause(); |
559 | | - return; |
560 | | - } |
561 | 565 | if (this.audio.currentTime !== 0) { |
562 | 566 | if (this.mode === 'random') { |
563 | 567 | this.setMusic(this.nextRandomNum()); |
@@ -602,11 +606,6 @@ class APlayer { |
602 | 606 |
|
603 | 607 | this.audios[indexMusic] = this.audio; |
604 | 608 | } |
605 | | - else { |
606 | | - this.audio = this.audios[indexMusic]; |
607 | | - this.audio.volume = parseInt(this.element.getElementsByClassName('aplayer-volume')[0].style.height) / 100; |
608 | | - this.audio.currentTime = 0; |
609 | | - } |
610 | 609 |
|
611 | 610 | /** |
612 | 611 | * Parse lrc, suppose multiple time tag |
@@ -725,10 +724,6 @@ class APlayer { |
725 | 724 | this.play(); |
726 | 725 | } |
727 | 726 | this.option.autoplay = true; // autoplay next music |
728 | | - |
729 | | - if (this.isMobile) { |
730 | | - this.pause(); |
731 | | - } |
732 | 727 | } |
733 | 728 |
|
734 | 729 | /** |
|
0 commit comments