play URL audio using AVAudioPlayer
AVAudioPlayer is used to play audio file in iPhone. However, according to the document, it only support playing local audio file:
http://developer.apple.com/iphone/library/qa/qa2009/qa1634.html
To solve this problem, we can create a NSData using the NSURL and play the data using AVAudioPlayer
NSData *soundData = [NSData dataWithContentsOfURL:url];
AVAudioPlayer *avPlayer = [[AVAudioPlayer alloc] initWithData:soundData error: nil];
[avPlayer play];
由 water 在 週四, 2010-01-14 15:19 發表
Tags:

最新回應
18 周 4 天前
23 周 6 天前
27 周 2 天前
28 周 1 天前
37 周 10 小時前
37 周 10 小時前
37 周 1 天前
37 周 2 天前
39 周 20 小時前
39 周 1 天前