在videoview

时间:2017-12-26 15:53:35

标签: android

以下是我的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();
}

发送null,我想发送以下标题

  

User-Agent:Mozilla / 5.0(Windows NT 6.1; WOW64)AppleWebKit / 537.36(KHTML,与Gecko一样)Chrome / 46.0.2490.80 Safari / 537.36。

怎么做?

1 个答案:

答案 0 :(得分:0)

您可以在setVideoUri(Uri, Map)方法

中添加标题
            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();
            }