shubham ghosh
shubham ghosh

Reputation: 1

sending header during request in videoview

Below is my sample code for videoView of vimeo

 public void setVideoPath(String path) {
   setVideoURI(Uri.parse(path));
 }

public void setVideoURI(Uri uri) {
  setVideoURI(uri,null );
}

public void setVideoURI(Uri uri, Map<String, String> headers) {


  mUri = uri;
  mHeaders = headers;
  mSeekWhenPrepared = 0;
  openVideo();
  requestLayout();
  invalidate();
}

Insteaded of sending null, I want to send the following header

User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36.

How to do that ?

Upvotes: 0

Views: 499

Answers (1)

Giuseppe Giacoppo
Giuseppe Giacoppo

Reputation: 435

You can add the header in your setVideoUri(Uri, Map) method

            public void setVideoURI(Uri uri, Map < String, String > headers) {
            if (headers == null) {
                headers = new HashMap<>();
            }

            headers.put("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36.");

            mUri = uri;
            mHeaders = headers;
            mSeekWhenPrepared = 0;
            openVideo();
            requestLayout();
            invalidate();
            }

Upvotes: 0

Related Questions