0

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 have wrapped my layout with Frame Layout
  • I removed my 'VideoView" and add it to the Frame Layout

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

Erdi İzgi
  • 1,262
  • 2
  • 15
  • 33
  • 1
    [this may be helpful](http://stackoverflow.com/questions/18268218/change-screen-orientation-programatically-using-a-button) you should also interest in changing Theme (besides orientation) [Theme.NotTitleBar.Fullscreen](http://stackoverflow.com/questions/10086371/androidtheme-androidstyle-theme-notitlebar-fullscreen-works-on-application). check out also app compat for more "smooth" solutions" possible porbably only on "newer part" of android version market share – snachmsm Aug 18 '16 at 16:02
  • @snachmsm one of the problem goes away. Now I need to care about the making view full screen part – Erdi İzgi Aug 18 '16 at 16:07
  • see the edit :) just googlin... [how-to-set-screen-size-to-full-screen-at-runtime-in-android](http://stackoverflow.com/questions/18268218/how-to-set-screen-size-to-full-screen-at-runtime-in-android) – snachmsm Aug 18 '16 at 16:07
  • @snachmsm well I have tried this before. It is making all the layout fullscreen, not the view. I want just one view visible and streched out to the screen. But thanks anyway. – Erdi İzgi Aug 18 '16 at 16:12
  • so just use `Animation`s and `Transition`s. check [this](https://developer.android.com/training/transitions/index.html) but note that this is for newer api only... – snachmsm Aug 18 '16 at 16:20
  • I need to support 4.1+, I am working on another idea like making gone all the other views. Since only the player will remain and naturally be streched out. – Erdi İzgi Aug 18 '16 at 16:37

1 Answers1

1

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
    }
Erdi İzgi
  • 1,262
  • 2
  • 15
  • 33