Created
August 9, 2012 15:07
-
-
Save dhilipsiva/3304992 to your computer and use it in GitHub Desktop.
Code to Copy from iPod Library to App's Directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Implement this in the MPMediaPickerControllerDelegate | |
-(void)mediaPicker:(MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection{ | |
NSString *tempPath = NSTemporaryDirectory(); | |
int i=1; | |
for (MPMediaItem *theItem in mediaItemCollection.items) { | |
NSURL *url = [theItem valueForProperty:MPMediaItemPropertyAssetURL]; | |
AVURLAsset *songAsset = [AVURLAsset URLAssetWithURL:url options:nil]; | |
AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset: songAsset presetName: AVAssetExportPresetPassthrough]; | |
exporter.outputFileType = @"com.apple.coreaudio-format"; | |
NSString *fname = [[NSString stringWithFormat:@"%d",i] stringByAppendingString:@".caf"]; | |
++i; | |
NSString *exportFile = [tempPath stringByAppendingPathComponent: fname]; | |
exporter.outputURL = [NSURL fileURLWithPath:exportFile]; | |
[exporter exportAsynchronouslyWithCompletionHandler:^{ | |
//Code for completion Handler | |
}]; | |
} | |
[picker dismissViewControllerAnimated:YES completion:Nil]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment