Android 2.3.4 - Http Live Streaming

I am working on this project for a client and we need to stream audio from the server to a device running Android Gingerbread. To get a stream, the Android client has to make a request for a variant playlist, and then make a request for the playlist itself (the one with URIs pointing to chunks of the TS file). The client application then decrypts the chunks and sends them to the platform for playback.

The problem I am facing is regarding the security part. Our client (the respective company) uses a proprietary encryption scheme that serves keys to decrypt fragments of the TS file ahead of time via an HTTP request, instead of following the HLS specification and serving the key files via the URI (s) listed in the index files themselves. As far as I can tell, Android Mediaplayer platform has the ability to find these keyfiles and generate / find the corresponding IVs to decrypt if the keyfiles URIs are in the index files.

Unfortunately, this all means that I cannot decrypt file chunks and play the stream without spaces between each segment - I accomplish this by making HTTP GET requests for each segment, loading them into internal memory, applying decrypt, and then playing them with with the following code:

  public void onCreate(Bundle savedInstanceState) {

    File dir = new File(TS_FILE_DIR);
    String [] files = dir.list();

    mTsFiles = new ArrayList<File>();
    for (String file : files) {
        String path = TS_FILE_DIR + file;
        mTsFiles.add(new File(path));

    mMediaController = new MediaController(this);
    mVideoView = (VideoView)findViewById(;

    mVideoView.setOnPreparedListener(new OnPreparedListener() {

        public void onPrepared(MediaPlayer mp) {
    mVideoView.setOnCompletionListener(new OnCompletionListener() {
        public void onCompletion(MediaPlayer mp) {

            if (mIndex < mTsFiles.size()) {

                try {
                catch (Exception e) {



I tried:

1) Using 2 media planners and switching between 2 media planners, but that doesn't work at all 2) Being in the source code for ICS to get an idea of ​​how it all works, but its very complicated and I don't know much about C ++

Is there something I have missed?


source to share

All Articles