Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you are playing a short system sound (shorter than 30 seconds) using the System Sound Services mechanism (code would look something like the following)</p> <pre><code>#include &lt;AudioToolbox/AudioToolbox.h&gt; SystemSoundID aSoundID; /* Setup */ SystemSoundID aSoundID; OSStatus error = AudioServicesCreateSystemSoundID((CFURLRef)aFileURL, &amp;aSoundID); if (error == kAudioServicesNoError) { // success _soundID = aSoundID; } /* Play */ AudioServicesPlaySystemSound(aSoundID); /* Dispose */ AudioServicesDisposeSystemSoundID(aSoundID); </code></pre> <p>You can use <strong>AudioServicesSetProperty</strong> to set two properties using this function.</p> <p>They are: kAudioServicesPropertyIsUISound = 'isui', kAudioServicesPropertyCompletePlaybackIfAppDies = 'ifdi'</p> <p><strong>kAudioServicesPropertyIsUISound</strong>, if it is set to 1 means that, for the audio file specified by a system sound passed in the inSpecifier parameter, the System Sound server respects the user setting in the Sound Effects preference and is silent when the user turns off sound effects.</p> <p>This property is set to 1 by default. Set it to 0 for the system sound to always play when passed to AudioServicesPlaySystemSound, regardless of the user's setting in sound preferences.</p> <p><strong>kAudioServicesPropertyCompletePlaybackIfAppDies</strong>, if it is set to 1 means that the audio file specified by a system sound passed in the inSpecifier parameter should finish playing even if the client application terminates. This could happen, for example, if the user quits or the application terminates unexpectedly while the sound is playing. The default is 0. That is, you must explicitly set this property’s value to 1 if you want the sound to complete playing even if the application terminates.</p> <p><strong>EDIT:</strong> Upon re-reading your question, it seems it may be more "How do I set a property" than "what does this thing do" In this case, the following will be more useful:</p> <p>Assuming you set up the sound as I specified above, you could set this particular SystemSoundID object to ignore the "silent" setting on the side of the phone by doing the following:</p> <pre><code>UInt32 flag = 0; err = AudioServicesSetProperty(kAudioServicesPropertyIsUISound, sizeof(UInt32), &amp;aSoundID, sizeof(UInt32), &amp;flag); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload