我想使用AVAudioPlayer在服务器上播放mp3文件 [英] I want to play mp3 files on my server with AVAudioPlayer
本文介绍了我想使用AVAudioPlayer在服务器上播放mp3文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用AVAudioPlayer在服务器上播放mp3文件 我已经尝试过此代码,但是它不起作用.
I want to play mp3 files on my server with AVAudioPlayer I've tried this code, but it does not work.
-(IBAction)playSound {
NSString *path = [[NSBundle mainBundle] pathForResource:@"http://www.domain.com/audio/test.mp3"];
AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
theAudio.delegate = self;
[theAudio play];
}
推荐答案
NSBundle只能选择应用程序捆绑包中的文件,而不能选择Internet上的文件.
NSBundle can only select the files in the apps bundle, not the ones on the internet.
将其设为path
NSString *path = @"http://www.domain.com/audio/test.mp3";
并保持其他所有内容不变,并且应该可以正常工作
and leave everything else the same and it should work
这篇关于我想使用AVAudioPlayer在服务器上播放mp3文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文