Code example for Visualizer

Methods: setCaptureSize, setDataCaptureListener, setEnabled

0
    { 
      throw new NullPointerException("Cannot link to null MediaPlayer");
    } 
 
    // Create the Visualizer object and attach it to our media player. 
    mVisualizer = new Visualizer(player.getAudioSessionId());
    Equalizer mEqualizer = new Equalizer(0, player.getAudioSessionId());
    mEqualizer.setEnabled(true);
    mVisualizer.setCaptureSize(Visualizer.getCaptureSizeRange()[1]);
 
    // Pass through Visualizer data to VisualizerView 
    Visualizer.OnDataCaptureListener captureListener = new Visualizer.OnDataCaptureListener()
    { 
      @Override 
      public void onWaveFormDataCapture(Visualizer visualizer, byte[] bytes,
          int samplingRate)
      { 
        updateVisualizer(bytes);
      } 
 
      @Override 
      public void onFftDataCapture(Visualizer visualizer, byte[] bytes,
          int samplingRate)
      { 
        updateVisualizerFFT(bytes);
      } 
    }; 
 
    mVisualizer.setDataCaptureListener(captureListener,
        Visualizer.getMaxCaptureRate() / 2, false, true);
 
    // Enabled Visualizer and disable when we're done with the stream 
    mVisualizer.setEnabled(true);
    player.setOnCompletionListener(new MediaPlayer.OnCompletionListener()
    { 
      @Override 
      public void onCompletion(MediaPlayer mediaPlayer)
      {