标签:
AVAudioplayer 有两个初始化方法:
NSData *audioData = [NSData dataWithContentsOfURL:someURL];
NSString *docDirPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES) objectAtIndex:0];
NSString *filePath = [NSString stringWithFormat:@"%@/%@.mp3", docDirPath , fileName];
[audioData writeToFile:filePath atomically:YES];
NSError *error;
NSURL *fileURL = [NSURL fileURLWithPath:filePath];
player = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:&error];
if (player == nil)
{ NSLog(@"AudioPlayer did not load properly: %@", [error description]); }
else
{ [player play]; }
标签:
原文地址:http://www.cnblogs.com/tangyuanby2/p/5676809.html