mirror of
https://github.com/2ec0b4/kaamelott-soundboard.git
synced 2025-12-08 23:53:24 +00:00
Joue / stoppe le son
This commit is contained in:
@@ -359,6 +359,11 @@ a.btn-play:before {
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
left: 10px;
|
left: 10px;
|
||||||
}
|
}
|
||||||
|
a.btn-play.playing:before {
|
||||||
|
content: "▩";
|
||||||
|
font-size: 1.2em;
|
||||||
|
top: 7px;
|
||||||
|
}
|
||||||
.btn:active,
|
.btn:active,
|
||||||
a.btn:active {
|
a.btn:active {
|
||||||
top:3px;
|
top:3px;
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.audio.play();
|
this.audio.play();
|
||||||
|
this.audio.onended = this.stop.bind(this);
|
||||||
|
this.audio.onpause = this.stop.bind(this);
|
||||||
|
|
||||||
this.set('playing', true);
|
this.set('playing', true);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -16,14 +16,30 @@ define(
|
|||||||
soundItem: 'a'
|
soundItem: 'a'
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
'click @ui.soundItem': 'playSound'
|
'click @ui.soundItem': 'toggleSound'
|
||||||
},
|
},
|
||||||
playSound: function(e) {
|
initialize: function() {
|
||||||
|
this.listenTo(this.model, "change:playing", this.playingAttributeChanged);
|
||||||
|
},
|
||||||
|
toggleSound: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
this.trigger('sound:play');
|
if( this.model.get('playing') ) {
|
||||||
|
this.trigger('sound:stop');
|
||||||
|
|
||||||
this.model.play();
|
this.model.stop();
|
||||||
|
} else {
|
||||||
|
this.trigger('sound:play');
|
||||||
|
|
||||||
|
this.model.play();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
playingAttributeChanged: function() {
|
||||||
|
if( this.model.get('playing') ) {
|
||||||
|
$(this.ui.soundItem).addClass('playing');
|
||||||
|
} else {
|
||||||
|
$(this.ui.soundItem).removeClass('playing');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user