0

I'm playing a video in VideoView on Android Studio. The video starts when I click on the video. How can I get it to display the video instead of a black screen before I click the video to start? I also want to make the video full screen when it is clicked and I'm also struggling to do this. Any help would be greatly appreciated, thanks.

LegWorkouts.java

burpeeButton.setOnClickListener(new Button.OnClickListener(){
        @Override
        public void onClick(View v) {
            VideoView mVideoView2 = (VideoView) findViewById(R.id.burpees);

            String uriPath = "android.resource://com.delta.object.newandroidproject/"+R.raw.burpees;
            Uri uri1 = Uri.parse(uriPath);
            mVideoView2.setVideoURI(uri1);
            mVideoView2.requestFocus();
            mVideoView2.start();

        }
    });

LegWorkouts.xml

<VideoView
    android:id="@+id/burpees"
    android:layout_width="80dp"
    android:layout_height="131dp"
    android:layout_alignStart="@+id/secondJump"
    android:layout_below="@+id/secondJump"
    android:layout_gravity="center"
    android:layout_marginTop="14dp"
    android:visibility="visible" />
GleneaMan
  • 167
  • 1
  • 2
  • 13
  • black screen is duplicate problem. [android-videoview-black-screen](http://stackoverflow.com/questions/9765629/android-videoview-black-screen) – redAllocator Mar 26 '17 at 15:34

1 Answers1

-1

Use seekTo to with time in milliseconds, to display image at the second in the video.

Using zero would set it to the first frame of the video. //Initialize the videoView before onClickListener

    VideoView mVideoView2 = (VideoView) findViewById(R.id.burpees);
    String uriPath = "android.resource://com.delta.object.newandroidproject/"+R.raw.burpees;
    Uri uri1 = Uri.parse(uriPath);
    mVideoView2.setVideoURI(uri1);
    **mVideoView2.seekTo(0);**

burpeeButton.setOnClickListener(new Button.OnClickListener(){
    @Override
    public void onClick(View v) {
    mVideoView2.requestFocus();
    mVideoView2.start();
}
sai
  • 434
  • 5
  • 13
  • Your onClick() is setting up the video. You will need to move the code to initialize the video, so that it is displayed BEFORE you wait for the click. – hg123 Mar 26 '17 at 15:27