本文整理匯總了Java中android.media.audiofx.Visualizer.setEnabled方法的典型用法代碼示例。如果您正苦於以下問題:Java Visualizer.setEnabled方法的具體用法?Java Visualizer.setEnabled怎麽用?Java Visualizer.setEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.media.audiofx.Visualizer
的用法示例。
在下文中一共展示了Visualizer.setEnabled方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: VisualizerWrapper
import android.media.audiofx.Visualizer; //導入方法依賴的package包/類
public VisualizerWrapper(@NonNull Context context, int audioSessionId, @NonNull final OnFftDataCaptureListener onFftDataCaptureListener) {
mediaPlayer = MediaPlayer.create(context, R.raw.av_workaround_1min);
visualizer = new Visualizer(audioSessionId);
visualizer.setEnabled(false);
visualizer.setCaptureSize(Visualizer.getCaptureSizeRange()[1]);
captureRate = Visualizer.getMaxCaptureRate();
captureListener = new Visualizer.OnDataCaptureListener() {
@Override
public void onWaveFormDataCapture(Visualizer visualizer, byte[] waveform, int samplingRate) {
}
@Override
public void onFftDataCapture(Visualizer visualizer, byte[] fft, int samplingRate) {
boolean allZero = Utils.allElementsAreZero(fft);
if (lastZeroArrayTimestamp == 0) {
if (allZero) {
lastZeroArrayTimestamp = System.currentTimeMillis();
}
} else {
if (!allZero) {
lastZeroArrayTimestamp = 0;
} else if (System.currentTimeMillis() - lastZeroArrayTimestamp >= WAIT_UNTIL_HACK) {
setEnabled(true);
lastZeroArrayTimestamp = 0;
}
}
onFftDataCaptureListener.onFftDataCapture(fft);
}
};
visualizer.setEnabled(true);
}
示例2: run
import android.media.audiofx.Visualizer; //導入方法依賴的package包/類
@Override
public void run() {
try {
mVisualizer = new Visualizer(0);
mVisualizer.setEnabled(false);
mVisualizer.setCaptureSize(66);
mVisualizer.setDataCaptureListener(mVisualizerListener,
Visualizer.getMaxCaptureRate(), false, true);
mVisualizer.setEnabled(true);
} catch (Throwable e){
if (areWeInsideSystemUI){
LLog.e(e);
} else e.printStackTrace();
}
}
示例3: linkPlayer
import android.media.audiofx.Visualizer; //導入方法依賴的package包/類
public void linkPlayer(int sessionId){
Timber.d("linkPlayer, session id: %d", sessionId);
visualizer = new Visualizer(sessionId);
if(!visualizer.getEnabled()){
visualizer.setCaptureSize(Visualizer.getCaptureSizeRange()[1]);
}
visualizer.setDataCaptureListener(dataCaptureListener, Visualizer.getMaxCaptureRate() / 2, true, true);
visualizer.setEnabled(true);
}
示例4: startMusic
import android.media.audiofx.Visualizer; //導入方法依賴的package包/類
private Bitmap startMusic() {
mMediaPlayer = MediaPlayer.create(this, R.raw.hyperfun);
mMediaPlayer.setLooping(true);
mAudioSession = mMediaPlayer.getAudioSessionId();
mMediaPlayer.start();
mVisualizer = new Visualizer(mAudioSession);
mVisualizer.setDataCaptureListener(this, Visualizer.getMaxCaptureRate() / 2, true, true);
mVisualizer.setCaptureSize(Visualizer.getCaptureSizeRange()[1] / 2);
Bitmap visualizerBitmap = Bitmap.createBitmap(Visualizer.getCaptureSizeRange()[1] / 2, 2, Bitmap.Config.RGB_565)
.copy(Bitmap.Config.RGB_565, true);
visualizerBitmap.eraseColor(Color.BLACK);
mVisualizer.setScalingMode(Visualizer.SCALING_MODE_AS_PLAYED);
mVisualizer.setEnabled(true);
return visualizerBitmap;
}
示例5: VisualizerShadowChanger
import android.media.audiofx.Visualizer; //導入方法依賴的package包/類
private VisualizerShadowChanger(int audioSessionId) {
mVisualizer = new Visualizer(audioSessionId);
mVisualizer.setEnabled(false);
mVisualizer.setCaptureSize(Visualizer.getCaptureSizeRange()[1]);
mVisualizer.setDataCaptureListener(this, Visualizer.getMaxCaptureRate(), false, true);
}