1
0
mirror of https://github.com/2ec0b4/kaamelott-soundboard.git synced 2025-12-09 16:05:35 +00:00

Stoppe la lecture en cours

This commit is contained in:
Antoine
2016-04-10 14:17:50 +02:00
parent 342ba56bf4
commit 190d2c6420
2 changed files with 12 additions and 3 deletions

View File

@@ -15,7 +15,9 @@ define(
play: function() { play: function() {
var audio = new Audio('sounds/'+this.attributes.file); var audio = new Audio('sounds/'+this.attributes.file);
return audio.play(); audio.play();
return audio;
} }
}); });

View File

@@ -11,7 +11,7 @@ define(
"use strict"; "use strict";
var SoundListView = Marionette.LayoutView.extend({ var SoundListView = Marionette.LayoutView.extend({
collection : new SoundsCollection(), collection: new SoundsCollection(),
template: SoundListTemplate, template: SoundListTemplate,
ui: { ui: {
soundItem: 'li a' soundItem: 'li a'
@@ -39,8 +39,15 @@ define(
e.preventDefault(); e.preventDefault();
this.stopCurrentPlay();
if( sound ) { if( sound ) {
sound.play(); this.currentPlay = sound.play();
}
},
stopCurrentPlay: function() {
if( this.currentPlay && !this.currentPlay.paused ) {
this.currentPlay.pause();
} }
}, },
serializeData: function () { serializeData: function () {