Fix song previews

This commit is contained in:
LoveEevee 2018-09-11 20:24:40 +03:00
parent 47f346eadb
commit 1c92f3b344
2 changed files with 7 additions and 5 deletions

View File

@ -3,7 +3,7 @@ function SongSelect(){
var _songs;
var _selectedSong = {title:'', folder:'', difficulty:''};
var _preview;
var _preview_ended
var _preview_id = 0
var _diffNames={
easy:"かんたん",
normal:"ふつう",
@ -14,7 +14,7 @@ function SongSelect(){
this.startPreview = function(id, prvtime, first_open=true) {
_this.endPreview();
var startLoad = +new Date
_preview_ended = false
var current_id = _preview_id
if(first_open){
snd.musicGain.fadeOut(0.4)
}
@ -30,7 +30,7 @@ function SongSelect(){
this.previewLoaded(startLoad, prvtime, first_open)
}else{
snd.previewGain.load("/songs/" + id + "/main.mp3").then(sound => {
if(!_preview_ended){
if(current_id == _preview_id){
songObj.sound = sound
_preview = sound
this.previewLoaded(startLoad, prvtime, first_open)
@ -48,7 +48,7 @@ function SongSelect(){
}
this.endPreview = function() {
_preview_ended = true
_preview_id++
if (_preview) {
_preview.stop();
};

View File

@ -124,7 +124,9 @@ class Sound{
playLoop(time, absolute, seek1, seek2, until){
time = this.convertTime(time, absolute)
seek1 = seek1 || 0
seek2 = seek2 || 0
if(typeof seek2 == "undefined"){
seek2 = seek1
}
until = until || this.duration
this.loop = {
started: time + until - seek1,