// Path: Services/Services/app/src/main/java/qa/edu/qu/cse/cmps312/services/services/MusicPlayerService.java
// public class MusicPlayerService extends Service {
// 
//     @SuppressWarnings("unused")
//     private final String TAG = "MusicService";
// 
//     private static final int NOTIFICATION_ID = 1;
//     private MediaPlayer mPlayer;
//     private int mStartID;
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
// 
//         // Set up the Media Player
//         mPlayer = MediaPlayer.create(this, R.raw.badnews);
// 
//         if (null != mPlayer) {
// 
//             mPlayer.setLooping(false);
// 
//             // Stop Service when music has finished playing
//             mPlayer.setOnCompletionListener(new OnCompletionListener() {
// 
//                 @Override
//                 public void onCompletion(MediaPlayer mp) {
// 
//                     // stop Service if it was started with this ID
//                     // Otherwise let other start commands proceed
//                     stopSelf(mStartID);
// 
//                 }
//             });
//         }
// 
//         // Create a notification area notification so the user
//         // can get back to the MusicServiceClient
// 
//         final Intent notificationIntent = new Intent(getApplicationContext(),
//                 MusicPlayerClient.class);
//         final PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
//                 notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// 
//         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();
// 
//             }
// 
//         }
// 
//         // Don't automatically restart this Service if it is killed
//         return START_NOT_STICKY;
//     }
// 
//     @Override
//     public void onDestroy() {
// 
//         if (null != mPlayer) {
// 
//             mPlayer.stop();
//             mPlayer.release();
// 
//         }
//     }
// 
//     // Can't bind to this Service
//     @Override
//     public IBinder onBind(Intent intent) {
// 
//         return null;
// 
//     }
// 
// }


import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import qa.edu.qu.cse.cmps312.services.services.MusicPlayerService;
package qa.edu.qu.cse.cmps312.services;



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(),
// Path: Services/Services/app/src/main/java/qa/edu/qu/cse/cmps312/services/services/MusicPlayerService.java
// public class MusicPlayerService extends Service {
// 
//     @SuppressWarnings("unused")
//     private final String TAG = "MusicService";
// 
//     private static final int NOTIFICATION_ID = 1;
//     private MediaPlayer mPlayer;
//     private int mStartID;
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
// 
//         // Set up the Media Player
//         mPlayer = MediaPlayer.create(this, R.raw.badnews);
// 
//         if (null != mPlayer) {
// 
//             mPlayer.setLooping(false);
// 
//             // Stop Service when music has finished playing
//             mPlayer.setOnCompletionListener(new OnCompletionListener() {
// 
//                 @Override
//                 public void onCompletion(MediaPlayer mp) {
// 
//                     // stop Service if it was started with this ID
//                     // Otherwise let other start commands proceed
//                     stopSelf(mStartID);
// 
//                 }
//             });
//         }
// 
//         // Create a notification area notification so the user
//         // can get back to the MusicServiceClient
// 
//         final Intent notificationIntent = new Intent(getApplicationContext(),
//                 MusicPlayerClient.class);
//         final PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
//                 notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// 
//         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();
// 
//             }
// 
//         }
// 
//         // Don't automatically restart this Service if it is killed
//         return START_NOT_STICKY;
//     }
// 
//     @Override
//     public void onDestroy() {
// 
//         if (null != mPlayer) {
// 
//             mPlayer.stop();
//             mPlayer.release();
// 
//         }
//     }
// 
//     // Can't bind to this Service
//     @Override
//     public IBinder onBind(Intent intent) {
// 
//         return null;
// 
//     }
// 
// }


// Path: Services/Services/app/src/main/java/qa/edu/qu/cse/cmps312/services/MusicPlayerClient.java
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import qa.edu.qu.cse.cmps312.services.services.MusicPlayerService;

package qa.edu.qu.cse.cmps312.services;



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);