Erdi İzgi
Erdi İzgi

Reputation: 1322

Changing a view's orientation and making it full screen

I am doing a video player application and want to add full screen feature. Currently I am using a layout like youtube's and my video is playing in a videoView and it is completely alright.

I want to toggle the orientation of this videoView and stretch it to make it full screen.

Here what I have tried;

((ViewManager)VideoView.getParent()).removeView(VideoView);
frameLayout.addView(VideoView); 

I berely achieved the result but in this case video is stopping. It's like all the VideoView became useless. When I remove it, it tries to send message to a Handler on a dead thread and stops working.

My question is,

Is there any way to change the parent of a view without removing it? or Is there a better option to make this view full screen?

Note: The type of this VideoView is Exo Media Video View, I used the library below https://github.com/brianwernick/ExoMedia

Upvotes: 0

Views: 839

Answers (1)

Erdi İzgi
Erdi İzgi

Reputation: 1322

Well after thinking about it I found a working solution.

  • Make all the other views GONE
  • hide status bar

basically I have written this functional structure

    private void goFullScreen() {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        makeAllGone();
    }

    private void outFullScreen(){
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        makeAllVisible();
    }

    private void makeAllGone(){
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }

        toolbar.setVisibility(View.GONE);
        // make visibility gone for the rest of the views

    }

    private void makeAllVisible(){
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }

        toolbar.setVisibility(View.VISIBLE);
        // make visibility visible for the rest of the view
    }

Upvotes: 1

Related Questions