2014-10-07 2 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 horizontalOrientationChange 이벤트에

답변

0

이 나 fullscreen에 비디오를 얻을 어떤 이벤트, 당신은 숨길 수있을 것이다Status BarAction Bar. 이렇게하면 방향을 바꿀 때 상태 표시 줄과 동작 표시 줄이 숨겨져 비디오를 전체 화면으로 볼 수 있습니다.

상태 표시 줄 숨기기 방법

:

1See this from Android Developer 어떻게 숨길

작업 표시 줄 : 희망이

2See This Post

을 도와 줘.

0

다음 코드를 적용하여 문제를 해결할 수 있었지만 여전히 완전한 전체 화면으로 이동하지는 않습니다. 의 onConfigurationChanged에서

@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

구성이 prtrait 다시 변경 될 때 규칙을 제거해야이

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

같은 비디오 프레임에 규칙을 설정

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); 
    } 
관련 문제