* Stops a playing sound. Unloads and cleans up data after * stopping. Stopping a paused sound unloads and cleans up * all data. * * @param opts {string} ID of sound to stop * * @param opts.id {string} ID of sound to stop * @param opts.unload {boolean} unload / cl
({ getters, commit, state }, opts)
| 349 | * @throws {Error} when invalid ID specified |
| 350 | */ |
| 351 | stopSound ({ getters, commit, state }, opts) { |
| 352 | let unload |
| 353 | let id |
| 354 | |
| 355 | if (typeof opts === 'object') { |
| 356 | unload = opts.unload |
| 357 | id = opts.id |
| 358 | } else { |
| 359 | id = opts |
| 360 | unload = false |
| 361 | } |
| 362 | |
| 363 | const sound = getters.getSoundById(id) |
| 364 | if (!sound) { |
| 365 | return |
| 366 | } |
| 367 | |
| 368 | sound.stop() |
| 369 | |
| 370 | if (unload) { |
| 371 | sound.unload() |
| 372 | commit('removeSound', id) |
| 373 | if (state.unique.soundIdKeys.has(id)) { |
| 374 | commit('removeUniqueEntry', { id, unique: state.unique.soundIdKeys.get(id) }) |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | return id |
| 379 | }, |
| 380 | |
| 381 | /** |
| 382 | * Fades all tracks between two volumes. |