我编辑了VideoViewDemo.java(官网提供的 Android Vitamio 演示),目的是在 Vitamio 生成的请求头中添加 cookie 。
(使用方法“setVideoPath”时自动发送标头。)
原始 VideoViewDemo.java:
...
} else {
/*
* Alternatively,for streaming media you can use
* mVideoView.setVideoURI(Uri.parse(URLstring));
*/
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
...
编辑 VideoViewDemo.java:
...
} else {
Map<String, String> headers = new HashMap<String, String>();
headers.put("Cookie", "test=abc; test2=def");
mVideoView.setVideoHeaders(headers);
/*
* Alternatively,for streaming media you can use
* mVideoView.setVideoURI(Uri.parse(URLstring));
*/
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
...
然后我使用Wireshark检查数据包。
我“预期”的结果:
我得到的结果:
它表明我尝试添加的 cookie 不包含在 Vitamio 生成的请求标头中。
我的代码有什么问题吗?或者有没有其他方法可以实现我的目标?
设备:HTC J Z321e
Android 版本:4.1.1
Vitamio 版本:4.2.0 (2013-12-31)
IDE:Eclipse on Windows 7 32 Bit
图片网址:http: //imgur.com/dY7qajG&lHoxxwo#0