How to make a music loop after the end of Android music

I just wanted the music in my activity to play endlessly (i.e. when my 38 second music ends, I wanted to play it again and again until the user leaves the page). By the way, I am using MediaPlayer.

ourSound = MediaPlayer.create(NewKFCActivity.this, R.raw.start); ourSound.start(); 

Hooray!

+4
source share
1 answer

You can call MediaPlayer#setLooping(boolean) :

 ourSound = MediaPlayer.create(NewKFCActivity.this, R.raw.start); ourSound.setLooping(true); ourSound.start(); 
+16
source

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


All Articles