Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8377493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:41:06+00:00 2026-06-09T15:41:06+00:00

Basically I have 3 songs, and I want the user to be able to

  • 0

Basically I have 3 songs, and I want the user to be able to loop back to the first song once the cycle of 3 songs is complete. Why won’t this work? It will play all 3 songs, then on the fourth click, no song is played.

MediaPlayer song0, song1, song2;
Button play, next;
ArrayList<MediaPlayer> music = new ArrayList<MediaPlayer>();
int track = 0;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {


     super.onCreate(savedInstanceState);
     setContentView(R.layout.main);

     song0 = MediaPlayer.create(TheParty0Activity.this, R.raw.blacksunempire);
     song1 = MediaPlayer.create(TheParty0Activity.this, R.raw.blueskies);
     song2=  MediaPlayer.create(TheParty0Activity.this, R.raw.fuckingnoise);

     music.add(song0);
     music.add(song1);
     music.add(song2);

     play = (Button) findViewById(R.id.button0);
     next = (Button) findViewById(R.id.button1);

     play.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
            music.get(track).start();

        }
    });

     next.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
            music.get(track).stop();
            track++;
            if(track == 3)
                track = 0;

            music.get(track).start();

        }
    });
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:41:07+00:00Added an answer on June 9, 2026 at 3:41 pm

    Call the function:

    MediaPlayer.setLooping(true|false)

    on the mediaplayerObject after you called MediaPlayer.prepare()

    Example:

    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);
    
    mPlayer.start();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this form and a yes or no radio choice. The get_request_ids(song) basically
I basically have three tables, posts, images and postimages (this simply contains the ids
I basically have the same question as this guy .. The example in the
Basically, I have a lot of audio files representing the same song. However, some
I basically have the same problem in this questions: Flash Video still playing in
I basically have the classic many to many model. A user, an award, and
Basically I have this application which scans through all mp3's in a folder and
I have a Song model which contains hundreds of thousands of songs, when I
This is my first time doing these things. Basically I am creating a batch
Basically I have three models songs, playlists and assignments. Songs have many playlists through

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.