iPod library song path access
Posted
by
Narendra Kumar
on Stack Overflow
See other posts from Stack Overflow
or by Narendra Kumar
Published on 2012-03-30T04:49:50Z
Indexed on
2012/04/02
5:29 UTC
Read the original article
Hit count: 301
iphone
|objective-c
I studied a lot but did not find any good answer. My problem is i am calculating beats per minute of song.I used Bass api for that, now problem is i am able to get bpm of a file which i have in my resource folder but i have to get bpm of all songs of iPod library. I am getting path of song from MPMediaItemPropertyAssetURL property of MpMediaItem but when passing this one in api api is saying stream cant load BASS_StreamCreateFile(). In my point of view i am not getting right path of song. How can we access valid path? Did any one access ipod library song with external api? Please help me .
Thanks
CODE IS THIS
NSURL *assetURL = [song valueForProperty:MPMediaItemPropertyAssetURL];
NSString *respath = [NSString stringWithFormat:@"%@",[assetURL absoluteString]];
BASS_SetConfig(BASS_CONFIG_IOS_MIXAUDIO, 0); // Disable mixing. To be called before BASS_Init.
if (HIWORD(BASS_GetVersion()) != BASSVERSION) {
NSLog(@"An incorrect version of BASS was loaded");
}
// Initialize default device.
if (!BASS_Init(-1, 44100, 0, NULL, NULL)) {
//textView.text = [NSString stringWithFormat:@"%@ CAN'T Load Stream",textView.text];
}
DWORD chan1;
if(!(chan1=BASS_StreamCreateFile(FALSE, [respath UTF8String], 0, 0, BASS_SAMPLE_LOOP))) {
NSLog(@"Can't load stream!");
textView.text = [NSString stringWithFormat:@"%@ not loading...",textView.text];
}
mainStream=BASS_StreamCreateFile(FALSE, [respath cStringUsingEncoding:NSUTF8StringEncoding], 0, 0, BASS_SAMPLE_FLOAT|BASS_STREAM_PRESCAN|BASS_STREAM_DECODE);
float playBackDuration=BASS_ChannelBytes2Seconds(mainStream, BASS_ChannelGetLength(mainStream, BASS_POS_BYTE));
NSLog(@"Play back duration is %f",playBackDuration);
HSTREAM bpmStream=BASS_StreamCreateFile(FALSE, [respath UTF8String], 0, 0, BASS_STREAM_PRESCAN|BASS_SAMPLE_FLOAT|BASS_STREAM_DECODE);
//BASS_ChannelPlay(bpmStream,FALSE);
BpmValue= BASS_FX_BPM_DecodeGet(bpmStream,0.0,
playBackDuration,
MAKELONG(45,256),
BASS_FX_BPM_MULT2| BASS_FX_BPM_MULT2 | BASS_FX_FREESOURCE,
(BPMPROCESSPROC*)proc);
textView.text = [NSString stringWithFormat:@"%@ %f",textView.text,BpmValue];
© Stack Overflow or respective owner