Dev*_*ang 5 iphone objective-c avaudioplayer ios4
我将在我的应用程序中使用.wav音频文件.
不AVAudioPlayer支持.wav的文件格式?
以及支持哪些其他格式AVAudioPlayer?
是的,AVAudioPlayer让您可以播放.wav文件。
这非常简单:
// in the corresponding .h file:
// @property (nonatomic, retain) AVAudioPlayer *player;
// in the .m file:
@synthesize player; // the player object
NSString *soundFilePath =
[[NSBundle mainBundle] pathForResource: @"sound"
ofType: @"wav"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: soundFilePath];
AVAudioPlayer *newPlayer =
[[AVAudioPlayer alloc] initWithContentsOfURL: fileURL
error: nil];
[fileURL release];
self.player = newPlayer;
[newPlayer release];
[player prepareToPlay];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5676 次 |
| 最近记录: |