MediaController positioning over VideoView

后端 未结 10 1837
半阙折子戏
半阙折子戏 2020-12-02 07:19

I have a VideoView that takes up the top half of the Activity in portrait orientation with the bottom half of the screen showing some images and text. I am playing a rtsp v

10条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 07:39

    I found really easy solution.

    Just wrap the videoView in a FrameLayout then you can add the MediaController to that FrameLayout from code, like this:

        MediaController mc = new MediaController(context);
        videoView.setMediaController(mc);
    
        FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        lp.gravity = Gravity.BOTTOM;
        mc.setLayoutParams(lp);
    
        ((ViewGroup) mc.getParent()).removeView(mc);
    
        ((FrameLayout) findViewById(R.id.videoViewWrapper)).addView(mc);
    

    EDIT: since I posted this answer I ran into a lot of issues with getting it to hide and with controlling its size so what I ended up doing was I just created my own layout with controls that I could animate and work with without headaches

提交回复
热议问题