ANDROID_LOOP = true - how to avoid MediaPlayer playback loops using this metadata tag

I want to play device tunes using MediaPlayer, but it seems like a metadata tag

ANDROID_LOOP = true 

installed MediaPlayer ignores setLooping method call

 mMediaPlayer.setLooping(false); 

and in any case, audio will sound. Also, the onCompletionListener method is not called.

I noticed that even audio applications, such as ES Media Player loopback audio clips with this tag, are set to true, regardless of whether the loop is on or off.

So my question is, can I

  • make MediaPlayer ignore this tag
  • temporarily change the tag so MediaPlayer does not loop the audio

This question has arisen because of ring tones, but it, of course, is not melodic. It's funny that in the tutorials that I found on how to play ringtones, mMediaPlayer.setLooping (true) is set; so they don’t need to deal with this problem, it seems ...

thanks

enter image description here

+4
source share
1 answer

There may not be a satisfactory answer, but it seems that the engineers are not inclined to change the behavior of MediaPlayer and the metadata tag ANDROID_LOOP=true for ogg files. See Question: http://code.google.com/p/android/issues/detail?id=1314

Regarding the temporary change of the tag, I do not know how you could do this.

I have not tested it, but I believe that other sound formats do not exhibit this behavior (for example, mp3 or wav). Perhaps you can convert the ogg files to another format and save them as temporary data (may help with this: Java - convert ogg to mp3 ). This, of course, seems like a lot of overhead to play some files, but at least they are usually small files.

+2
source

Source: https://habr.com/ru/post/1439096/


All Articles