2011-10-03 194 views
0

我下载的歌曲与asihttp要求 我的问题是,当我在URL点击下载歌曲,歌曲开始在我看来打 如何停止这个,我不想首歌应该玩的时候下载 请帮助停止背景音乐播放时,歌曲下载的iPhone

+0

您不需要下载与ASIHTTPRequest一首歌,因为ASIHTTPRequest没有支持在所有播放歌曲。你究竟在做什么?向我们展示一些代码。 – JosephH

回答

0
obj.tagvalue=[sender tag]; 
NSString * tmp =[NSString stringWithString:[obj.ringArray objectAtIndex:obj.tagvalue]]; 
NSString *filename=[RingUrlArray objectAtIndex:obj.tagvalue]; 
NSLog(@"%@",filename); 


NSURL *url=[NSURL URLWithString:tmp]; 
NSLog(@"url %@",url); 
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; 

NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; 



NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"Song"]; 

if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath]) 
    [[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:nil]; 

NSString *filePath =[NSString stringWithFormat:@"%@/%@.mp3",dataPath,filename]; 

NSLog(@"%@",filePath); 
[request setDownloadDestinationPath:filePath]; 
[request startAsynchronous]; 

UIAlertView *v=[[UIAlertView alloc] initWithTitle:@"Download Message " message:@"Your download has been started" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
[v show]; 
[v release];