Jazz-Soft.net

We make it sound!

Home » Documentation » JZZ.js » JZZ.util

JZZ.util

Odds and ends...

iOS

iosSound()

JZZ.util.iosSound() - turn on Web Audio on iOS device.

On iOS devices, Web Audio is muted until the first sound is played in response to the user-triggered event.

This function plays a silent "sound". Place it into the handler of the user-triggered event (like a button click).

Placing it in the handler of the system-triggered event (like "page loaded" or a timer tick) will not work.

This call is only required if you target your application for iPhone or other iOS devices. It does not hurt on other platforms though...

Example

<script src="scripts/JZZ.js"></script>
<script src="scripts/JZZ.synth.OSC.js"></script>
...
<script><!--
function play(){
  JZZ.util.iosSound();
  JZZ.synth.OSC()
    .note(0, "C5", 127, 500).wait(500)
    .note(0, "E5", 127, 500).wait(500)
    .note(0, "G5", 127, 500);
}
--></script>
...
<button onclick="play();">Press to play!</button>

See also