Android-全屏视频查看 [英] Android-Video View in Fullscreen

查看:23
本文介绍了Android-全屏视频查看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让这个 VideoView 以全屏模式显示:

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

视频正在从 sdcard 播放.唯一的问题是当我单击全屏菜单按钮时,应用程序意外停止".

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.

推荐答案

当您单击菜单项时.你必须开始一个新的活动.对于该活动,您必须在清单中设置主题属性.设置这个值是

when you click an menu item. you have to start a New Activity. for that Activity you have to set the theme attribute in the Manifest. set this value that is

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

就是这样.

这篇关于Android-全屏视频查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆