// Path: Services/Services/app/src/main/java/qa/edu/qu/cse/cmps312/services/MusicPlayerClient.java
// public class MusicPlayerClient extends AppCompatActivity {
// 
//     @Override
//     protected void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         setContentView(R.layout.activity_music_player_client);
//     }
// 
//     public void buttonClicked(View view) {
//         final Intent musicServiceIntent = new Intent(getApplicationContext(),
//                 MusicPlayerService.class);
//         switch (view.getId()) {
//             case R.id.play_button:
// 
//                 // Start the MusicService using the Intent
//                 startService(musicServiceIntent);
// 
//                 break;
//             case R.id.stop_button:
// 
//                 // Stop the MusicService using the Intent
//                 stopService(musicServiceIntent);
// 
//                 break;
// 
//         }
//     }
// }


import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.os.IBinder;
import qa.edu.qu.cse.cmps312.services.MusicPlayerClient;
import qa.edu.qu.cse.cmps312.services.R;
        final Notification notification = new Notification.Builder(
                getApplicationContext())
                .setSmallIcon(android.R.drawable.ic_media_play)
                .setOngoing(true).setContentTitle(getResources().getString(R.string.music_notif_title))
                .setContentText(getResources().getString(R.string.music_notif_text))
                .setContentIntent(pendingIntent).build();

        // Put this Service in a foreground state, so it won't
        // readily be killed by the system
        startForeground(NOTIFICATION_ID, notification);

    }


    @Override
    public int onStartCommand(Intent intent, int flags, int startid) {

        if (null != mPlayer) {

            // ID for this start command
            mStartID = startid;

            if (mPlayer.isPlaying()) {

                // Rewind to beginning of song
                mPlayer.seekTo(0);

            } else {

                // Start playing song
// Path: Services/Services/app/src/main/java/qa/edu/qu/cse/cmps312/services/MusicPlayerClient.java
// public class MusicPlayerClient extends AppCompatActivity {
// 
//     @Override
//     protected void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         setContentView(R.layout.activity_music_player_client);
//     }
// 
//     public void buttonClicked(View view) {
//         final Intent musicServiceIntent = new Intent(getApplicationContext(),
//                 MusicPlayerService.class);
//         switch (view.getId()) {
//             case R.id.play_button:
// 
//                 // Start the MusicService using the Intent
//                 startService(musicServiceIntent);
// 
//                 break;
//             case R.id.stop_button:
// 
//                 // Stop the MusicService using the Intent
//                 stopService(musicServiceIntent);
// 
//                 break;
// 
//         }
//     }
// }


// Path: Services/Services/app/src/main/java/qa/edu/qu/cse/cmps312/services/services/MusicPlayerService.java
import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.os.IBinder;
import qa.edu.qu.cse.cmps312.services.MusicPlayerClient;
import qa.edu.qu.cse.cmps312.services.R;

        final Notification notification = new Notification.Builder(
                getApplicationContext())
                .setSmallIcon(android.R.drawable.ic_media_play)
                .setOngoing(true).setContentTitle(getResources().getString(R.string.music_notif_title))
                .setContentText(getResources().getString(R.string.music_notif_text))
                .setContentIntent(pendingIntent).build();

        // Put this Service in a foreground state, so it won't
        // readily be killed by the system
        startForeground(NOTIFICATION_ID, notification);

    }


    @Override
    public int onStartCommand(Intent intent, int flags, int startid) {

        if (null != mPlayer) {

            // ID for this start command
            mStartID = startid;

            if (mPlayer.isPlaying()) {

                // Rewind to beginning of song
                mPlayer.seekTo(0);

            } else {

                // Start playing song
                mPlayer.start();