This question is about Objective-C, Xcode and iOS. I want to access the mp3 or m4a files inside the applications documents folder and get these files MPMediaItemPropertyTitle
,MPMediaItemPropertyAlbumTitle
and MPMediaItemPropertyArtist
informations. After that I want to play these files. Actually I want to make a music player application and I need help. Thanks in advance...
Asked
Active
Viewed 1,814 times
1

batiaktas
- 21
- 4
-
What's the **applications documents folder**? There's an applications folder, a bundle for your application, and a documents folder for each user. You need to clarify.. – cacau Aug 05 '14 at 12:06
-
I meant Documents folder @cacau – batiaktas Aug 05 '14 at 12:07
2 Answers
2
you can use below code to get array of mp3file and play it with AVAudio player
-(void)getallMp3Files
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSArray *filePathsArray = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsDirectory error:nil];
NSMutableArray *arrMp3Files=[[NSMutableArray alloc]init];
for (NSString *str in filePathsArray) {
NSString *strFileName=[str.lastPathComponent lowercaseString];
if([strFileName.pathExtension isEqualToString:@"mp3"])
{
NSLog(@"%@",str);
[arrMp3Files addObject:str];
}
}
}

Kalpit Gajera
- 2,475
- 1
- 14
- 24
0
Please refer this below links, Hope it will be helpful
AVPlayer not playing MP3 audio file in documents directory iOS

Community
- 1
- 1

Sreejith Bhatt
- 589
- 3
- 12