Media Player Looping : Android

This is working on my projects, place mediaPlayer.setLooping(true); after mediaPlayer.start();

public static void PlayAudio(Context c, int id){
        mediaPlayer = MediaPlayer.create(c, id);
        soundPool = new SoundPool(4, AudioManager.STREAM_MUSIC,50);
        if (!mediaPlayer.isPlaying())
        {
            isPlayingAudio = true;
            mediaPlayer.start();
            mediaPlayer.setLooping(true);
        }
    }

Happy Coding


This is a working code that i used in my project

 if (Flags.notificationReceived) {
                        showAlert(Flags.patientModel);
                        Flags.notificationReceived = false;
                        mp.start();
                        mp.setLooping(true);
                        vibrate(2000);
                    }

mMediaPlayer.setLooping(true);