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

Proto bouton aléatoire

This commit is contained in:
Thomas Graviou
2019-10-16 11:28:49 +02:00
parent dc41717ed4
commit 0261f2b86b
6 changed files with 43 additions and 1 deletions

View File

@@ -28,6 +28,7 @@ define("views/sounds", function(require) {
this.channel = Radio.channel("Sounds");
this.channel.request("getSounds").then(this.initCollection.bind(this));
this.channel.on("sounds:filter", this.filterCollection.bind(this));
this.channel.on("sounds:random", this.randomSound.bind(this));
},
onBeforeRender: function() {
var sound;
@@ -57,6 +58,13 @@ define("views/sounds", function(require) {
Radio.channel("Sounds").trigger("sound:play", args.model.getSlug());
},
randomSound: function() {
var index = Math.floor(Math.random() * Math.floor(this.collection.length));
var sound = this.collection.models[index];
Radio.channel("Sounds").trigger("sound:play", sound.getSlug());
// sound.play();
},
stopPlayingSound: function() {
var playingSound = this.collection.findWhere({playing: true});