Skip to content

Commit

Permalink
fix end of file error when startStream after finish video
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroSG94 committed Nov 1, 2023
1 parent 19425a3 commit ed8c6d9
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ public double getTime() {

private void decode() {
if (startTs == 0) {
moveTo(0); //make sure that we are on the start
startTs = System.nanoTime() / 1000;
}
long sleepTime = 0;
Expand Down Expand Up @@ -287,13 +288,15 @@ private void decode() {
boolean render = decodeOutput(output);
codec.releaseOutputBuffer(outIndex, render && bufferInfo.size != 0);
boolean finished = extractor.getSampleTime() < 0;
if (finished && loopMode) {
moveTo(0);
looped = true;
if (finished) {
if (loopMode) {
moveTo(0);
looped = true;
} else {
Log.i(TAG, "end of file");
finished();
}
}
} else if ((bufferInfo.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0 || sampleSize < 0) {
Log.i(TAG, "end of file");
finished();
}
}
}
Expand Down

0 comments on commit ed8c6d9

Please sign in to comment.