title: How can I fix my audio? (Prioritize)
body: <p><strong>When two audio's are played at the same time...the sound is canceling out. How do I fix this weird phenomenon?</strong> </p>
  
  <p>I have some code where there is audio on button click <strong>and</strong> audio in ten second intervals (in a background service). I have the following code to stop the button audio when the ten second interval plays, and it works fine:</p>
  
  <pre><code>public static void myPop(Context context){
      AudioManager manager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
      if(!manager.isMusicActive()) {       //Only if there isn't any other audio playing
          MediaPlayer pop = MediaPlayer.create(context, R.raw.pop);
          pop.start();
      }
      else{
          Log.v(TAG, "Audio is already playing");
      }
  }
  </code></pre>
  
  <p>This works fine, and it stops one audio from playing (pop) to let the other audio play(The one from the background service). Now, I am getting the issue when they both play at the same time. For example, when I tap the button at the <strong>exact</strong> same time as when the audio from the background service is about to start. when they are both played at the same time, the audio just gets cut off </p>
  
  <p>Is there any way to give a preference to the background service audio? Somehow say that: <strong>If two audio pieces start at the exact same time, I want to let the background service audio to play.</strong> </p>
  
  <p>To think of this visually:</p>
  
  <p><a href="https://i.stack.imgur.com/XFfti.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XFfti.png" alt="enter image description here"></a></p>
  
  <p>(<a href="https://upload.wikimedia.org/wikipedia/en/4/49/Preference_example.jpg" rel="nofollow noreferrer">https://upload.wikimedia.org/wikipedia/en/4/49/Preference_example.jpg</a>)</p>
  
  <p><strong>I want to say that if I have the choice between apples and oranges, pick apples. AKA If I have two audioplayers playing at the same time, pick one (the apple).</strong></p>
  
  <p>Thanks for your help,</p>
  
  <p>Ruchir</p>