title: Why won't my android service that plays music work?
body: <p>I'm relatively new to android development and I'm trying to make a game in Android Studio where I want background music to play. Here is my code for the service:</p>
  
  <pre><code>public class BackgroundSoundService extends Service {
      private static final String TAG = null;
      MediaPlayer player;
      public IBinder onBind(Intent arg0) {
  
          return null;
      }
      @Override
      public void onCreate() {
          super.onCreate();
          player = MediaPlayer.create(this, R.raw.backgroundmusic);
          player.setLooping(true); // Set looping
          player.setVolume(100,100);
  
      }
      public int onStartCommand(Intent intent, int flags, int startId) {
          player.start();
          return 1;
      }
  
      public IBinder onUnBind(Intent arg0) {
          // TO DO Auto-generated method
          return null;
      }
  
      public void onStop() {
          player.pause();
      }
      public void onPause() {
  
      }
      @Override
      public void onDestroy() {
          player.stop();
          player.release();
      }
  
      @Override
      public void onLowMemory() {
          player.pause();
      }
  }
  </code></pre>
  
  <p>And in the activity where I want to initialise the backgroundmusic</p>
  
  <pre><code>Intent svc=new Intent(this, BackgroundSoundService.class);
  startService(svc);
  </code></pre>
  
  <p>which is placed in the onCreateMethod. When I open the activity where I call the service to play the music, nothing happens, total silence.</p>
  
  <p>For some further details: the backgroundmusic file is in a .mp3 format and the phone on which I do my testing is a Nexus 6 running the latest version of Marshmallow. </p>
  
  <p>I'm probably missing something obvious, can anyone point it out for me and/or give any tips on how to do it better in the future? Thanks in advance.</p>