I'm successfully streaming videos over HTTP on a custom VideoView.
But now, I'm trying to Stream a signed video over HTTPS.
let's take the following URL for example :
those are the authentication headers of the request, from which I build the Map headers :
Akm-Client-Timestamp : 2014-09-27T12:18:07Z
Authorization : AKM wdMTVz5Oesgf+UVWO4CX:546gtSMWUPhP8kKPJFaBgZTzWALj/kx3PASz+Y/Za08=
ACCEPT : application/json
and I've used setDataSource (Context context, Uri uri, Map<String, String> headers )
for newer versions of Android and Java reflection
to call the hidden setDataSource method with headers prior to ICE_CREAM_SANDWICH
. with all the previous headers on a Map.
in the custom VideoView.java
class :
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;
}
}
and when playing it I get this error :
MediaPlayer : error (1, -1004)
AwesomePlayer: mConnectingDataSource->connect () returned -1004
EDIT : I would like to specify that this is not due to video format, since when I download this very video and store it to the external storage of the phone it can be played with my custom VideoView
Is there any way I can solve this ?
Thank you.