// Path: app/src/main/java/com/commonslab/commonslab/Activities/MainActivity.java
// public static final String PAUSE_OPUS = "org.wikimedia.commons.wikimedia.PAUSE_OPUS";
// 
// Path: app/src/main/java/com/commonslab/commonslab/Activities/MainActivity.java
// public static final String PLAY_OPUS = "org.wikimedia.commons.wikimedia.PLAY_OPUS";
// 
// Path: app/src/main/java/com/commonslab/commonslab/Activities/MainActivity.java
// public static final String SEEKBAR_UPDATE_OPUS = "org.wikimedia.commons.wikimedia.SEEKBAR_UPDATE_OPUS";
// 
// Path: app/src/main/java/com/commonslab/commonslab/Activities/MainActivity.java
// public static final String STOP_OPUS = "org.wikimedia.commons.wikimedia.STOP_OPUS";


import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.widget.Toast;
import com.audionowdigital.android.openplayer.Player;
import com.audionowdigital.android.openplayer.PlayerEvents;
import com.commonslab.commonslab.R;
import static com.commonslab.commonslab.Activities.MainActivity.PAUSE_OPUS;
import static com.commonslab.commonslab.Activities.MainActivity.PLAY_OPUS;
import static com.commonslab.commonslab.Activities.MainActivity.SEEKBAR_UPDATE_OPUS;
import static com.commonslab.commonslab.Activities.MainActivity.STOP_OPUS;
                        Log.d(TAG, "Starting to read header");
                        break;
                    case PlayerEvents.READY_TO_PLAY:
                        Log.d(TAG, "READY to play - press play :)");
                        if (player != null && player.isReadyToPlay()) {
                            player.play();
                            Intent intent = new Intent(PLAY_OPUS);
                            context.sendBroadcast(intent);
                        }
                        break;
                    case PlayerEvents.PLAY_UPDATE:
                        Log.d(TAG, "Playing:" + (msg.arg1 / 60) + ":" + (msg.arg1 % 60) + " (" + (msg.arg1) + "s)");
                        seekBarIntent.putExtra("progressPosition", String.valueOf((int) (msg.arg1 * 100 / player.getDuration())));
                        context.sendBroadcast(seekBarIntent);
                        break;
                    case PlayerEvents.TRACK_INFO:
                        Bundle data = msg.getData();
                        Log.d(TAG, "title:" + data.getString("title") + " artist:" + data.getString("artist") + " album:" + data.getString("album") +
                                " date:" + data.getString("date") + " track:" + data.getString("track"));
                        break;
                }
            }
        };
        // quick test for a quick player
        player = new Player(playbackHandler, type);
    }

    public void toggleOpusPlayer() {
        if (player.isPlaying()) {
            pauseOpusMedia();
// Path: app/src/main/java/com/commonslab/commonslab/Activities/MainActivity.java
// public static final String PAUSE_OPUS = "org.wikimedia.commons.wikimedia.PAUSE_OPUS";
// 
// Path: app/src/main/java/com/commonslab/commonslab/Activities/MainActivity.java
// public static final String PLAY_OPUS = "org.wikimedia.commons.wikimedia.PLAY_OPUS";
// 
// Path: app/src/main/java/com/commonslab/commonslab/Activities/MainActivity.java
// public static final String SEEKBAR_UPDATE_OPUS = "org.wikimedia.commons.wikimedia.SEEKBAR_UPDATE_OPUS";
// 
// Path: app/src/main/java/com/commonslab/commonslab/Activities/MainActivity.java
// public static final String STOP_OPUS = "org.wikimedia.commons.wikimedia.STOP_OPUS";


// Path: app/src/main/java/com/commonslab/commonslab/AudioPlayer/OpusPlayer.java
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.widget.Toast;
import com.audionowdigital.android.openplayer.Player;
import com.audionowdigital.android.openplayer.PlayerEvents;
import com.commonslab.commonslab.R;
import static com.commonslab.commonslab.Activities.MainActivity.PAUSE_OPUS;
import static com.commonslab.commonslab.Activities.MainActivity.PLAY_OPUS;
import static com.commonslab.commonslab.Activities.MainActivity.SEEKBAR_UPDATE_OPUS;
import static com.commonslab.commonslab.Activities.MainActivity.STOP_OPUS;

                        Log.d(TAG, "Starting to read header");
                        break;
                    case PlayerEvents.READY_TO_PLAY:
                        Log.d(TAG, "READY to play - press play :)");
                        if (player != null && player.isReadyToPlay()) {
                            player.play();
                            Intent intent = new Intent(PLAY_OPUS);
                            context.sendBroadcast(intent);
                        }
                        break;
                    case PlayerEvents.PLAY_UPDATE:
                        Log.d(TAG, "Playing:" + (msg.arg1 / 60) + ":" + (msg.arg1 % 60) + " (" + (msg.arg1) + "s)");
                        seekBarIntent.putExtra("progressPosition", String.valueOf((int) (msg.arg1 * 100 / player.getDuration())));
                        context.sendBroadcast(seekBarIntent);
                        break;
                    case PlayerEvents.TRACK_INFO:
                        Bundle data = msg.getData();
                        Log.d(TAG, "title:" + data.getString("title") + " artist:" + data.getString("artist") + " album:" + data.getString("album") +
                                " date:" + data.getString("date") + " track:" + data.getString("track"));
                        break;
                }
            }
        };
        // quick test for a quick player
        player = new Player(playbackHandler, type);
    }

    public void toggleOpusPlayer() {
        if (player.isPlaying()) {
            pauseOpusMedia();
            Intent broadcastIntent = new Intent(PAUSE_OPUS);