【问题标题】:Set headers on Vitamio Android在 Vitamio Android 上设置标题
【发布时间】:2017-01-05 07:26:31
【问题描述】:

我正在尝试播放流式 HLS (m3u8),它需要一些参数,例如 User-Agent 和 Referer,但不起作用。

我的代码:

...

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

结果是一样的……

代码有错误吗?格式?顺序可能吗?

谢谢。

【问题讨论】:

    标签: android header m3u8 vitamio referer


    【解决方案1】:
    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);
    

    这是正确的方法。但是解析用户代理与标准方法不同。您使用的是哪个服务器?

    【讨论】:

    • 我不记得了,因为我改变了库 =/
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多