title: Video Streaming in Android
body: <p>I am working on an application that tries to display the video which is streaming on a webserver. I have the HTTP link for the video stream. To connect to the webserver I am connecting to a specific WIFI which enables me to access the video. </p>
  
  <p>I have taken care of the WIFI connectivity. I am having a problem when I try to display the video on my app using VideoView. I used a tool which showed me that I was receiving data from the server. So my application is receiving the packets of data for the video but it is unable to display it. </p>
  
  <p>The code is like this :</p>
  
  <pre><code>    private VideoView videoView;
      videoView = (VideoView)findViewById(R.id.VideoView_videoOnly);
      ....
      ....
      //connect to the router
      String ip = "http://192.168.2.250";
      URL url = null;
      try {
          url = new URL(ip);
      } catch (MalformedURLException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  
      URLConnection connection = null;
      try {
          connection = url.openConnection();
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  
      String vidLink = "http://XXXX:XXXX@192.168.2.250/axis-cgi/mjpg/video.cgi";
      //set up video streaming
      MediaController mc = new MediaController(this);
      mc.setAnchorView(videoView);
      mc.setMediaPlayer(videoView);
      Uri video = Uri.parse(vidLink);
      videoView.setMediaController(mc);
      videoView.setVideoURI(video);
      videoView.start();
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>XXXX:XXXX is the username and password to access the video stream </p>