我想用AVAudioPlayer播放我的服務器上的mp3文件我試過這段代碼,但它不起作用。我想用AVAudioPlayer在我的服務器上播放mp3文件
-(IBAction)playSound {
NSString *path = [[NSBundle mainBundle] pathForResource:@"http://www.domain.com/audio/test.mp3"];
AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
theAudio.delegate = self;
[theAudio play];
}
歡迎計算器!我冒昧地重新格式化您的代碼。你可能想告訴我們更多關於你的問題,特別是爲什麼它不起作用。你會得到什麼錯誤信息?什麼規格(配置,編譯或執行)錯誤發生?你爲什麼認爲你的榜樣應該工作? – phihag 2010-07-17 20:49:49