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:
@@ -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;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user