Skip to content

Commit 8135725

Browse files
committed
Add docs to clarify what group playback refers to
Fixes goldfire#982
1 parent 8c1e020 commit 8135725

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Tested in the following browsers/versions:
5252
* [Options](#options-1)
5353
* [Methods](#methods-1)
5454
* [Global Methods](#global-methods-1)
55+
* [Group Playback](#group-playback)
5556
* [Mobile Playback](#mobilechrome-playback)
5657
* [Dolby Audio Playback](#dolby-audio-playback)
5758
* [Facebook Instant Games](#facebook-instant-games)
@@ -465,6 +466,32 @@ Get/set the direction the listener is pointing in the 3D cartesian space. A fron
465466
* **zUp**: `Number` The z-orientation of the top of the listener.
466467

467468

469+
### Group Playback
470+
Each `new Howl()` instance is also a group. You can play multiple sounds from the `Howl` and control them individually or as a group. For example, the following plays two sounds from a sprite, changes their volume together and then pauses both of them at the same time.
471+
472+
```javascript
473+
var sound = new Howl({
474+
src: ['sound.webm', 'sound.mp3'],
475+
sprite: {
476+
track01: [0, 20000],
477+
track02: [21000, 41000]
478+
}
479+
});
480+
481+
// Play each of the track.s
482+
sound.play('track01');
483+
sound.play('track02');
484+
485+
// Change the volume of both tracks.
486+
sound.volume(0.5);
487+
488+
// After a second, pause both sounds in the group.
489+
setTimeout(function() {
490+
sound.pause();
491+
}, 1000);
492+
```
493+
494+
468495
### Mobile/Chrome Playback
469496
By default, audio on mobile browsers and Chrome/Safari is locked until a sound is played within a user interaction, and then it plays normally the rest of the page session ([Apple documentation](https://developer.apple.com/library/safari/documentation/audiovideo/conceptual/using_html5_audio_video/PlayingandSynthesizingSounds/PlayingandSynthesizingSounds.html)). The default behavior of howler.js is to attempt to silently unlock audio playback by playing an empty buffer on the first `touchend` event. This behavior can be disabled by calling:
470497

0 commit comments

Comments
 (0)