我通过HTTP在自定义VideoView上成功传输视频。通过HTTPS流式传输MP4视频时MediaPlayer出错
但现在,我试图通过HTTPS流式传输已签名的视频。
让我们下面的网址,例如:
那些请求的认证头,从我所要建造的地图标题:
Akm-Client-Timestamp : 2014-09-27T12:18:07Z
Authorization : AKM wdMTVz5Oesgf+UVWO4CX:546gtSMWUPhP8kKPJFaBgZTzWALj/kx3PASz+Y/Za08=
ACCEPT : application/json
,我已经使用setDataSource (Context context, Uri uri, Map<String, String> headers)
用于较新版本的Android,Java reflection
用ICE_CREAM_SANDWICH
之前的标头调用隐藏的setDataSource方法。与地图上的所有以前的标题。
VideoView.java
类
:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
mMediaPlayer.setDataSource (getContext(), mUri, mHeaders);
} else {
Method method = null;
try {
method = mMediaPlayer.getClass().getMethod ("setDataSource", new Class[] { Context.class, Uri.class, Map.class });
} catch (NoSuchMethodException e) {
Log.w (TAG, "Unable to open content: " + mUri, e);
mCurrentState = STATE_ERROR;
mTargetState = STATE_ERROR;
mErrorListener.onError (mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
return;
}
try {
method.invoke (mMediaPlayer, new Object[] {this, mUri, mHeaders});
} catch (IllegalAccessException e) {
Log.w (TAG, "Unable to open content: " + mUri, e);
mCurrentState = STATE_ERROR;
mTargetState = STATE_ERROR;
mErrorListener.onError (mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
return;
} catch (InvocationTargetException e) {
Log.w (TAG, "Unable to open content: " + mUri, e);
mCurrentState = STATE_ERROR;
mTargetState = STATE_ERROR;
mErrorListener.onError (mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
return;
}
}
和播放时,我得到这个错误:
MediaPlayer : error (1, -1004)
AwesomePlayer: mConnectingDataSource->connect() returned -1004
编辑:我想说明,这不是由于视频格式,因为当我下载这个视频并将其存储到手机的外部存储器时,可以使用我的自定义功能播放VideoView
有什么办法可以解决这个问题吗?
谢谢。
http://stackoverflow.com/questions/22073970/how-to-embed-vlc-media-player-to-my-android-app – koutuk 2014-10-04 09:49:05
都去了哪里通过这个,http://developer.android.com/guide/appendix/media-formats.html可能是你的编码不支持。 – Chitrang 2014-10-04 20:12:36