Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot load recorded file #6

Open
Supertecnoboff opened this issue Feb 23, 2015 · 2 comments
Open

Cannot load recorded file #6

Supertecnoboff opened this issue Feb 23, 2015 · 2 comments

Comments

@Supertecnoboff
Copy link

Hi,

This is superb library thank you very much. How can I get it to load a file that I recorded instead of a file stored in the NS Main Bundle? I have tried the following but they don't work:


// "myURL" being a string like so:
// file:///var/mobile/Containers/Data/Application/35B72EE7-7320-4185-9B2E-55C540F738FD/Documents/23Feb2015_065229am.aif

NSURL *assetURL = [NSURL URLWithString:myURL];
AVURLAsset *asset  = [AVURLAsset URLAssetWithURL:assetURL options:nil];

I have tried so many different things and they dont work :(

@mnearents
Copy link

I don't know if this is what you're looking for, but this is how I do it. I'm recording files into the Documents directory and retrieving them from there. Sometimes I record to the Caches directory and retrieve them from there:

AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:[self originalFilePathURL] options:nil];

-(NSURL*)originalFilePathURL {

    NSURL* url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%@",
                                          [self applicationDocumentsDirectory],
                                          @"record.m4a"]];
    return url;
}


-(NSString*)applicationDocumentsDirectory
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
    return basePath;
}

@etayluz
Copy link

etayluz commented Apr 14, 2015

This is how you do it assuming you're selecting a music file from your library:

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

// Setting the asset
MPMediaItem *mediaItem = [[mediaItemCollection items] objectAtIndex:0];

self.waveformView = [SCWaveformView new];
self.waveformView.asset = [AVURLAsset URLAssetWithURL:[mediaItem valueForProperty:MPMediaItemPropertyAssetURL] options:nil];;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants