private int getTrackIndex(MediaExtractor mediaExtractor, String mimeType) {
        if(mediaExtractor == null) {
            return MediaCodecDecoder.INDEX_NONE;
        }

        for (int i = 0; i < mediaExtractor.getTrackCount(); ++i) {
            MediaFormat format = mediaExtractor.getTrackFormat(i);
            Log.d(TAG, format.toString());
            String mime = format.getString(MediaFormat.KEY_MIME);
            if (mime.startsWith(mimeType)) {
                return i;
            }
        }

        return MediaCodecDecoder.INDEX_NONE;
    }
Sets the media source and automatically selects fitting tracks.

@param source the media source
@throws IOException
@throws IllegalStateException
MediaPlayer/src/main/java/net/protyposis/android/mediaplayer/MediaPlayer.java