Skip to content

Commit

Permalink
Add a global stop method
Browse files Browse the repository at this point in the history
Fixes #1308
  • Loading branch information
goldfire committed Apr 3, 2020
1 parent 09dc0fb commit e2b72fe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@ Mute or unmute all sounds.
Get/set the global volume for all sounds, relative to their own volume.
* **volume**: `Number` `optional` Volume from `0.0` to `1.0`.

#### stop()
Stop all sounds and reset their seek position to the beginning.

#### codecs(ext)
Check supported audio codecs. Returns `true` if the codec is supported in the current browser.
* **ext**: `String` File extension. One of: "mp3", "mpeg", "opus", "ogg", "oga", "wav", "aac", "caf", m4a", "mp4", "weba", "webm", "dolby", "flac".
Expand Down
14 changes: 14 additions & 0 deletions src/howler.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,20 @@
return self;
},

/**
* Handle stopping all sounds globally.
*/
stop: function() {
var self = this || Howler;

// Loop through all Howls and stop them.
for (var i=0; i<self._howls.length; i++) {
self._howls[i].stop();
}

return self;
},

/**
* Unload and destroy all currently loaded Howl objects.
* @return {Howler}
Expand Down

0 comments on commit e2b72fe

Please sign in to comment.