2017-01-05 16 views
0

Я пытаюсь воспроизвести потоковый HLS (m3u8), который требует некоторых параметров, таких как User-Agent и Referer, но не работает.Установить заголовки на Vitamio Android

Мой код:

... 

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

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

videoView.setVideoURI(streamURI,options); 

... 

И ответ:

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 

Также я пытался использовать его как это:

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

Результат был тот же ...

Есть ошибки в co де? Формат? порядок может быть?

Спасибо.

ответ

0
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); 

Это правильный метод. Но разбор агента пользователя отличается от стандартного метода. Какой сервер вы используете?

+0

Я не помню, потому что я сменил библиотеку =/ – AndrewL6891

+0

Справа. Это также поможет вам https://github.com/Bilibili/ijkplayer – powerthazan