Skip to content

Commit dedcfbf

Browse files
committed
switch to next song in mobile, close DIYgod#138
1 parent f0927af commit dedcfbf

5 files changed

Lines changed: 752 additions & 681 deletions

File tree

dist/APlayer.min.js

Lines changed: 1 addition & 7 deletions
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: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aplayer",
3-
"version": "1.6.0",
3+
"version": "1.6.1",
44
"description": "Wow, such a beautiful html5 music player",
55
"main": "dist/APlayer.min.js",
66
"scripts": {
@@ -24,19 +24,19 @@
2424
},
2525
"homepage": "https://github.com/DIYgod/APlayer#readme",
2626
"devDependencies": {
27-
"autoprefixer": "^6.7.2",
27+
"autoprefixer": "^7.1.1",
2828
"babel-core": "^6.22.1",
29-
"babel-loader": "^6.2.10",
29+
"babel-loader": "^7.0.0",
3030
"babel-preset-es2015": "^6.22.0",
31-
"css-loader": "^0.27.1",
31+
"css-loader": "^0.28.4",
3232
"exports-loader": "^0.6.3",
33-
"file-loader": "^0.10.0",
33+
"file-loader": "^0.11.2",
3434
"node-sass": "^4.5.0",
35-
"postcss-loader": "^1.2.2",
35+
"postcss-loader": "^2.0.5",
3636
"sass-loader": "^6.0.3",
37-
"style-loader": "^0.13.1",
37+
"style-loader": "^0.18.2",
3838
"url-loader": "^0.5.7",
39-
"webpack": "^2.2.1",
40-
"webpack-dev-server": "^2.3.0"
39+
"webpack": "^2.6.1",
40+
"webpack-dev-server": "^2.4.5"
4141
}
4242
}

src/APlayer.js

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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;");
22

33
require('./APlayer.scss');
44

@@ -460,15 +460,24 @@ class APlayer {
460460
this.element.getElementsByClassName('aplayer-list')[0].getElementsByTagName('li')[indexMusic].classList.add('aplayer-list-light');
461461

462462
// set the previous audio object
463-
if (this.audio) {
463+
if (!this.isMobile && this.audio) {
464464
this.pause();
465465
this.audio.currentTime = 0;
466466
}
467467

468468
this.element.getElementsByClassName('aplayer-list')[0].scrollTop = indexMusic * 33;
469469

470470
// 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 {
472481
this.audio = document.createElement("audio");
473482
this.audio.src = this.music.url;
474483
this.audio.preload = this.option.preload ? this.option.preload : 'auto';
@@ -553,11 +562,6 @@ class APlayer {
553562
this.ended = false;
554563
this.audio.addEventListener('ended', () => {
555564
if (this.multiple) {
556-
if (this.isMobile) {
557-
this.ended = true;
558-
this.pause();
559-
return;
560-
}
561565
if (this.audio.currentTime !== 0) {
562566
if (this.mode === 'random') {
563567
this.setMusic(this.nextRandomNum());
@@ -602,11 +606,6 @@ class APlayer {
602606

603607
this.audios[indexMusic] = this.audio;
604608
}
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-
}
610609

611610
/**
612611
* Parse lrc, suppose multiple time tag
@@ -725,10 +724,6 @@ class APlayer {
725724
this.play();
726725
}
727726
this.option.autoplay = true; // autoplay next music
728-
729-
if (this.isMobile) {
730-
this.pause();
731-
}
732727
}
733728

734729
/**

0 commit comments

Comments
 (0)