1

I am trying to play videos by url using http streaming in my application using VideoView. Everything is working fine but the problem is that videoView is not able to play .mp4 videos. I searched alot but didn't find any solution. Can anybody tell me what's the solution for that. below is my code.

ProgressDialog pDialog;
    VideoView videoview;

    String VideoURL;

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

        videoview = (VideoView) findViewById(R.id.VideoView);

        VideoURL="http://198.74.53.248/overtribe/photos/125/post/871/1423532370ytl6r_video1.mp4";
        System.out.println("video url " + VideoURL);

        pDialog = new ProgressDialog(VideoViewActivity.this);
        pDialog.setMessage("Buffering...");
        pDialog.setIndeterminate(false);
        pDialog.setCanceledOnTouchOutside(false);
        pDialog.show();

        try {
            // Start the MediaController
            MediaController mediacontroller = new MediaController(
                    VideoViewActivity.this);
            mediacontroller.setAnchorView(videoview);
            // Get the URL from String VideoURL
            Uri video = Uri.parse(VideoURL);
            videoview.setMediaController(mediacontroller);
            videoview.setVideoURI(video);

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

        videoview.requestFocus();
        videoview.setOnPreparedListener(new OnPreparedListener() {
            public void onPrepared(MediaPlayer mp) {
                pDialog.dismiss();
                videoview.start();
            }
        });

    } // onCreate
rahul
  • 2,613
  • 8
  • 32
  • 55
  • Check [this](http://stackoverflow.com/questions/24730087/cant-play-this-video-android-videoview-mp4-recorded-by-android-device)! – Bhavik Mehta Feb 10 '15 at 09:53
  • this is to play a locally stored video. I want to play video using http streaming. – rahul Feb 10 '15 at 10:28
  • The video you are trying to play is of 30 fps and has very huge specification, try uploading a video with low / medium specifications, read android Video format and codec support over developers.android.com, I think the codecs of this video are not supported – Bhavik Mehta Feb 10 '15 at 12:17
  • i am having the same issue, i want to play a video from my server but its not working :/. Did you figure it out? – Lazar Kukolj Mar 28 '16 at 23:49

0 Answers0