iPhone上的NSSound [英] NSSound on the iphone
本文介绍了iPhone上的NSSound的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在寻找如何在iphone上播放声音的方法,我认为这类似于:
I've been looking for a while how to play sound on the iphone, and I think it's something along the lines of:
[[NSSound soundNamed:@"cat.mp3"] play];
但是NSSound在AppKit上...有什么建议吗?我知道有一个非常简单的答案,但是今天我的搜索没有呈现任何结果...
But the NSSound is on the AppKit ... any suggestions ? I know there is a really simple answer to this, but today my searches are not rendering any result ...
推荐答案
新AVFoundation类是在iPhone上播放声音的最简单方法,尽管它仅适用于固件2.2:
the new AVFoundation class is the easiest way to play sound on the iPhone, though it is for firmware 2.2 only:
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
[audioPlayer play];
您只需要在使用它的类中使用此导入:
you just need this import in the class that uses it:
#import <AVFoundation/AVAudioPlayer.h>
这篇关于iPhone上的NSSound的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文