Query if the input started using play() or loop() is currently playing
AudioOutI2S.isPlaying();
1 if input is currently playing, 0 otherwise
// check if playback is still going on
if (!AudioOutI2S.isPlaying()) {
// playback has stopped
Serial.println("playback stopped");
while (1); // do nothing
}