Set headers on Vitamio Android

529 views Asked by At

I'm trying to play a streaming HLS (m3u8) that requires some parameters like User-Agent and Referer but doesn't works.

My code:

...

Map<String,String> options = new HashMap<>();

options.put("Referer","Xxxxxxxx");
options.put("User-Agent","Yyyyyyyy");

videoView.setVideoURI(streamURI,options);

...

And the response:

D/Vitamio[5.0.1][Player]: [http @ 0x9627e500] HTTP error 403 Forbidden
E/Vitamio[5.0.1][Player]: avformat_open_input: Server returned 403 Forbidden (access denied) : -858797304

Also I tried to use it like this:

options.put("headers","Referer:Xxxxxxxx\r\n");
options.put("headers","User-Agent:Yyyyyyyy\r\n");

The result was the same...

Is there an error in the code? the format? the order maybe?

Thanks.

1

There are 1 answers

1
AudioBubble On BEST ANSWER
final HashMap<String, String> options;

options = new HashMap<>();

options.put("headers", "User-Agent: myUserAgent\r\n");

videoView.setVideoURI(Uri.parse("http://www.example.com/playlist.m3u8), options);

It is the correct method. But parsing User agent is different from standard method. Which server your are using?