简体   繁体   中英

MediaPlayer : Put Signed URI into setDataSource android

I'm working on an Android app, and a part of it is about Streaming some videos from the server. Well all I have for now is pretty functional using normal video URIs.

The thing is that all the requests / responses going and coming between the App and the server are Signed with an Private/Public keys (for security reasons).

when it's about images / text I can just build an InputStream and then display it's content, but for the case of the video player I've built it's different since it's based on URIs :

setDataSource (context, Uri.parse(url));

Now the best I can do is to get the signed HttpRequest and try to retrieve from it the signature and the URI to be sent using my VideoPlayer.

So, is there any way to get the URI and the signature from that signed HttpHeaders ?

EDIT : This is what the request headers looks like when I do want to retrieve a video :

GET https://api.example.com/videos/a3jk-APgzh
lYfbkjC3GvFSku6/M5Ex // this is the public key 
2014-08-02T22:05:22Z

and the response :

Calculated: eZH5NbeH8RsSFziDi4uffoD8if4Spyz3I0UcI
[Timestamp]=>2014-08-02T22:05:22Z
[Authorization]=> lYfbkjC3GvFSku6/M5Ex:eZH5NbeH8RsSFzfG6J6ZRsyz3I0UcI=
[ACCEPT]=>application/json

Now, I'm supposed to fill the signed URI of the video in setDataSource from this response.

How can I achieve that ?

Thank you.

If you are signing your request, you must include the corresponding security token in it by adding a token in the header.

When you obtain temporary security credentials, the response includes temporary security credentials and a session token. You provide the session token value as a token in the header when you send requests like the following:

GET /photos/puppy.jpg HTTP/1.1
Host: myWebsite.com
Date: Sat, 02 Aug 2014 19:37:58 +0000

Authorization: TYPE AKIAIOSFODNN7EXAMPLE:frJIUN8DYpKDtOLCwo//yllqDzg=

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM