mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Hooked up real-time playback music.
This commit is contained in:
parent
9ea24f4c74
commit
9fc7fca528
1 changed files with 13 additions and 0 deletions
|
@ -12,6 +12,8 @@ module.exports = class MusicPlayer extends CocoClass
|
|||
subscriptions:
|
||||
'music-player:play-music': 'onPlayMusic'
|
||||
'audio-player:loaded': 'onAudioLoaded'
|
||||
'playback:real-time-playback-started': 'onRealTimePlaybackStarted'
|
||||
'playback:real-time-playback-ended': 'onRealTimePlaybackEnded'
|
||||
|
||||
constructor: ->
|
||||
super arguments...
|
||||
|
@ -62,6 +64,17 @@ module.exports = class MusicPlayer extends CocoClass
|
|||
createjs.Tween.removeTweens(@currentMusic)
|
||||
@currentMusic.volume = if me.get('music') then MUSIC_VOLUME else 0.0
|
||||
|
||||
onRealTimePlaybackStarted: (e) ->
|
||||
@previousMusic = @currentMusic
|
||||
trackNumber = _.random 0, 2
|
||||
Backbone.Mediator.publish 'music-player:play-music', file: "/music/music_real_time_#{trackNumber}", play: true
|
||||
|
||||
onRealTimePlaybackEnded: (e) ->
|
||||
@fadeOutCurrentMusic()
|
||||
if @previousMusic
|
||||
@currentMusic = @previousMusic
|
||||
@restartCurrentMusic()
|
||||
|
||||
destroy: ->
|
||||
me.off 'change:music', @onMusicSettingChanged, @
|
||||
super()
|
||||
|
|
Loading…
Reference in a new issue