如何在片段内设置videoView。我在文件资源管理器中推送了a.mp4文件。 3错误显示1.方法findViewById(int)未定义类型视频。 2.构造函数MediaController(Videos)未定义。 3.创建方法getWindowManager()。所以请任何人帮助我如何在Fragment中设置VideoView。
public class Videos extends Fragment {
VideoView video_player_view;
SurfaceView sur_view;
MediaController media_controller;
DisplayMetrics dm;
public Videos() {}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.frag_videos, container, false);
return rootView;
}
public void getInit() {
video_player_view = (VideoView)findViewById(R.id.videoView1);
media_controller = new MediaController(this);
dm = new DisplayMetrics();
this.getWindowManager().getDefaultDisplay().getMetrics(dm);
int height = dm.heightPixels;
int width = dm.heightPixels;
video_player_view.setMinimumHeight(height);
video_player_view.setMinimumWidth(width);
video_player_view.setMediaController(media_controller);
video_player_view.setVideoPath("/mnt/sdcard/a.mp4");
video_player_view.start();
}
}