// 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;
package qa.edu.qu.cse.cmps312.services.services;



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(),
// 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;

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



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