1
0
mirror of https://github.com/2ec0b4/kaamelott-soundboard.git synced 2025-12-08 23:53:24 +00:00

Révise l'utilisation de require

This commit is contained in:
Antoine
2016-05-29 20:47:35 +02:00
parent 77f1820fa5
commit 0ce3b318e4
14 changed files with 309 additions and 345 deletions

View File

@@ -1,43 +1,41 @@
define(
'models/sound',
[
'backbone'
],
function (Backbone) {
"use strict";
define('models/sound', function(require) {
"use strict";
var 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'));
}
var Backbone = require('backbone'),
Sound;
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');
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'));
}
});
return Sound;
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');
}
});
return Sound;
});