2017-01-05 48 views
0

我試圖播放需要像User-Agent和Referer這樣的參數但不起作用的流HLS(m3u8)。在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