コード例 #1
0
 static {
   try {
     VisualizerController.checkAvailable();
     visualizerAvailable = true;
   } catch (Throwable t) {
     visualizerAvailable = false;
   }
 }
コード例 #2
0
  @Override
  public void onDestroy() {
    super.onDestroy();
    lifecycleSupport.onDestroy();
    mediaPlayer.release();
    shufflePlayBuffer.shutdown();
    if (equalizerController != null) {
      equalizerController.release();
    }
    if (visualizerController != null) {
      visualizerController.release();
    }

    instance = null;
  }
コード例 #3
0
  @Override
  public void onCreate() {
    Util.setUncaughtExceptionHandler(this);
    super.onCreate();

    mediaPlayer = new MediaPlayer();
    mediaPlayer.setWakeMode(this, PowerManager.PARTIAL_WAKE_LOCK);

    mediaPlayer.setOnErrorListener(
        new MediaPlayer.OnErrorListener() {
          @Override
          public boolean onError(MediaPlayer mediaPlayer, int what, int more) {
            handleError(new Exception("MediaPlayer error: " + what + " (" + more + ")"));
            return false;
          }
        });

    if (equalizerAvailable) {
      equalizerController = new EqualizerController(this, mediaPlayer);
      if (!equalizerController.isAvailable()) {
        equalizerController = null;
      } else {
        equalizerController.loadSettings();
      }
    }
    if (visualizerAvailable) {
      visualizerController = new VisualizerController(this, mediaPlayer);
      if (!visualizerController.isAvailable()) {
        visualizerController = null;
      }
    }

    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, this.getClass().getName());
    wakeLock.setReferenceCounted(false);

    instance = this;
    lifecycleSupport.onCreate();
  }