MCPcopy Create free account
hub / github.com/codecombat/codecombat / fadeSound

Function fadeSound

app/core/store/modules/audio.js:437–452  ·  view source on GitHub ↗

* Fades a sound between two volumes. * * @param opts {object} * @param opts.id {string} sound to fade * @param opts.from {number|undefined} start volume between 0 and 1. If undefined starts at current volume. * @param opts.to {number} finish volume between 0 and 1 * @p

({ getters }, { id, from, to, duration })

Source from the content-addressed store, hash-verified

435 * @throws {Error} when invalid ID specified
436 */
437 fadeSound ({ getters }, { id, from, to, duration }) {
438 const sound = getters.getSoundById(id)
439 if (!sound) {
440 throw new Error('Sound not found')
441 }
442
443 if (typeof from === 'undefined') {
444 from = sound.volume()
445 }
446
447 return new Promise((resolve) => {
448 sound
449 .once('fade', () => resolve(id))
450 .fade(from, to, duration)
451 })
452 },
453
454 /**
455 * Sets volume of all tracks

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected