Ios7 在iOS 7中选择音频后应用程序崩溃,在iOS 6中可以
在运行iOS7的iPhone或iPad设备上从用户库中选择歌曲时,我的应用程序崩溃 它停的那条线是Ios7 在iOS 7中选择音频后应用程序崩溃,在iOS 6中可以,ios7,Ios7,在运行iOS7的iPhone或iPad设备上从用户库中选择歌曲时,我的应用程序崩溃 它停的那条线是 FourCharCode formatID = audioDesc->mFormatID; 使用EXC\u坏的\u访问代码 尝试检查控制台以获取更多信息,这是它提到的最后一步 appMake[8392:60b]选择音乐资产=(空) 导出会话部分的以下代码 - (void)exportAssetAsSourceFormat:(MPMediaItem *)item { NSAutor
FourCharCode formatID = audioDesc->mFormatID;
使用EXC\u坏的\u访问代码
尝试检查控制台以获取更多信息,这是它提到的最后一步
appMake[8392:60b]选择音乐资产=(空)
导出会话部分的以下代码
- (void)exportAssetAsSourceFormat:(MPMediaItem *)item {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
NSURL *assetURL = [item valueForProperty:MPMediaItemPropertyAssetURL];
AVURLAsset *songAsset = [AVURLAsset URLAssetWithURL:assetURL options:nil];
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc]
initWithAsset:songAsset
presetName:AVAssetExportPresetPassthrough];
NSArray *tracks = [songAsset tracksWithMediaType:AVMediaTypeAudio];
AVAssetTrack *track = [tracks objectAtIndex:0];
id desc = [track.formatDescriptions objectAtIndex:0];
const AudioStreamBasicDescription *audioDesc = CMAudioFormatDescriptionGetStreamBasicDescription((CMAudioFormatDescriptionRef)desc);
FourCharCode formatID = audioDesc->mFormatID;
NSString *fileType = nil;
NSString *ex = nil;
switch (formatID) {
case kAudioFormatLinearPCM:
{
UInt32 flags = audioDesc->mFormatFlags;
if (flags & kAudioFormatFlagIsBigEndian) {
fileType = @"public.aiff-audio";
ex = @"aif";
} else {
fileType = @"com.microsoft.waveform-audio";
ex = @"wav";
}
}
break;
case kAudioFormatMPEGLayer3:
fileType = @"com.apple.quicktime-movie";
ex = @"mp3";
break;
case kAudioFormatMPEG4AAC:
fileType = @"com.apple.m4a-audio";
ex = @"m4a";
break;
case kAudioFormatAppleLossless:
fileType = @"com.apple.m4a-audio";
ex = @"m4a";
break;
default:
break;
}
exportSession.outputFileType = fileType;
NSString *exportPath = [[NSTemporaryDirectory() stringByAppendingPathComponent:[EXPORT_NAME stringByAppendingPathExtension:ex]] retain];
if ([[NSFileManager defaultManager] fileExistsAtPath:exportPath]) {
[[NSFileManager defaultManager] removeItemAtPath:exportPath error:nil];
}
exportSession.outputURL = [NSURL fileURLWithPath:exportPath];
[exportSession exportAsynchronouslyWithCompletionHandler:^{
if (exportSession.status == AVAssetExportSessionStatusCompleted) {
NSLog(@"export session completed");
//return YES;
[self performSelectorOnMainThread:@selector(gotoMainView:)
withObject:[EXPORT_NAME stringByAppendingPathExtension:ex]
waitUntilDone:NO];
} else {
NSLog(@"export session error");
//return NO;
}
[exportSession release];
}];
[pool release];
}
媒体选择器代码
- (void) mediaPicker: (MPMediaPickerController *) mediaPicker didPickMediaItems: (MPMediaItemCollection *) mediaItemCollection
{
// Dismiss the media item picker.
[self dismissModalViewControllerAnimated: YES];
if ([mediaItemCollection count] < 1) {
return;
}
[selectedItem release];
selectedItem = [[[mediaItemCollection items] objectAtIndex:0] retain];
NSURL* filePath = [selectedItem valueForProperty: MPMediaItemPropertyAssetURL];
NSLog(@"Select music AssetUrl = %@", filePath);
[viewLoading setHidden:NO];
[self UnloadSound];
[NSThread detachNewThreadSelector:@selector(exportAssetAsSourceFormat:) toTarget:self withObject:selectedItem];
}
-(void)mediaPicker:(MPMediaPickerController*)mediaPicker didPickMediaItems:(MPMediaItemCollection*)mediaItemCollection
{
//关闭媒体项选取器。
[自我解散Modalviewcontrolleranimated:是];
如果([mediaItemCollection计数]<1){
回来
}
[选择编辑项目发布];
selectedItem=[[mediaItemCollection items]对象索引:0]保留];
NSURL*文件路径=[selectedItem valueForProperty:MPMediaItemPropertyAsetUrl];
NSLog(@“选择音乐资产=%@”,文件路径);
[查看加载设置隐藏:否];
[自动解锁];
[NSThread detachNewThreadSelector:@selector(ExportAssetSourceFormat:)toTarget:self with Object:selectedItem];
}
很可能,音乐是云计算的吗(iTunes匹配)?我对云上的音乐有问题。嘿,是的,它实际上是在云上的-不知道如何解决?我过滤了非云音乐。你可以在那里得到更多的信息:有什么我可以添加到上面的代码来修复,我读了你的链接,但不得不承认它让我更加困惑!如能为上述现有代码提供任何指导,将不胜感激。