I ACCEPT your question is “why doesn't it work at all?” This is usually too big a question, but in this case it seems to me that you did not understand at all how MediaExtractor and MediaCodec work.
Not your fault. The documentation is cryptic to say the least. However, I was able to play audio files in this way.
My design assumes MediaCodec implements an asynchronous buffer queue. There seem to be about 4 buffers in this queue.
So, I use 2 streams: one stream puts data from the MediaExtractor in the queue, and the other stream decodes the audio from the queue and writes it to AudioTrack.
I Then you need to be very careful to avoid a dead end during the search, for example. And I get a lot more code than yours. I do not know how to avoid this!
I am thinking about trying a video. Any useful links would be appreciated!
Don
source share