I put in background of my android application a song. I don't know how much time the application is open. And I want to put this song to repeat. My code is:
MediaPlayer mySong;
mySong = MediaPlayer.create(X_0Activity.this, R.raw.tj);
mySong.start();
Uri mediaUri = createUri(context, R.raw.media); // Audiofile in raw folder
Mediaplayer mPlayer = new MediaPlayer();
mPlayer.setDataSource(context, mediaUri);
mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mPlayer.prepare();
mPlayer.setLooping(true); // for repeat song
mPlayer.start();
mySong.setLooping(true) // repeat Song
mySong.start(),
And now you are ready with repeat mode on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With