2

I have an activity that show half of the screen facing user and the other half facing another guy in opposite direction. The portion facing another guy has a video view. Like this:

Sample

In my activity layout, I have:

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

    <ScrollView
        android:id="@+id/scrollViewTop"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="10dp"
        android:layout_weight="1"
        android:scrollbars="none"
        android:rotation="180.0" >
        ......
        <VideoView
            android:id="@+id/videoView1"
            android:layout_width="75dp"
            android:layout_height="75dp" />
        ......
    </ScrollView>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:orientation="vertical" >

    </LinearLayout>

</LinearLayout>

I use following code to set the video view: (videofile.mp4)

videoView1 = (VideoView) findViewById(R.id.videoView1);
Uri video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.videofile);
videoView1.setVideoURI(video);
videoView1.start();

It show a black screen without the video playing. Other content is showing correctly in 180 degree rotation except the video playback.

However, if I remove the line android:rotation="180.0" the video is playing correctly.

Is there a way to play the video while the screen is rotated?

Calvin
  • 3,302
  • 2
  • 32
  • 41
  • If i recognise your problem correctly then you want to play video at time of screen rotate by end user, right? if so then you need to apply sensormanager for that. why you put rotation in scroll view? – Brijesh Patel Jun 13 '14 at 07:40
  • because two persons (standing opposite) are looking at the screen at the same time. E.g. a customer and a receiptionist. – Calvin Jun 13 '14 at 07:43

1 Answers1

0

Haven't got any luck finding the proper solution. I use a walk-around instead.

  • First apply a rotation to the video view within the parent rotation.

    <VideoView android:id="@+id/videoView1" android:layout_width="75dp" android:layout_height="75dp" android:rotation="180.0" />

This will cause the layout to become:

enter image description here

  • Then we output the video source (videofile.mp4) to play in 180 degrees.

With 1 + 2, it is "as if" the video is playing in the other direction.

Calvin
  • 3,302
  • 2
  • 32
  • 41