NSString *urlPath = [[NSBundle mainBundle] pathForResource:@"snd" ofType:@"mp3"];
NSURL *url = [NSURL fileURLWithPath:urlPath];
NSError *err;
AVAudioPlayer* audioPlayerMusic = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&err];
[audioPlayerMusic play];
作品就好了。
雖然這一個:
NSString *urlPath = [[NSBundle mainBundle] pathForResource:@"snd" ofType:@"mp3"];
NSURL *url = [NSURL fileURLWithPath:urlPath];
AVPlayer* audioPlayerMusic = [AVPlayer playerWithURL:url];
[audioPlayerMusic play];
播放什麼!
怎麼回事?
那麼僅僅聲明一個變量就可以工作? – 2012-08-25 21:34:45
你是什麼意思?請注意,我剛更新了代碼。我做了一個複製/粘貼錯誤。 –
看到我的答案。 (首先在Google上搜索類似SO的問題!) – 2012-08-25 21:51:50