<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<VideoView android:name="@+id/video"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/></LinearLayout> private VideoView video;
private MediaController ctrl;
private List<Map<String, String>> list;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//设置窗口特征
getWindow().setFormat(PixelFormat.TRANSLUCENT);
setContentView(R.layout.mp4);
list=publicState.list;
video=(VideoView)findViewById(R.id.video);
int i=getIntent().getIntExtra("position", 0);
File file=new File(list.get(i).get("path"));
if(file.exists()){
Log.i("tag", video+"----------->"+file.getAbsolutePath());
video.setVideoPath(file.getAbsolutePath());
ctrl=new MediaController(this);
ctrl.setMediaPlayer(video);
video.setMediaController(ctrl);
video.requestFocus();
}
}包空指针异常,log打印出来,video是null;这是怎么回事呀android 视频播放
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货