android 6 videoview,Android-Video View in Fullscreen

蓝泰平
2023-12-01

I am trying to make this VideoView to appear in full screen mode :

public class ViewVideo extends Activity {

private String filename;

private static final int INSERT_ID = Menu.FIRST;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

System.gc();

Intent i = getIntent();

Bundle extras = i.getExtras();

filename = extras.getString("videofilename");

VideoView vv = new VideoView(getApplicationContext());

setContentView(vv);

vv.setVideoPath(filename);

vv.setMediaController(new MediaController(this));

vv.requestFocus();

vv.start();

}

@Override

public boolean onCreateOptionsMenu(Menu menu) {

super.onCreateOptionsMenu(menu);

menu.add(0, INSERT_ID, 0,"FullScreen");

return true;

}

@Override

public boolean onMenuItemSelected(int featureId, MenuItem item) {

switch(item.getItemId()) {

case INSERT_ID:

createNote();

}

return true;

}

private void createNote() {

requestWindowFeature(Window.FEATURE_NO_TITLE);

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,

WindowManager.LayoutParams.FLAG_FULLSCREEN);

}

}

The video is playing from sdcard. Only thing is when I click on the full-screen menu button, the application "stops unexpectedly".

Please help me out, how to get the video to run in full screen? Thanks in advance.

 类似资料: