mirror of
https://github.com/2ec0b4/kaamelott-soundboard.git
synced 2025-12-10 08:25:34 +00:00
* Permet la lecture d'un son passé en paramètre d'URL * Remplace du code créé par l'utilisation d'un template * Ajoute un bouton de partage * Ajoute une région pour gérer une modal * Affiche une modal de partage * Améliore le style du flash de sélection de son * Corrige un mauvais appel de fonction * Supprime la destruction de la vue au scroll de la fenêtre : le comportement n'est pas idéal sur iOS quand il y a le focus sur l'input * Ne joue pas automatiquement le son partagé sur iOS (après avoir tenté : https://paulbakaus.com/tutorials/html5/web-audio-on-ios/ ) * Permet d'éviter le zoom au focus sur l'input * Ajoute, dans le style, des préfixes manquants
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
define("models/sound", function(require) {
|
|
"use strict";
|
|
|
|
var Backbone = require("backbone"),
|
|
Sound;
|
|
|
|
Sound = Backbone.Model.extend({
|
|
audio: null,
|
|
defaults: {
|
|
title: "",
|
|
character: "",
|
|
episode: "",
|
|
file: "",
|
|
playing: false
|
|
},
|
|
play: function() {
|
|
if( !this.audio ) {
|
|
this.audio = new Audio("sounds/"+this.get("file"));
|
|
}
|
|
|
|
this.audio.play();
|
|
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 ) {
|
|
this.audio.pause();
|
|
this.audio.load();
|
|
}
|
|
|
|
this.set("playing", false);
|
|
},
|
|
getSoundDetail: function() {
|
|
return this.get("character")+", "+this.get("episode");
|
|
},
|
|
getSlug: function() {
|
|
return this.get("file").slice(0, this.get("file").lastIndexOf('.'));
|
|
},
|
|
toJSON: function(){
|
|
var json = Backbone.Model.prototype.toJSON.apply(this, arguments);
|
|
|
|
json.slug = this.getSlug();
|
|
|
|
return json;
|
|
}
|
|
});
|
|
|
|
return Sound;
|
|
});
|