I am making an iOS application. One of its functions is that it can save recordings and save audio files.
To save the URL of the recorded audio files, I save them in NSUserDefaults as filePaths as follows:
File: ///var/mobile/Containers/Data/Application/17F8E799-D7E1-4B3C-9DFE-7BA48E346314/Documents/recordName.aif
I am using a library called "FVSoundWaveDemo" to try and display a sound wave for a recorded file. But I have a problem with urls ...
The example in "FVSoundWaveDemo" loads the locally imported file as follows:
NSString* filename = [NSString stringWithFormat:@"song1.m4a"];
NSURL* url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:filename ofType:nil]];
_soundWaveView.soundURL = url;
You see a bit with "song1.m4a", well, I want to replace it and make the application use the file URL instead. Like the filePath url that I displayed above in my question.
I tried all kinds of things, for example, trying to "convert" filePath to a regular URL and trying to use AVAssets, etc. But all I'm trying is just causing this error:
The application terminated due to an unreported exception "NSRangeException", reason: "*** - [__ NSArrayM objectAtIndex:]: index 0 outside for an empty array
And this is because the library I use uses AVAssets like this:
AVAssetReader* reader = [[AVAssetReader alloc] initWithAsset:songAsset error:&error];
AVAssetTrack* songTrack = [songAsset.tracks objectAtIndex:0];
NSDictionary* outputSettingsDict = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithInt:kAudioFormatLinearPCM],AVFormatIDKey,
[NSNumber numberWithInt:1],AVNumberOfChannelsKey,
[NSNumber numberWithInt:8],AVLinearPCMBitDepthKey,
[NSNumber numberWithBool:NO],AVLinearPCMIsBigEndianKey,
[NSNumber numberWithBool:NO],AVLinearPCMIsFloatKey,
[NSNumber numberWithBool:NO],AVLinearPCMIsNonInterleaved,
nil];
So, how can I get AVAsset to work with filePath url?
, , , NOT , Xcode.
, , , .
, .