Android MediaPlayer支持使用包含的HTTP标头设置数据源: setDataSource(Context context,Uri uri,Map headers)
但是如果我用它来设置像这样的HttpHeaders:
Map<String, String> headers = new HashMap<String, String>();
headers.put("cookie", "rapidsession="+MyApplication.getInstance().getAccess_token());
mediaPlayer.setDataSource(mContext, mUri, headers )
它从不在手机上播放视频: Galaxy S6 edge,android6.0.1
但正常在手机上播放,如xiaomi
它可以获得uri,我已经添加了Internet权限
当我播放音频时,它正在工作。但是logcat说:
10-19 16:45:24.145 20369-20369 / com.dj.zfwx.client.activity E / ViewRootImpl:sendUserActionEvent()mView == null 10-19 16:45:24.415 20369-20369 / com.dj.zfwx.client.activity W / MediaPlayer:无法在客户端打开文件;尝试服务器端:java.io.FileNotFoundException:没有内容提供者:http://video.zfwx.com/111/16mp4/qiyefengxian/20160923wuhua/1.m4a?key=40a3a0ec95632f538e53b530fb02f869&start=1 10-19 16:45:36.885 20369-21917 / com.dj.zfwx.client.activity W / MediaHTTPConnection:readAt 3477123/32768 =&gt; java.net.ProtocolException 10-19 16:45:36.895 20369-20386 / com.dj.zfwx.client.activity W / MediaPlayer:info / warning(10973,0) 10-19 16:45:40.005 20369-20386 / com.dj.zfwx.client.activity W / MediaPlayer:info / warning(702,0)
当我启动视频时,它无法正常工作。 logcat说:
10-19 16:45:43.235 20369-20369 / com.dj.zfwx.client.activity W / MediaPlayer:无法在客户端打开文件;尝试服务器端:java.io.FileNotFoundException:没有内容提供者:http://video.zfwx.com/111/16mp4/qiyefengxian/20160923wuhua/1.mp4?key=40a3a0ec95632f538e53b530fb02f869&start=3 10-19 16:45:51.275 20369-22248 / com.dj.zfwx.client.activity W / MediaHTTPConnection:readAt 15539690/32768 =&gt; java.net.ProtocolException 10-19 16:45:51.405 20369-20369 / com.dj.zfwx.client.activity W / MediaPlayer:这是IMEDIA_PLAYER_VIDEO_EXIST 10-19 16:45:51.965 20369-21917 / com.dj.zfwx.client.activity W / MediaHTTPConnection:readAt 107713/32768 =&gt; java.net.ProtocolException 10-19 16:45:52.295 20369-20387 / com.dj.zfwx.client.activity W / MediaHTTPConnection:readAt 56404/32768 =&gt; java.net.ProtocolException 10-19 16:45:52.695 20369-21917 / com.dj.zfwx.client.activity W / MediaHTTPConnection:readAt 263623/32768 =&gt; java.net.ProtocolException 10-19 16:45:53.055 20369-20862 / com.dj.zfwx.client.activity W / MediaHTTPConnection:readAt 107713/32768 =&gt; java.net.ProtocolException 10-19 16:45:53.065 20369-22248 / com.dj.zfwx.client.activity W / MediaPlayer:info / warning(3,0) 10-19 16:45:53.075 20369-22248 / com.dj.zfwx.client.activity W / MediaPlayer:info / warning(702,0) 10-19 16:45:53.075 20369-22248 / com.dj.zfwx.client.activity E / MediaPlayer:错误(1,-1004) 10-19 16:45:53.085 20369-20369 / com.dj.zfwx.client.activity E / MediaPlayer:isPlaying:在状态MEDIA_PLAYER_STATE_ERROR中调用 10-19 16:45:53.085 20369-20369 / com.dj.zfwx.client.activity E / MediaPlayer:isPlaying:在状态MEDIA_PLAYER_STATE_ERROR中调用 10-19 16:45:53.085 20369-20369 / com.dj.zfwx.client.activity E / MediaPlayer:isPlaying:在状态MEDIA_PLAYER_STATE_ERROR中调用 10-19 16:45:53.085 20369-20369 / com.dj.zfwx.client.activity E / MediaPlayer:isPlaying:在状态MEDIA_PLAYER_STATE_ERROR中调用 10-19 16:45:53.085 20369-20369 / com.dj.zfwx.client.activity E / MediaPlayer:isPlaying:在状态MEDIA_PLAYER_STATE_ERROR中调用 10-19 16:45:53.085 20369-20369 / com.dj.zfwx.client.activity E / MediaPlayer:isPlaying:在状态MEDIA_PLAYER_STATE_ERROR中调用 10-19 16:45:53.085 20369-20369 / com.dj.zfwx.client.activity E / MediaPlayer:错误(1,-1004)
请帮我解决一下,请... 祝你好运 再次感谢!