相关疑难解决方法(0)

从iphone 5.0中的Iphone导入歌曲时,应用程序崩溃了

您好我在framworks下面使用,

#import <MediaPlayer/MediaPlayer.h>
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>
Run Code Online (Sandbox Code Playgroud)

在其中一个按钮事件中,我已经实现了以下代码来打开库.

        MPMediaPickerController *mediaPicker = [[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeMusic];
    mediaPicker.delegate = self;
    mediaPicker.allowsPickingMultipleItems = YES; // this is the default   
    [self presentModalViewController:mediaPicker animated:YES];
    [mediaPicker release];
Run Code Online (Sandbox Code Playgroud)

并且在MPMediaPickerController的委托方法中实现了如下代码

#pragma mark MPMediaPickerController delegate methods

- (void)mediaPicker: (MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection {

    // We need to dismiss the picker
    [self dismissModalViewControllerAnimated:YES];

    // Assign the selected item(s) to the music player and start playback.

    counterIpod = [mediaItemCollection.items count];
    totalcollection = counterIpod;
    if (totalcollection > 10) {
        NSString *str = [NSString …
Run Code Online (Sandbox Code Playgroud)

iphone ipod itunes-sdk media-player ios

8
推荐指数
1
解决办法
5594
查看次数

自iOS 5.1以来在ipod库中导出mp3文件时获取错误代码-11843

我使用AVAssetExportSession导出ipod库中的mp3/m4a文件.此方法适用于iOS 5.0及更早版本.但是在将iOS升级到5.1之后,此方法不再适用于mp3,但仍适用于m4a.

这是源代码.

AVURLAsset *songAsset = [AVURLAsset URLAssetWithURL: [mediaItem assetUrl] options:nil];

NSLog (@"compatible presets for songAsset: %@",[AVAssetExportSession exportPresetsCompatibleWithAsset:songAsset]);

AVAssetExportSession *exporter = [[AVAssetExportSession alloc]
                                  initWithAsset: songAsset
                                  presetName: AVAssetExportPresetPassthrough];

NSLog (@"created exporter. supportedFileTypes: %@", exporter.supportedFileTypes);
NSLog(@"output file type=%@",[mediaItem fileType]);
NSLog(@"export file path=%@",exportPath);
exporter.outputFileType =[mediaItem fileType];

NSError *error1;
error1=0;

if([[NSFileManager defaultManager] fileExistsAtPath:exportPath]) 
{

    [[NSFileManager defaultManager] removeItemAtPath:exportPath error:&error1];
    if(error1)
        NSLog(@"%@",error1);

}

NSURL* exportURL = [NSURL fileURLWithPath:exportPath];

exporter.outputURL = exportURL; 

// do the export
[exporter exportAsynchronouslyWithCompletionHandler:^{

    int exportStatus = exporter.status;

    switch (exportStatus) {

        case AVAssetExportSessionStatusFailed: …
Run Code Online (Sandbox Code Playgroud)

ios

8
推荐指数
1
解决办法
6822
查看次数

标签 统计

ios ×2

iphone ×1

ipod ×1

itunes-sdk ×1

media-player ×1