Note that there are some explanatory texts on larger screens.

plurals
  1. POPlay video on part of the screen
    primarykey
    data
    text
    <p>I am completely stumped on something that I thought would be the easiest thing ever. I am trying to play a video inside a frame in a relative layout.</p> <p>Note that the application is meant to run on a very specific device (Archos 101 internet tab) in landscape mode, and the videos are pre-encoded with a very specific size of 480x360, which is why the layout has some fixed sizes.</p> <p>Here is the layout</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;!-- Background --&gt; &lt;ImageView android:layout_width="980dp" android:layout_height="568dp" android:src="@drawable/bg_video" /&gt; &lt;TextView android:id="@+id/video_headtext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="73dp" android:layout_marginLeft="255dp" android:textColor="#FFFFFF" android:textSize="16dp" /&gt; &lt;TextView android:id="@+id/video_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:layout_centerHorizontal="true" android:layout_marginTop="112dp" /&gt; &lt;VideoView android:id="@+id/video_videocontainer" android:layout_width="480dp" android:layout_height="360dp" android:layout_below="@id/video_title" android:layout_marginTop="10dp" android:layout_centerHorizontal="true" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>I load the video using this code</p> <pre><code>player = (VideoPlayer) findViewById(R.id.video_videocontainer); player.setVideoURI(videoUri); </code></pre> <p>The code works, but while the videoView is correctly inside the frame, the video itself plays somewhere in the top of the screen, and only part of it is shown in the VideoView.</p> <p>Example of what happens <a href="http://i.imgur.com/KxFvA.jpg" rel="nofollow">here</a> (This is only a temp video for debugging). Screenshot of the video at the same moment <a href="http://i.imgur.com/U3ezT.png" rel="nofollow">here</a>.</p> <p>As you can see, the VideoView only shows part of the video, filling the rest with black. </p> <p>I'm pretty sure I'm missing something really simple, but I can't figure out what at all.</p> <p>Thanks in advance.</p> <p>EDIT : I have tried writing a VideoPlayer class that extends VideoView and overrides onMeasure like this </p> <pre><code>@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { setMeasuredDimension(480, 360); } public void changeVideoSize() { getHolder().setFixedSize(480, 360); requestLayout(); invalidate(); } </code></pre> <p>But it doesn't help a single bit.</p> <p>EDIT 2 : Tried with a SurfaceView and MediaPlayer, same result. I have the feeling I haven't understood the principle of playing a video on Android. Getting quite stuck here.</p> <p>EDIT 3 : I have tried on a Samsung Galaxy HD and the video shows correctly inside the frame. I wonder if this is a problem with the tablet, or with 2.2?</p> <p>EDIT 4 : AVD running under 2.2 doesn't render the video properly. AVD running 4.1 does. I guess that narrows it down a tad.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload