mirror of
https://github.com/2ec0b4/kaamelott-soundboard.git
synced 2025-12-08 15:43:24 +00:00
Corrige une erreur sur l'autoplay pour Google Chrome
This commit is contained in:
@@ -19,11 +19,20 @@ define("models/sound", function(require) {
|
||||
this.audio = new Audio("sounds/"+this.get("file"));
|
||||
}
|
||||
|
||||
this.audio.play();
|
||||
var that = this,
|
||||
promise = this.audio.play();
|
||||
|
||||
if (promise !== undefined) {
|
||||
promise.then(function(_) {
|
||||
that.set("playing", true);
|
||||
}).catch(function(error) {
|
||||
});
|
||||
} else {
|
||||
this.set("playing", true);
|
||||
}
|
||||
|
||||
this.audio.onended = this.stop.bind(this);
|
||||
this.audio.onpause = this.stop.bind(this);
|
||||
|
||||
this.set("playing", true);
|
||||
},
|
||||
stop: function() {
|
||||
if( this.audio && !this.audio.paused ) {
|
||||
|
||||
Reference in New Issue
Block a user