tcking / GiraffePlayer2

out of the box android video player(support lazy load, ListView/RecyclerView and hight performance)
Apache License 2.0
377 stars 110 forks source link

Using custom headers while set Video URI #155

Closed yunusmete closed 5 years ago

yunusmete commented 5 years ago

Hi everyone,

I want to set user-agent while set video URI and found that this feature is implemented in GiraffePlayer like that.

/**
  • Sets video URI using specific headers.
  • @param uri the URI of the video.
  • @param headers the headers for the URI request.
  • Note that the cross domain redirection is allowed by default, but that can be
  • changed with key/value pairs through the headers parameter with
  • "android-allow-cross-domain-redirect" as the key and "0" or "1" as the value
  • to disallow or allow cross domain redirection. */ private GiraffePlayer setVideoURI(Uri uri, Map<String, String> headers) throws IOException { this.uri = uri; this.headers.clear(); this.headers.putAll(headers); seekWhenPrepared = 0; return this; }

Unfortunately, there is no public API to use. Is there any way to achieve this? Thanks

tcking commented 5 years ago

Hi,you can set headers like this:


videoInfo.addOption(Option.create(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "headers", "Connection: keep-alive\r\nuser-agent: okhttp\r\n"))

every header KV pairs separate by \r\n

yunusmete commented 5 years ago

Thanks @tcking, closing the issue.