0

I'm trying to make an app that you can controll the X position of the video acording to the values of Gyro/Compass. For example the left side of the video only apears on screen, and acording to the movementos of the phone the rest of the movie apears in screen.

I think that the easy thing to do is to create a View that is larger than your phone screen and then control the X value of the videoView, or something like that.

Does anyone have a idea how to do that? Should i use VideoView for this? What is the Best layout to use?

I think that i tried everything and cant make it work.

I will post one of my trys here to help understand what i'm trying to do.

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/absoluteLayout"
    android:layout_width="3000dp"
    android:layout_height="3000dp"
    android:layout_x="-500dp" >

    <VideoView
        android:id="@+id/videoView"
        android:layout_width="2000dp"
        android:layout_height="1255dp"
        android:layout_x="-279dp" />

</AbsoluteLayout>
read
  • 340
  • 5
  • 14

1 Answers1

0

I tried to do it and its working .. Only difference I used the relative layoyt.. check this code:

layout:

<RelativeLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="2000px"
    android:layout_height="1125px"

    tools:context=".MainActivity" >


    <VideoView
        android:id="@+id/videoView"
        android:layout_width="2000px"
        android:layout_height="1125px"
        android:layout_marginTop="0px"
        android:layout_marginLeft="0px" />

    <Button 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="right"
        android:onClick="goright"
        />

    <Button 
        android:layout_width="wrap_content"
        android:layout_marginLeft="100px"
        android:layout_height="wrap_content"
        android:text="down"
        android:onClick="godown"
        />


</RelativeLayout>

and code is :

  public class MainActivity extends Activity {
        private VideoView vv;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

            vv = (VideoView) findViewById(R.id.videoView);

            vv.setVideoPath("sdcard/foo/foo.mp4");
            vv.start();

        }

        public void goright(View v) {
            RelativeLayout.LayoutParams ll = (RelativeLayout.LayoutParams) vv
                    .getLayoutParams();
            ll.setMargins(ll.leftMargin - 100, ll.topMargin, ll.rightMargin,
                    ll.bottomMargin);
            vv.setLayoutParams(ll);
        }

        public void godown(View v) {
            RelativeLayout.LayoutParams ll = (RelativeLayout.LayoutParams) vv
                    .getLayoutParams();
            ll.setMargins(ll.leftMargin, ll.topMargin - 100, ll.rightMargin,
                    ll.bottomMargin);
            vv.setLayoutParams(ll);

        }

    }

there are two buttons to move the video 100px to right or down

good luck,

Maher Abuthraa
  • 17,493
  • 11
  • 81
  • 103
  • I tested it and its not moving the video.. it looks like it is croping the movie not moving it. Appening the same to you? I'm testing with diferents kinds of layouts and im allways getting this problem the video dont move away from the screen instead is behing croped. – read Sep 10 '13 at 11:26
  • I think you would find your answer here: http://stackoverflow.com/a/2216788/2267723 .. and this for more info: http://stackoverflow.com/a/7200749/2267723 – Maher Abuthraa Sep 10 '13 at 11:41