// Path: app/src/main/java/com/sregg/android/tv/spotifyPlayer/enums/Control.java
// public enum Control {
//     PLAY("{fa-play}"),
//     PAUSE("{fa-pause}"),
//     NEXT("{fa-step-forward}"),
//     PREVIOUS("{fa-step-backward}"),
//     STOP("{fa-stop}"),
//     SHUFFLE("{fa-random}"),
//     FAST_FORWARD("{fa-fast-forward}"),
//     REWIND("{fa-rewind}");
// 
//     private final String mFontId;
// 
//     Control(String fontId) {
//         mFontId = fontId;
//     }
// 
//     public String getFontId() {
//         return mFontId;
//     }
// }


import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Build;
import android.support.v4.media.session.MediaSessionCompat;
import android.view.KeyEvent;
import com.sregg.android.tv.spotifyPlayer.enums.Control;
import timber.log.Timber;
package com.sregg.android.tv.spotifyPlayer.controllers;




/**
 * Created by gw111zz on 24/01/2016.
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public class MediaButtonReceiver extends MediaSessionCompat.Callback {

    private static final String TAG = "MediaButtonReceiver";

    private final SpotifyPlayerController mPlayer;

    public MediaButtonReceiver(SpotifyPlayerController player) {
        mPlayer = player;
    }

    @Override
    public boolean onMediaButtonEvent(Intent mediaButtonIntent) {
        final KeyEvent event = (KeyEvent) mediaButtonIntent.getExtras().get(Intent.EXTRA_KEY_EVENT);
        Timber.d("onMediaButtonEvent: %s", (event == null ? "null" : event));

        if (event == null) {
            return super.onMediaButtonEvent(mediaButtonIntent);
        }

        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            final int keyCode = event.getKeyCode();
            switch (keyCode) {
                case KeyEvent.KEYCODE_MEDIA_PLAY:
// Path: app/src/main/java/com/sregg/android/tv/spotifyPlayer/enums/Control.java
// public enum Control {
//     PLAY("{fa-play}"),
//     PAUSE("{fa-pause}"),
//     NEXT("{fa-step-forward}"),
//     PREVIOUS("{fa-step-backward}"),
//     STOP("{fa-stop}"),
//     SHUFFLE("{fa-random}"),
//     FAST_FORWARD("{fa-fast-forward}"),
//     REWIND("{fa-rewind}");
// 
//     private final String mFontId;
// 
//     Control(String fontId) {
//         mFontId = fontId;
//     }
// 
//     public String getFontId() {
//         return mFontId;
//     }
// }


// Path: app/src/main/java/com/sregg/android/tv/spotifyPlayer/controllers/MediaButtonReceiver.java
import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Build;
import android.support.v4.media.session.MediaSessionCompat;
import android.view.KeyEvent;
import com.sregg.android.tv.spotifyPlayer.enums.Control;
import timber.log.Timber;

package com.sregg.android.tv.spotifyPlayer.controllers;




/**
 * Created by gw111zz on 24/01/2016.
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public class MediaButtonReceiver extends MediaSessionCompat.Callback {

    private static final String TAG = "MediaButtonReceiver";

    private final SpotifyPlayerController mPlayer;

    public MediaButtonReceiver(SpotifyPlayerController player) {
        mPlayer = player;
    }

    @Override
    public boolean onMediaButtonEvent(Intent mediaButtonIntent) {
        final KeyEvent event = (KeyEvent) mediaButtonIntent.getExtras().get(Intent.EXTRA_KEY_EVENT);
        Timber.d("onMediaButtonEvent: %s", (event == null ? "null" : event));

        if (event == null) {
            return super.onMediaButtonEvent(mediaButtonIntent);
        }

        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            final int keyCode = event.getKeyCode();
            switch (keyCode) {
                case KeyEvent.KEYCODE_MEDIA_PLAY:
                    mPlayer.onControlClick(Control.PLAY);