What is the Mac equivalent of AVAudioPlayer?
I am porti开发者_运维问答ng an iPhone app to Mac. On iPhone I use AVAudioPlayer
for playing sounds, but it doesn't exist on Mac. What would be the Mac equivalent for playing audio (hopefully as simple as AVAudioPlayer so I can port my app easily)?
Additionally, are there any open source libraries / samples / wrappers available for playing music and sound files on Mac?
As of OS X 10.7, AVAudioPlayer is available on the Mac and Apple recommends using this wherever possible.
Depending on what capabilities you need, Core Audio might be unnecessarily complex. The obvious simple way is NSSound. It's also possible to use a hidden QTMovieView to play sound.
I've written a framework for audio playback, called SFBAudioEngine: http://github.com/sbooth/SFBAudioEngine
It might be a bit more than you're looking for, but it is more capable than NSSound and supports formats (FLAC, Musepack, Ogg Vorbis) that Core Audio doesn't handle natively.
Take a look at Core Audio:
Core Audio is designed to handle all audio needs in Mac OS X. You can use Core Audio to generate, record, mix, edit, process, and play audio.
精彩评论