objective c - cocoa playing an mp3 -


Is there an easy way to load, run, and control MP3 files with cocoa? Tried to googling it, but, as all the things in the apple, I am getting the wrong results and do not know where to begin, as I think, there is NSSound and there are many limitations in it and then the core It is audio, but it is very difficult. So can someone tell me in the right direction with this? Thank you.

Resuscitation in progress:

Why raise this question? Because googling "coco mp3 game" takes me here, and there is no horrible 2012 answer. So, here is the answer to the horrific 2012;)

Use AVFoundation! According to Apple, it has been integrated with Mac OS X Sher (I think), so how to play without suffering MP3:

1- Link to the AVI Foundation Framework.

2- Import it wherever you want to play your awesome MP3

  #import & lt; AVFoundation / AVFoundation.h & gt;  

3- Add an Audio Players instance variable to play sound (at least) I like doing this

  @interface WCMainWindow: .. ...... AVAudioPlayer * Audio Player; 4- In itself, make sure you want to initialize your audio player:  
  NSString * path = [[NSBundle mainBundle] pathForResource: @ "MyFile" ofType: @ "MP3"]; Ns url * file = [nsur file url with path: path]; // Thanks @GearbusBabberBlack audioplayer = [[Aviideo Player Alok] initWithContentsOfURL: File Error: Zero]; [For audioplayer preparation];  

5- Play your awesome MP3!

  if ([Audio is player's play]] {[Audioplayer pause]; } And {[audio player play]; }  

Finally, goes credit.


Comments