1

I want to play vimeo video in VideoView, but here is problem.

Steps for downloading video in desktop is as follows(based on ossguy.com script):

I want to repeat same steps in android, since URL obtained from last step can be played with VideoView. But the problem is when send same request from step 3, response doesn't contain "Location" header. Any ideas?

user1831986
  • 583
  • 1
  • 8
  • 16

2 Answers2

1

If someone needs answer, I posted my solution. Below is my function httpRequest(), which I've used in each step in order to obtain page and response headers. I'm assuming that I had a problem with redirects when I used DefaultHTTPClient, since "Location" header will be given in step 3, where it actually should be redirected.

public URLConnection httpRequest(String path) {
    HttpURLConnection conn = null;
    try {
        URL url = new URL(path);
        conn= (HttpURLConnection) url.openConnection();
        conn.setInstanceFollowRedirects(false);  //you still need to handle redirect manully.
        HttpURLConnection.setFollowRedirects(false);
        conn.setReadTimeout(5000);
        conn.addRequestProperty("Accept-Language", "en-US,en;q=0.8");
        conn.addRequestProperty("User-Agent", "Mozilla/5.0");
        conn.addRequestProperty("Referer", "google.com");
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return conn;
}
user1831986
  • 583
  • 1
  • 8
  • 16
-2

In android

First of all add io.vov.vitamio.widget package in your project .

  1. Then define a videoview in your xml layout file ...

  2. Then use this code in your java file. Make sure that you are importing packages available in vimeo package

    videoView.setVideoURI(Uri.parse(path));

    videoView.setMediaController(new MediaController(this));

    videoView.requestFocus();

    videoView.start();

Vaibs_Cool
  • 6,126
  • 5
  • 28
  • 61
  • I need 'path' variable set to link similar to step 4, problem is getting that url in order to do playing via streaming, I am using vitamio, but if I set link similar to in step 1 and 3, it cannot play video. – user1831986 Sep 09 '13 at 07:06