androidamazon-s3amazon-cloudfrontaudio-streaming

Playing m3u8 from Amazon S3 + CloudFront with Signed URL in Android


I was able to access the playlist file (.m3u8) with signed URL. But the problem is, to access the stream files (.ts) within the playlist, the URL of each file needs to be signed too.

For Example:

I can access playlist.m3u8 with signed URL http://abcdefg.cloudfront.net/media/playlist.m3u8?Expires=xxxxxxxx&Policy=yyyyyyyyyyyyy&Signature=zzzzzzzzzzzzzz&Key-Pair-Id=kkkkkkkkkkkkkkkkk

#EXTM3U
#EXT-X-TARGETDURATION:10
#EXTINF:13
playlist-00000.ts
#EXTINF:12,
playlist-00001.ts
#EXTINF:12,
playlist-00002.ts

But each ts file inside it should also be accessed like

http://abcdefg.cloudfront.net/media/playlist-00000.ts?Expires=xxxxxxxx&Policy=yyyyyyyyyyyyy&Signature=zzzzzzzzzzzzzz&Key-Pair-Id=kkkkkkkkkkkkkkkkk

I have to sign every single URL for each .ts files in the playlist.

Unfortunately, I don't see any media player that could handle the appending of the parameters for the URL before it gets the ts files.

If possible, I need a callback from the player like this:

public String onStreamFileReadyForPlaying(String pathToTsFile)
{
     //I could append the parameters here
     return pathToTsFile + "?Expires=xxxxxxxx&Policy=yyyyyyyyyyyyy&Signature=zzzzzzzzzzzzzz&Key-Pair-Id=kkkkkkkkkkkkkkkkk"
}

Solution

  • Simply sign the URLs in the playlist.

    That's all there is to it.