I'm trying to build a player that plays mpeg2-ts stream with 2 audio tracks using MediaCodec
and MediaExtractor
. When I set the URL to the extractor: extractor.setDataSource(URL)
int the Logcat I can see that the framework has found the 2 audio tracks:
But afterwards I call:
int trackCount = extractor.getTrackCount();
for (int i = 0; i < track_count; i++){
format = extractor.getTrackFormat(i);
String mime = format.getString(MediaFormat.KEY_MIME);
if (mime.startsWith("video/")) ...
if (mime.startsWith("audio/")) ...
}
trackCount
aways equals 2(1 audio track & 1 video track). What am I doing wrong?