我要在我的应用程序从远程服务器播放音频文件。我能玩的时候我与本地主机服务器进行测试(使用WAMP)。当相同的文件从服务器提供的它不工作.. 该文件没有扩展名,内容为MP3
字符串fileUrl =http://192.168.1.131/myproject/songs/xyz;
字符串URL =HTTP:// MYSERVER /歌曲/ XYZ; //(MYSERVER - >在远程服务器上)
mVideoView.setVideoURI(Uri.parse(fileUrl));
mVideoView.requestFocus();
此外,我需要有一个更好的控制播放器。 请帮忙...
解决方案 公共无效onRadioClick(视图v){
如果(!IsPlaying模块){
IsPlaying模块= TRUE;
MediaPlayer的熔点为新的MediaPlayer();
尝试 {
mp.setDataSource(的getString(R.string.audio_stream));
MP prepare()。
mp.start();
}赶上(IOException异常E){
Log.e(LOG_TAG,prepare()失败);
}
} 其他 {
IsPlaying模块= FALSE;
stopPlaying();
}
}
私人无效stopPlaying(){
mp.release();
熔点=无效;
}
I need to play audio file from remote server in my app. I could play when I tested with localhost server (using WAMP). When the same file supplied from the server it is not working.. The file has no extension and the content is MP3
String fileUrl = "http://192.168.1.131/myproject/songs/xyz";
String url = "http://myserver/songs/xyz"; //(myserver -> A remote server)
mVideoView.setVideoURI(Uri.parse(fileUrl));
mVideoView.requestFocus();
Also I need to have a better control over player. Please help...
解决方案public void onRadioClick(View v) {
if (!isPLAYING) {
isPLAYING = true;
MediaPlayer mp = new MediaPlayer();
try {
mp.setDataSource(getString(R.string.audio_stream));
mp.prepare();
mp.start();
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
} else {
isPLAYING = false;
stopPlaying();
}
}
private void stopPlaying() {
mp.release();
mp = null;
}