[英]Playing an mp3 on IPhone OS 2.2.1
当我在OS版本3.0的第二代iPod touch上运行此示例代码时,它工作正常。 但是,当我在OS版本2.2.1的第一代iPod touch上运行它时,却没有。 我正在为背景音乐播放mp3,但仍可以在3.0设备上播放SFX mp3。 我想知道对于旧版设备/操作系统版本是否必须采取其他措施,或者旧版设备/操作系统版本无法同时播放多个mp3文件。 我读过的帖子说,iPhone无法同时播放多个mp3文件,但它可以在3.0设备上运行。 有想法吗?
//h file
@interface AudioTest {
AVAudioPlayer *player;
}
@property (nonatomic, retain) AVAudioPlayer *player;
- (void)playSound;
//m file
@synthesize player;
- (void)playSound {
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"sound" ofType:@"mp3"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:soundFilePath];
AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
[fileURL release];
self.player = newPlayer;
[newPlayer release];
[self.player prepareToPlay];
[self.player setDelegate:self];
[self.player play];
}
在3.0 OS发行版之前,一次播放多个MP3文件对我来说从来都不可靠。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.