Skip to content

Commit

Permalink
switch to next song in mobile, close #138
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Jun 7, 2017
1 parent f0927af commit dedcfbf
Show file tree
Hide file tree
Showing 5 changed files with 752 additions and 681 deletions.
8 changes: 1 addition & 7 deletions dist/APlayer.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/APlayer.min.js.map

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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"
}
}
29 changes: 12 additions & 17 deletions src/APlayer.js
Original file line number Diff line number Diff line change
@@ -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');

Expand Down Expand Up @@ -460,15 +460,24 @@ 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;
}

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';
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -725,10 +724,6 @@ class APlayer {
this.play();
}
this.option.autoplay = true; // autoplay next music

if (this.isMobile) {
this.pause();
}
}

/**
Expand Down
Loading

0 comments on commit dedcfbf

Please sign in to comment.