* 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 })
| 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 |
nothing calls this directly
no outgoing calls
no test coverage detected