我正在尝试开发一个 Android 应用程序来从 URL 流式传输视频。但我收到以下错误。
@Override
public void onClick(View v) {
Log.d("TAG", "on Click");
System.out.println("on Click");
// TODO Auto-generated method stub
if(v==play)
{
if( mp.isPlaying()==false && mp!=null)
{
mp.start();
}
}
if(v==stop)
{
mp.stop();
mp.release();
mp=null;
}
if(v==sd)
{
Log.d("TAG", "Loading the video file");
//path="C:\\Users\\Public\\Videos\\Sample Videos\\Wildlife.wmv";
//path="http://10.17.68.18:8080/stream";
path = "http://www.youtube.com/watch?v=wBGIoxvEakw";
try{
mp=new MediaPlayer();
mp.reset();
mp.setDataSource(URLEncoder.encode(path,"UTF-8"));
mp.prepareAsync();
mp.setOnPreparedListener(new OnPreparedListener(){
public void onPrepared(MediaPlayer mp) {
Log.d("TAG", "Playing the video file");
mp.start();
}
});
//mp.start();
}
catch( Exception e)
{
System.out.println(e);
Toast.makeText(this,e.toString(),Toast.LENGTH_LONG)
.show();
}
}
}
错误日志:
02-09 20:44:11.746: W/MediaPlayer(2807): info/warning (1, 26)
02-09 20:44:11.746: E/MediaPlayer(2807): error (-4, -4)
02-09 20:44:11.777: I/MediaPlayer(2807): Info (1,26)
02-09 20:44:11.785: E/MediaPlayer(2807): Error (-4,-4)
02-09 20:49:50.815: W/KeyCharacterMap(2807): No keyboard for id 0