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

Function stopTrack

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

* Stops the specified track and clears current play data. Removes all * currently playing sounds. Calling stop on a paused track clears * all data. * * @param opts {string} name of track to stop. * * @param opts.track {string} name of track to stop * @param opts.

({ state, dispatch }, opts)

Source from the content-addressed store, hash-verified

204 * @throws {Error} when invalid track specified
205 */
206 stopTrack ({ state, dispatch }, opts) {
207 let unload
208 let track
209
210 if (typeof opts === 'object') {
211 unload = opts.unload
212 track = opts.track
213 } else {
214 track = opts
215 unload = false
216 }
217
218 const trackData = state.tracks[track]
219 if (!trackData) {
220 throw new Error('Invalid track specified')
221 }
222
223 const stops = Array.from(trackData.keys())
224 .map(id => dispatch('stopSound', { id, unload }))
225
226 return Promise.all(stops)
227 },
228
229 /**
230 * Plays a new sound on a track.

Callers

nothing calls this directly

Calls 1

dispatchFunction · 0.85

Tested by

no test coverage detected