MediaController positioning over VideoView

后端 未结 10 1835
半阙折子戏
半阙折子戏 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条回答
  •  无人及你
    2020-12-02 07:25

    I did it by wrapping the VideoView inside a LinearView such that the LinearView has layout_width="match_parent" so that it always stretches to the extent of the screen but layout_height="wrap_content" so that the height of the linear view is always fixed to the height of the content. This way when the video plays the controls are always positioned with the VideoView.

    
    
    
        
    
    

    and the code for the Activity:

    // create media controller
    val mediaController = MediaController(this@DisplayClipActivity)
    mediaController.setAnchorView(videoView)
    mediaController.setMediaPlayer(videoView)
    
    // video view
    videoView.setVideoURI(uri)
    videoView.setMediaController(mediaController)
    videoView.start()
    

提交回复
热议问题