在 iPhone 中下载歌曲时停止播放背景音乐

发布于 2024-12-07 10:58:47 字数 84 浏览 1 评论 0原文

我正在使用 asihttp 请求下载歌曲 我的问题是当我点击网址下载歌曲时,歌曲开始在我的视图中播放 我该如何阻止这个,我不想在下载时播放歌曲 请帮忙

I am downloading song with asihttp request
My problem is when i click on url to download song, song start playing in my view
How do i stop this, I dont want song should play when downloading
Please Help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倾城°AllureLove 2024-12-14 10:58:47
 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];
 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];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文