-1

I have created a basic app which displays an image and also plays a song. I have typed the code below. The app plays the song once. I would like it to play it in a loop. I have added the song to a raw folder in res. I have named the song as happy. I have declared it in MediaPlayer as hbds.

public class MainActivity extends AppCompatActivity {

    MediaPlayer hbds ;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        hbds = MediaPlayer.create(MainActivity.this,R.raw.happy);
        hbds.start();
        setContentView(R.layout.activity_main);
    }
}
Federico klez Culloca
  • 26,308
  • 17
  • 56
  • 95

1 Answers1

0

Implement the On Update Methode in the Methode check if the song stopped playing if it did start it again.

Stroby
  • 11
  • 2