2014-10-07 79 views
0

我正在使用videoview和示例代码从全网的YouTube/rtmp实时视频应用程序工作,所以秋天我有应用程序工作,但我面临一个问题当我改变方向时,实时视频旋转并展开良好,但它并没有进入一个完整的全屏幕,我如何设置一种方式,只有当我进入横向模式时才能进入完整的全屏幕?全屏Videoview不会隐藏菜单栏在旋转过程中

我的主要活动。

progressdialog = ProgressDialog.show(this, "", " Cargando vídeo por favor espere...", true); 
    progressdialog.setCancelable(true); 

    final VideoView vidView = (VideoView)findViewById(R.id.video_view); 
    String vidAddress = "http://videourl/playlist.m3u8"; 
    Uri vidUri = Uri.parse(vidAddress); 

    vidView.setVideoURI(vidUri); 

    MediaController vidControl = new MediaController(this); 
    vidControl.setAnchorView(vidView); 
    vidView.setMediaController(vidControl); 

    vidView.setOnPreparedListener(new OnPreparedListener() { 

     public void onPrepared(MediaPlayer arg0) { 
      progressdialog.dismiss(); 
      vidView.start(); 


     } 
    }); 

主要XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@color/white" > 

<GridView 
    android:id="@+id/list_playlist" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentRight="true" 
    android:layout_below="@+id/video_view" 
    android:layout_margin="5sp" 
    android:gravity="center" 
    android:numColumns="2" 
    android:scrollbars="none" > 

</GridView> 

<RelativeLayout 
    android:id="@+id/layout_ad" 
    android:layout_width="match_parent" 
    android:layout_height="50sp" 
    android:layout_alignParentBottom="true" 
    android:gravity="center_horizontal" > 
</RelativeLayout> 

<VideoView 
    android:id="@+id/video_view" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentTop="true"/> 

vertical horizontal

回答

0

在你OrientationChange事件或任何事件获取视频fullscreen,你将不得不隐藏Status BarAction Bar。这样,当您改变方向时,状态栏和操作栏将被隐藏,允许视频全屏显示。

如何隐藏状态栏:

See this from Android Developer

如何隐藏操作栏:

2.See This Post

希望这帮助你。

0

我设法通过应用下面的代码来解决问题,但仍然不会去完整的全屏。

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { 
     this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 
     this.requestWindowFeature(Window.FEATURE_NO_TITLE); 

    } 

    setContentView(R.layout.activity_main); 
0
在onConfigurationChanged

设定的规则的视频帧这样

@Override 
public void onConfigurationChanged(Configuration newConfig) { 
    super.onConfigurationChanged(newConfig); 
if (newConfig.orientation == ORIENTATION_LANDSCAPE){ 
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) rel.getLayoutParams(); 
     lp.addRule(RelativeLayout.ALIGN_PARENT_TOP, R.id.relativeFrame); 
     lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, R.id.relativeFrame); 
     lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT, R.id.relativeFrame); 
     lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, R.id.relativeFrame); 
     rel.setLayoutParams(lp); 

     View decorView = getWindow().getDecorView(); 
     int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN; 
     decorView.setSystemUiVisibility(uiOptions); 
} 

记得当配置变回prtrait以除去规则

if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){ 


     RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) rel.getLayoutParams(); 
     lp.removeRule(RelativeLayout.ALIGN_PARENT_TOP); 
     lp.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM); 
     lp.removeRule(RelativeLayout.ALIGN_PARENT_LEFT); 
     lp.removeRule(RelativeLayout.ALIGN_PARENT_RIGHT); 
     rel.setLayoutParams(lp); 
     View decorView = getWindow().getDecorView(); 
     int uiOptions = View.SYSTEM_UI_FLAG_VISIBLE; 
     decorView.setSystemUiVisibility(uiOptions); 
    }