0

I'm working on a youtube / rtmp live video app using videoview and samples codes from all over the net so fall i have the app working but I'm facing a problem when i change orientation the live video rotates and expands fine but it doesn't go to a complete full screen, how can i setup a way to go to a complete full screen only when I go into landscape mode?

my main activity.

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


        }
    });

main 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

jww
  • 97,681
  • 90
  • 411
  • 885
Rijo
  • 47
  • 1
  • 8

3 Answers3

0

In your OrientationChange event or whatever event gets the video to fullscreen, You will have to hide the Status Bar and the Action Bar. This way when you change orientation, the Status Bar and Action Bar will be hidden allowing the video to go in fullscreen.

How to Hide the Status Bar:

1. See this from Android Developer

How to Hide the Action Bar:

2. See This Post

Hopefully this helps you.

Community
  • 1
  • 1
Zer0
  • 1,002
  • 1
  • 19
  • 40
0

I have manage to kind of solve the issue by applying the following codes but still wont go to a complete full screen.

@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);
Rijo
  • 47
  • 1
  • 8
0

in onConfigurationChanged set rules to the video frame like this

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

remember to remove rules when configuration changes back to 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);
    }
Ittai Oren
  • 542
  • 5
  • 10