Quantcast
Channel: MediaController positioning over VideoView - Stack Overflow
Viewing all articles
Browse latest Browse all 11

Answer by Stefan Zhelyazkov for MediaController positioning over VideoView

$
0
0

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.

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:orientation="vertical"    tools:context=".DisplayClipActivity"><VideoView android:id="@+id/episode_clip"        android:layout_width="match_parent"        android:layout_height="wrap_content"/></LinearLayout>

and the code for the Activity:

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

Viewing all articles
Browse latest Browse all 11

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>