我有一个需要播放.mp4视频的应用。
以下是代码:
try
{
videoView1 = (VideoView)findViewById(R.id.Video1);
video= Uri.parse("android.resource://dr.droid/" + R.raw.burn);
mc = new MediaController(this);
videoView1.setMediaController(mc);
videoView1.setVideoURI(video);
videoView1.start();
} catch (Exception e) {
Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
}
我总是得到警报无法播放视频,但我没有错误。有任何想法吗?
答案 0 :(得分:0)
就这样 -
String SrcPath = "/sdcard/Video/Android in Spaaaaaace!_low.mp4"; // Instead of this just give your raw folder path.
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
VideoView myVideoView = (VideoView)findViewById(R.id.myvideoview);
myVideoView.setVideoPath(SrcPath);
myVideoView.setMediaController(new MediaController(this));
myVideoView.requestFocus();
myVideoView.start();
}
希望这会奏效。