0

したがって、おそらくiOS 4 SDKでは、ユーザーのiTunesライブラリを編集して書き込むことができます。iPhone / iPodライブラリからAVAssetを正常にロードできますが、簡単なテストとして、 AVAssetExportSessionを使用して同じファイルをすぐに上書きしようとしていますが、常にステータス「4」が返されます。それが言うドキュメント:


enum {
    AVAssetExportSessionStatusUnknown,
    AVAssetExportSessionStatusExporting,
    AVAssetExportSessionStatusCompleted,
    AVAssetExportSessionStatusFailed,
    AVAssetExportSessionStatusCancelled,
    AVAssetExportSessionStatusWaiting
};

しかし、AVAssetExportSession.hには次のように書かれています。


enum {
    AVAssetExportSessionStatusUnknown,
    AVAssetExportSessionStatusWaiting,
    AVAssetExportSessionStatusExporting,
    AVAssetExportSessionStatusCompleted,
    AVAssetExportSessionStatusFailed,
    AVAssetExportSessionStatusCancelled
};
typedef NSInteger AVAssetExportSessionStatus;

これが私が使用しているコードです:



// before this, i'm using mpmediapicker to pick an m4a file i synched with my itunes library 

NSURL *assetUrl = [[self.userMediaItemCollection.items objectAtIndex: 0] valueForProperty: MPMediaItemPropertyAssetURL];
AVURLAsset *asset = [AVURLAsset URLAssetWithURL: assetUrl options: nil];
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset: asset presetName: AVAssetExportPresetAppleM4A];
exportSession.outputURL = asset.URL;
exportSession.outputFileType = AVFileTypeAppleM4A;

NSLog(@"output filetype: %@", exportSession.outputFileType);
// prints "com.apple.m4a-audio"

[exportSession exportAsynchronouslyWithCompletionHandler: ^(void) {
    NSLog(@"status: %i for %@", exportSession.status, exportSession.outputURL);
    // prints "status: 4 for ipod-library://item/item.m4a?id=3631988601206299774"
}];

[exportSession release];

どちらにしても...「失敗」か「キャンセル」かと思います。他の誰かが以前にメディアライブラリに正常に書き込んだことがありますか?

ありがとう!

4

2 に答える 2

2

itunesライブラリに書き込むことはできず、今はそこから読み取るだけです。

于 2010-08-22T20:01:06.943 に答える
0
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
NSParameterAssert(library);
if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:[NSURL     fileURLWithPath:movieFileName]]) {
   [library writeVideoAtPathToSavedPhotosAlbum:[NSURL fileURLWithPath:movieFileName]     completionBlock:^(NSURL *assetURL, NSError *error){}];
}
[library release];
于 2011-06-29T21:42:06.353 に答える