Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To play audio on the Mac, you can either use <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSSound_Class/Reference/Reference.html" rel="noreferrer"><code>NSSound</code></a> for basic activities, or the more robust <a href="http://developer.apple.com/library/mac/#documentation/MusicAudio/Conceptual/CoreAudioOverview/Introduction/Introduction.html" rel="noreferrer"><code>CoreAudio</code></a> framework for more complicated tasks.</p> <hr> <p>If you were to use <code>NSSound</code> to achieve this goal, your code would look something like this:</p> <pre><code>NSString *resourcePath = [[NSBundle mainBundle] pathForResource:@"replace-with-file-name" ofType:@"aif"]; NSSound *sound = [[NSSound alloc] initWithContentsOfFile:resourcePath byReference:YES]; // Do something with sound, like [sound play] and release. </code></pre> <p>OR</p> <pre><code>NSSound *sound = [NSSound soundNamed:@"replace-with-file-name-without-the-extension"]; // Do something with sound, like [sound play], but don't release (it's autoreleased). </code></pre> <p>If you were to use the second snippet, you would have to ensure that the sound file's extension is <code>aiff</code> and not just <code>aif</code>, since <code>+soundNamed:</code> looks for very specific file extensions; I don't think <code>aif</code> is on that list.</p> <p>Using <code>CoreAudio</code> is more complicated, so if you just want to play it and mess around with very simple settings, just use <code>NSSound</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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