2014-10-07 80 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); 
    }