Hi friends I got a question. Here it is:
I want to play an mp3 song which first will be downloaded locally and then it will be played.
I have written following code. Please have a look:-
NSURL *url = [NSURL URLWithString:[songURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0];
[request setHTTPMethod:@"POST"];
NSURLResponse *response;
NSError *error;
NSData* result = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
NSString *pathForSoundFile = [[paths objectAtIndex:0] stringByAppendingString:[NSString stringWithFormat:@"/my.mp3"]];
NSLog(@"%@",pathForSoundFile);
NSURL *myURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@",pathForSoundFile]];
[self playPreviewMethod];
-(void)playPreviewMethod
{
[songPreview play];
}
What i guess is that the file is not downloaded or converted in the mp3 format. Please help!