use of com.simplecity.amp_library.services.Equalizer in project Shuttle by timusus.
the class MusicService method onCreate.
@SuppressLint("InlinedApi")
@Override
public void onCreate() {
super.onCreate();
notificationHelper = new MusicNotificationHelper(this);
servicePrefs = getSharedPreferences("Service", 0);
prefs = PreferenceManager.getDefaultSharedPreferences(this);
// Start up the thread running the service. Note that we create a
// separate thread because the service normally runs in the process's
// main thread, which we don't want to block. We also make it
// background priority so CPU-intensive work will not disrupt the UI.
handlerThread = new HandlerThread("MusicPlayerHandler", android.os.Process.THREAD_PRIORITY_BACKGROUND);
handlerThread.start();
mainHandler = new Handler(Looper.getMainLooper());
// Initialize the handlers
playerHandler = new MediaPlayerHandler(this, handlerThread.getLooper());
notificationStateHandler = new NotificationStateHandler(this);
registerHeadsetPlugReceiver();
registerBluetoothReceiver();
audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
mediaButtonReceiverComponent = new ComponentName(getPackageName(), MediaButtonIntentReceiver.class.getName());
setupMediaSession();
playbackLocation = LOCAL;
if (ShuttleUtils.isUpgraded()) {
castManager = VideoCastManager.getInstance();
setupCastListener();
castManager.addVideoCastConsumer(castConsumer);
}
if (castManager != null && castManager.isConnected()) {
updatePlaybackLocation(REMOTE);
} else {
updatePlaybackLocation(LOCAL);
}
playbackState = STOPPED;
registerExternalStorageListener();
registerA2dpServiceListener();
player = new MultiPlayer(this);
player.setHandler(playerHandler);
equalizer = new Equalizer(this);
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(ServiceCommand.SERVICE_COMMAND);
intentFilter.addAction(ServiceCommand.TOGGLE_PAUSE_ACTION);
intentFilter.addAction(ServiceCommand.PAUSE_ACTION);
intentFilter.addAction(ServiceCommand.NEXT_ACTION);
intentFilter.addAction(ServiceCommand.PREV_ACTION);
intentFilter.addAction(ServiceCommand.STOP_ACTION);
intentFilter.addAction(ServiceCommand.SHUFFLE_ACTION);
intentFilter.addAction(ServiceCommand.REPEAT_ACTION);
intentFilter.addAction(ExternalIntents.PLAY_STATUS_REQUEST);
registerReceiver(mIntentReceiver, intentFilter);
final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName());
wakeLock.setReferenceCounted(false);
// Initialize the delayed shutdown intent
final Intent shutdownIntent = new Intent(this, MusicService.class);
shutdownIntent.setAction(ServiceCommand.SHUTDOWN);
alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
this.shutdownIntent = PendingIntent.getService(this, 0, shutdownIntent, 0);
// Listen for the idle state
scheduleDelayedShutdown();
reloadQueue();
disposables.add(SleepTimer.getInstance().getCurrentTimeObservable().subscribe(remainingTime -> {
if (remainingTime == 0) {
if (SleepTimer.getInstance().playToEnd) {
pauseOnTrackFinish = true;
} else {
playerHandler.sendEmptyMessage(MusicService.PlayerHandler.FADE_DOWN_STOP);
}
}
}, throwable -> LogUtils.logException(TAG, "Error consuming SleepTimer observable", throwable)));
}
Aggregations