Hey. I write an audio player for Android. The problem is this: there is a collection ( LinkedList ) of audio file paths. Purpose: The MediaPlayer should, after playing one, proceed to the next.
OnCompletionListener() implemented so that in the onCompletion() method after the end of playback, the presence of the next file element in the collection is checked and if there is one, start() MediaPlayerʻa is called.
I can not figure out why, but 1 file is being played - 2 file is on, it is also being played - 3 file is on, it is also being played - 4 file is on, and now it is played endlessly, then again several files are played and the next one is endless.
Parameter Looping()=false , all files have the extension .ogg, these files are 3 and 4 seconds, others are longer, others are less long. Those. onCompletion() is not called at all in these two cases.
@Override public void onCompletion(MediaPlayer mp){ Toast.makeText(this, "Воспроизведение закончено!", Toast.LENGTH_SHORT).show(); if(lllZZZ.listIterator(indd+1).hasNext()){ if(!new File(lllZZZ.get(indd+1)).isDirectory()){ indd=indd+1; startmp(indd); } } else{ indd=indffZZZ; startmp(indffZZZ); } } Thus, the transition to the next file does not occur. Who thinks why?