Reputation: 428
i am new to xcode programming.my need is to search all sound files and display them in table view.Any one please give me idea
Upvotes: 3
Views: 2990
Reputation: 17665
You can get all sound files by simply checking the extension of file. Below I have given the example for mp3 files. If you want to also search for another extension then simply add one more extension in the "OR
" condition:
resourcePath
i.e. directory, because all sound files are resourcesNow search for a specific extension in that list
NSString *bundlePath = [[NSBundle mainBundle] resourcePath];
NSFileManager *filemgr = [[NSFileManager alloc] init];
NSArray *allFiles = [filemgr contentsOfDirectoryAtPath:bundlePath error:NULL];
for (NSString *fileName in allFiles)
{
if ([[fileName pathExtension] isEqualToString:@"mp3"])
{
NSString *fullFilePath = [bundlePath stringByAppendingPathComponent:fileName];
//do whatever you want to do with the path
}
}
Upvotes: 4
Reputation: 1579
If you are looking for Sound files within your app, Ravindra has already answered it.
If you are looking for Sound files from all other Music Apps in the iPhone, I doubt if you can access them.
You can however access the Songs from the users iTunes Music Library. You will need to use the MPMediaPickerController.
Try this tutorial: http://mobile.tutsplus.com/tutorials/iphone/ios-sdk-music-library-access/
Upvotes: 3