开发者

not able to play audio from internet using AVAudioPlayer

i tried to play an audio file from internet using AVAudioplayer but there is no response from UIView but if i m to play an mp3 file from bundle it works ..cud u guys help me out below is the code...

-(IBAction)playPause:(id)sender

{

NSURL *url=[NSURL URLWithString:@"http://www.1040communications.net/sheeba/stepheni/iphone/images/today.mp3"];


NSError *error;
player =开发者_Go百科 [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
if (!player) NSLog(@"Error: %@", error);
[player prepareToPlay];

[player play];

}


The URL has to be a file URL, see Apple’s Technical QA1634. You can download the file to the device and then play it locally.


your url is not returning any data.That's why it is not playing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜