title: Using MediaPlayer class in Java (Android Studio)
body: <p>I want the background music to repeat as long as the user stays in a particular screen. Is there a function in the MediaPlayer class that allows you to do the above task? </p>
  
  <pre><code>button1.setOnClickListener(new View.OnClickListener() { 
      @Overridepublic void onClick(View v) {
  
          Intent intent = new Intent(context,kids_quiz.class);
  
          startActivity(intent);
  
          player=MediaPlayer.create(Games.this,R.raw.macdonald);
  
          player.start();
  
      }
  });
  </code></pre>