我制作了一个简单的应用程序来播放视频,但视频没有播放。我将视频文件放在 res/raw 文件夹中。
public class Video extends Activity {
private MediaController mc;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
VideoView video = (VideoView) findViewById(R.id.video);
Uri uri = Uri.parse("android.resource://" + getPackageName() + "kidvideo");
mc = new MediaController(this);
video.setMediaController(mc);
video.setVideoURI(uri);
video.start();
}
}
我已更改代码,以便可以从 SD 卡运行视频文件。我已将视频文件推送到 data/misc/video/ 文件夹中。并将代码更改为 -
public class Video extends Activity {
private MediaController mc;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Fill view from resource
setContentView(R.layout.main);
VideoView video = (VideoView) findViewById(R.id.video);
// Load and start the movie
video.setVideoPath("data/misc/video/pocket-bike-kid");
video.start();
}
}
但它不工作.......