i made a Video Player using the MediaCodec library, and i wanted to add a playlist feature. I tried to have two instances of MediaCodec in order to make a smoother transition between two consecutive videos, however this seems to be dangerous, in some devices (i tried an S4 with cyanogen) it worked perfectly, however in a S4 with TouchWiz the same code crashed on the Media Codec declaration. This is the code snippet:
MediaExtractor extractor = new MediaExtractor();
extractor.setDataSource(path1);
MediaFormat format = extractor.getTrackFormat(0);
String mime = format.getString(MediaFormat.KEY_MIME);
extractor.selectTrack(0);
MediaCodec decoder = MediaCodec.createDecoderByType(mime);
decoder.configure(format, null, null, 0);
MediaExtractor extractor2 = new MediaExtractor();
extractor2.setDataSource(path2);
MediaFormat format2 = extractor2.getTrackFormat(0);
String mime2 = format.getString(MediaFormat.KEY_MIME);
extractor2.selectTrack(0);
MediaCodec decoder2 = MediaCodec.createDecoderByType(mime2);
decoder2.configure(format2, null, null, 0);
and the exception i got on the TouchWiz S4 is
E/ACodec(17651): configureCodec multi window instance fail appPid : 17651
E/ACodec(17651): [OMX.qcom.video.decoder.avc] configureCodec returning error -38
E/MediaCodec(17651): Codec reported an error. (omx error 0x80001001, internalError -38)
Can anyone point me some guidelines on how to do this correctly? Maybe different threads? I really would like to make a smooth transition between different videos, but i need it to work consistently in some devices at least.
Thanks a lot