switch to next song in mobile, close #138

This commit is contained in:
DIYgod 2017-06-08 00:16:56 +08:00
parent f0927af30b
commit dedcfbf1ac
No known key found for this signature in database
GPG Key ID: EC0B76A252D3EF67
5 changed files with 757 additions and 686 deletions

8
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.6.0",
"version": "1.6.1",
"description": "Wow, such a beautiful html5 music player",
"main": "dist/APlayer.min.js",
"scripts": {
@ -24,19 +24,19 @@
},
"homepage": "https://github.com/DIYgod/APlayer#readme",
"devDependencies": {
"autoprefixer": "^6.7.2",
"autoprefixer": "^7.1.1",
"babel-core": "^6.22.1",
"babel-loader": "^6.2.10",
"babel-loader": "^7.0.0",
"babel-preset-es2015": "^6.22.0",
"css-loader": "^0.27.1",
"css-loader": "^0.28.4",
"exports-loader": "^0.6.3",
"file-loader": "^0.10.0",
"file-loader": "^0.11.2",
"node-sass": "^4.5.0",
"postcss-loader": "^1.2.2",
"postcss-loader": "^2.0.5",
"sass-loader": "^6.0.3",
"style-loader": "^0.13.1",
"style-loader": "^0.18.2",
"url-loader": "^0.5.7",
"webpack": "^2.2.1",
"webpack-dev-server": "^2.3.0"
"webpack": "^2.6.1",
"webpack-dev-server": "^2.4.5"
}
}

View File

@ -1,4 +1,4 @@
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;");
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;");
require('./APlayer.scss');
@ -460,7 +460,7 @@ class APlayer {
this.element.getElementsByClassName('aplayer-list')[0].getElementsByTagName('li')[indexMusic].classList.add('aplayer-list-light');
// set the previous audio object
if (this.audio) {
if (!this.isMobile && this.audio) {
this.pause();
this.audio.currentTime = 0;
}
@ -468,7 +468,16 @@ class APlayer {
this.element.getElementsByClassName('aplayer-list')[0].scrollTop = indexMusic * 33;
// get this audio object
if (!this.audios[indexMusic]) {
if (this.isMobile && this.audio) {
this.audio.src = this.music.url;
this.play();
}
else if (!this.isMobile && this.audios[indexMusic]) {
this.audio = this.audios[indexMusic];
this.audio.volume = parseInt(this.element.getElementsByClassName('aplayer-volume')[0].style.height) / 100;
this.audio.currentTime = 0;
}
else {
this.audio = document.createElement("audio");
this.audio.src = this.music.url;
this.audio.preload = this.option.preload ? this.option.preload : 'auto';
@ -553,11 +562,6 @@ class APlayer {
this.ended = false;
this.audio.addEventListener('ended', () => {
if (this.multiple) {
if (this.isMobile) {
this.ended = true;
this.pause();
return;
}
if (this.audio.currentTime !== 0) {
if (this.mode === 'random') {
this.setMusic(this.nextRandomNum());
@ -602,11 +606,6 @@ class APlayer {
this.audios[indexMusic] = this.audio;
}
else {
this.audio = this.audios[indexMusic];
this.audio.volume = parseInt(this.element.getElementsByClassName('aplayer-volume')[0].style.height) / 100;
this.audio.currentTime = 0;
}
/**
* Parse lrc, suppose multiple time tag
@ -725,10 +724,6 @@ class APlayer {
this.play();
}
this.option.autoplay = true; // autoplay next music
if (this.isMobile) {
this.pause();
}
}
/**

1386
yarn.lock

File diff suppressed because it is too large Load Diff