Fix bug: multiple ended event in iOS; clicking list error in mobile

This commit is contained in:
DIYgod
2016-05-14 22:37:48 +08:00
parent 47270238cb
commit 7b8ad10c04
3 changed files with 23 additions and 11 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+21 -9
View File
@@ -263,7 +263,12 @@
if (musicIndex !== this.playIndex) {
this.setMusic(musicIndex);
}
this.play();
if (this.isMobile) {
this.pause();
}
else {
this.play();
}
});
}
}
@@ -480,16 +485,23 @@
this.ended = false;
if (this.multiple) {
this.audio.addEventListener('ended', () => {
if (this.playIndex < this.option.music.length - 1) {
this.setMusic(++this.playIndex);
}
else if (this.loop) {
this.setMusic(0);
}
else if (!this.loop) {
if (this.isMobile) {
this.ended = true;
this.pause();
this.trigger('ended');
return;
}
if (this.audio.currentTime !== 0) {
if (this.playIndex < this.option.music.length - 1) {
this.setMusic(++this.playIndex);
}
else if (this.loop) {
this.setMusic(0);
}
else if (!this.loop) {
this.ended = true;
this.pause();
this.trigger('ended');
}
}
});
}