我試圖播放遙控器.mp3 file
如何在我的ios應用程序中播放遠程.mp3文件?
但它給出了以下錯誤。
The operation couldn’t be completed. (OSStatus error -43.)
這裏是我的代碼:
- (void)viewDidLoad
{
[super viewDidLoad];
isPlaying = NO;
/*
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"Dar-e-Nabi-Per" ofType:@"mp3"]];
*/
NSURL *url = [NSURL
URLWithString:@"http://megdadhashem.wapego.ru/files/56727/tubidy_mp3_e2afc5.mp3"];
NSError *error;
audioPlayer = [[AVAudioPlayer alloc]
initWithContentsOfURL:url
error:&error];
if (error)
{
NSLog(@"Error in audioPlayer: %@",
[error localizedDescription]);
}
else
{
audioPlayer.delegate = self;
[audioPlayer prepareToPlay];
}
}
任何人都可以請指導我在哪裏,我在做錯誤
錯誤#1:你的代碼不可讀。錯誤#2:你沒有谷歌的錯誤號碼。 – 2013-07-10 11:16:08
@ H2CO3我谷歌它,但不明白,錯誤號碼, 現在你能給我solowtion這是錯誤的我的代碼?我的代碼是可讀的。 –
請請,請不要做這樣的錯誤檢查。它從根本上被打破,並且違背了Cocoa文檔。 **總是**在測試錯誤指針本身之前檢查返回值。 http://blog.bignerdranch.com/360-an-nserror-error/ –