title: Using MediaPlayer for Android Studio
body: <p>I would like to automatically play music in the background when I enter this Fragment page. I believe the commented out section is how you implement it, but I might be typing the first parameter incorrectly? </p>
  
  <pre><code>public class AlphabetFragment extends Fragment {
  
  @Nullable
  @Override
  public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  
      //MediaPlayer mysong;
      //mysong = MediaPlayer.create(AlphabetFragment.this, R.raw.alphabetlist);
      //mysong.start();
  
      return inflater.inflate(R.layout.fragment_alphabet, container, false);
  }
  </code></pre>
  
  <p>Or am I coding this in the wrong spot, should it be part of the MainActivity.java?</p>
  
  <p>case R.id.nav_alphabet:</p>
  
  <pre><code>getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new AlphabetFragment()).commit();
                      //mysong = MediaPlayer.create(AlphabetFragment., R.raw.alphabetlistm4a);
                      //mysong.start();
  </code></pre>