0

我有一个需要播放 .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();
}

我总是收到警报无法播放视频,但我没有收到任何错误。有任何想法吗?

4

1 回答 1

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();
}

希望这会奏效。

于 2012-08-22T11:45:19.697 回答