Misc changes, wishing I could get sounds to work at lower volumes.

This commit is contained in:
Nick Winter 2014-09-10 19:55:00 -07:00
parent 0b1f4ebada
commit f53f6bf0a3
3 changed files with 15 additions and 7 deletions

View file

@ -81,7 +81,7 @@ class AudioPlayer extends CocoClass
playInterfaceSound: (name, volume=1) ->
filename = "/file/interface/#{name}#{@ext}"
if filename of cache and createjs.Sound.loadComplete filename
if @hasLoadedSound filename
@playSound name, volume
else
@preloadInterfaceSounds [name] unless filename of cache
@ -89,15 +89,23 @@ class AudioPlayer extends CocoClass
playSound: (name, volume=1, delay=0, pos=null) ->
return console.error 'Trying to play empty sound?' unless name
audioOptions = {volume: (me.get('volume') ? 1) * volume, delay: delay}
audioOptions = {volume: volume, delay: delay}
filename = if _.string.startsWith(name, '/file/') then name else '/file/' + name
unless (filename of cache) and createjs.Sound.loadComplete filename
unless @hasLoadedSound filename
@soundsToPlayWhenLoaded[name] = audioOptions.volume
audioOptions = @applyPanning audioOptions, pos if @camera and pos
instance = createjs.Sound.play name, audioOptions
# For some reason, individual sound volume control doesn't work any more.
# I tried updating to SoundJS NEXT on 2014-09-10, but couldn't get any sounds to play with that one.
#console.log 'got instance with volume', instance.volume, instance._volume, instance.gainNode?.gain.value
instance
# # TODO: load Interface sounds somehow, somewhere, somewhen
hasLoadedSound: (filename, name) ->
return false unless filename of cache
return false unless createjs.Sound.loadComplete filename
true
# TODO: load Interface sounds somehow, somewhere, somewhen
preloadSoundReference: (sound) ->
name = @nameForSoundReference sound

View file

@ -41,7 +41,7 @@ module.exports =
'tome:palette-updated': c.object {title: 'Palette Updated', description: 'Published when the spell palette has just been updated.'},
thangID: {type: 'string'}
entryGroups: {type: 'object', additionalProperties: {type: 'string'}}
entryGroups: {type: 'string'}
'tome:palette-hovered': c.object {title: 'Palette Hovered', description: 'Published when you hover over a Thang in the spell palette', required: ['thang', 'prop', 'entry']},
thang: {type: 'object'}

View file

@ -339,7 +339,7 @@ module.exports = class LevelPlaybackView extends CocoView
@slideCount = 0
@wasPlaying = @playing
Backbone.Mediator.publish 'level:set-playing', {playing: false}
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'playback-scrub-start', volume: 1
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'playback-scrub-start', volume: 0.5
stop: (event, ui) =>
return if @shouldIgnore()
@ -351,7 +351,7 @@ module.exports = class LevelPlaybackView extends CocoView
Backbone.Mediator.publish 'level:set-playing', {playing: false}
@$el.find('.scrubber-handle').effect('bounce', {times: 2})
else
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'playback-scrub-end', volume: 1
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'playback-scrub-end', volume: 0.5
)
getScrubRatio: ->