MP3 오디오 파일을 재생하려고하는데 파일이 웹 서버의 사용자에 의해 업로드되고 해당 파일의 URL을 얻은 다음 해당 파일을 재생해야합니다. 그러나 나는 그것에 성공하지 못하고있다. 여기 내 코드는iphone dev mp3 파일이 av 오디오 플레이어를 사용하여 재생되지 않음
NSURL * url = [NSURL URLWithString : url1]; NSData * theData = [NSData dataWithContentsOfURL : url]; newPlayer = [[AVAudioPlayer alloc] initWithData : theData 오류 : 없음]; [newPlayer play];
URL은
http://mqm.designers99.com/Notification/mp3_files/1331551313_1919.mp3
Plz은 같다.
NSURL *url = [NSURL URLWithString:url1];
NSData *theData = [NSData dataWithContentsOfURL:url];
NSError *error = nil;
newPlayer = [[AVAudioPlayer alloc] initWithData:theData error:&error];
if (error == nil) {
NSLog(@"AVAudioPlayer start playing");
[newPlayer play];
} else {
NSLog(@"%@", error);
}
모든 "행운"내가 여기 고맙습니다 붙어 및
P. 이 경우'-initWithData : error :'인스턴스 메소드가 필요하지 않습니다. 단지 -initWithContentsOfURL : error :' – basvk
을 배포하고 있습니까? – basvk
운이 없다 오히려 그것은이 오류를 표시하고 있습니다. 작업을 완료 할 수 없습니다 (OSStatus -43) –