nsbundle* bundle = [NSBundle mainbundle];
nsstring* path = [bundle Bundlepath];
Nsurl * Fileurl=[nsurl fileurlwithpath:[nsstring stringwithformat:@ "%@/akon, Be-you-with.mp3", Path]];
Audiofiletypeid filetypehint = Kaudiofilemp3type;
NSString *fileextension = [[FileURL path] pathextension];
if ([FileExtension isequal:@ "MP3"]| | [FileExtension isequal:@ "M4A"])
{
Audiofileid FileID = nil;
Osstatus err = NOERR;
Err = Audiofileopenurl ((cfurlref) FileURL, kaudiofilereadpermission, 0, &fileid);
if (err! = NOERR) {
NSLog (@ "Audiofileopenurl failed");
}
UInt32 id3datasize = 0;
Err = Audiofilegetpropertyinfo (FileID, Kaudiofilepropertyid3tag, &id3datasize, NULL);
if (err! = NOERR) {
NSLog (@ "Audiofilegetpropertyinfo failed for ID3 tag");
}
Nsdictionary *pidict = nil;
UInt32 pidatasize = sizeof (PIDICT);
Err = Audiofilegetproperty (FileID, Kaudiofilepropertyinfodictionary, &pidatasize, &pidict);
if (err! = NOERR) {
[Pidict release];
NSLog (@ "Audiofilegetproperty failed for property info dictionary");
}
Cfdataref albumpic= Nil;
UInt32 picdatasize = sizeof (picdatasize);
Err =audiofilegetproperty (FileID, Kaudiofilepropertyalbumartwork, &picdatasize, &albumpic);
if (err! = NOERR) {
NSLog (@ "Get picture failed");
}
nsdata* imagedata= (nsdata*) albumpic;
uiimage* Image=[[uiimage Alloc]initwithdata:imagedata];
Imageview.image=image;
NSString * Album = [(nsdictionary*) pidict Objectforkey:
[NSString Stringwithutf8string:kafinfodictionary_album]];
NSString * Artist = [(nsdictionary*) pidict Objectforkey:
[NSString Stringwithutf8string:kafinfodictionary_artist]];
NSString * Title = [(nsdictionary*) pidict Objectforkey:
[NSString Stringwithutf8string:kafinfodictionary_title]];
NSLog (@ "%@", Title);
NSLog (@ "%@", Artist);
NSLog (@ "%@", Album);
}
Get song information and album images for MP3 and m4a music files-Alternate