0

i have issues in android video playing. am geting videos from server and set to videoview but videos is playing in backgroung am not able to see that videos ,please refer my code what i have tried.

XML FILE

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
 <VideoView
                        android:id="@+id/eventDetailsPage_videosView"
                        android:layout_width="160dp"
                        android:layout_height="100dp"
                        android:layout_marginBottom="16dp"
                        android:layout_marginLeft="16dp"
                        android:layout_marginTop="16dp"

                        android:background="@drawable/ic_eventvideo_image" />

</LinearLayout>

Java Class

Uri uri=Uri.parse(mEventDetailsUtil1.getAttachmentsUrls().get(0).getAttach_url());

             VideoView mVideosView = (VideoView) findViewById(R.id.eventDetailsPage_videosView);
             MediaController mc = new MediaController(this);

             mc.setAnchorView(mVideosView);
             mc.setMediaPlayer(mVideosView);
             mVideosView.setMediaController(mc);
             mVideosView.setVideoURI(uri);
             mVideosView.requestFocus();
                 mVideosView.start();

the video is playing when opening the activity , but i don't want like that i need when i click on VideoView i need to open video full screen.

venu
  • 2,971
  • 6
  • 40
  • 59

2 Answers2

1

Try this :

VideoView mVideoview;
mVideoview = (VideoView) findViewById(R.id.VideoView);
mPlayServer = (Button) findViewById(R.id.mServerbutton);

mPlayServer.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            playVideo(SERVER_VIDEO_URL);
        }

    });

            private void playVideo(SERVER_VIDEO_URL)
            try {
    // Start the MediaController
          MediaController mediacontroller = new MediaController(mContext);
            mediacontroller.setAnchorView(mVideoview);
            // Get the URL from String VideoURL
            mVideo = Uri.parse(SERVER_VIDEO_URL);
            mVideoview.setMediaController(mediacontroller);
            mVideoview.setVideoURI(mVideo);

        } catch (Exception e) {
            Log.e("Error", e.getMessage());
            e.printStackTrace();

        }

        mVideoview.requestFocus();
        mVideoview.setOnPreparedListener(new OnPreparedListener() {
            // Close the progress bar and play the video
            public void onPrepared(MediaPlayer mp) {

                mVideoview.start();

            }
        });

        mVideoview.setOnCompletionListener(new OnCompletionListener() {
            // Called when video is completed
            public void onCompletion(MediaPlayer mp) {

            }
        });
                   }

To show in fullscreen use video view in new xml file with height and width as fill parent and start new activity with Intent.

Hope this helps.

Siddharth_Vyas
  • 9,972
  • 10
  • 39
  • 69
1

Android does not support the resizing of videos, you may want to look into a Third Party library that you can utilize. By default android does not have this. I got the same problem while applying controls to video player.

Jaydipsinh Zala
  • 16,558
  • 7
  • 41
  • 45