use of org.moire.ultrasonic.audiofx.VisualizerController in project ultrasonic by ultrasonic.
the class DownloadServiceImpl method onCreate.
@SuppressLint("NewApi")
@Override
public void onCreate() {
super.onCreate();
new Thread(new Runnable() {
@Override
public void run() {
Thread.currentThread().setName("DownloadServiceImpl");
Looper.prepare();
if (mediaPlayer != null) {
mediaPlayer.release();
}
mediaPlayer = new MediaPlayer();
mediaPlayer.setWakeMode(DownloadServiceImpl.this, PowerManager.PARTIAL_WAKE_LOCK);
mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
@Override
public boolean onError(MediaPlayer mediaPlayer, int what, int more) {
handleError(new Exception(String.format("MediaPlayer error: %d (%d)", what, more)));
return false;
}
});
try {
Intent i = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION);
i.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, mediaPlayer.getAudioSessionId());
i.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
sendBroadcast(i);
} catch (Throwable e) {
// Froyo or lower
}
mediaPlayerLooper = Looper.myLooper();
mediaPlayerHandler = new Handler(mediaPlayerLooper);
Looper.loop();
}
}).start();
audioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
setUpRemoteControlClient();
if (equalizerAvailable) {
equalizerController = new EqualizerController(this, mediaPlayer);
if (!equalizerController.isAvailable()) {
equalizerController = null;
} else {
equalizerController.loadSettings();
}
}
if (visualizerAvailable) {
visualizerController = new VisualizerController(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();
}
use of org.moire.ultrasonic.audiofx.VisualizerController in project ultrasonic by ultrasonic.
the class VisualizerView method getVizualizer.
private static Visualizer getVizualizer() {
DownloadService downloadService = DownloadServiceImpl.getInstance();
VisualizerController visualizerController = downloadService == null ? null : downloadService.getVisualizerController();
return visualizerController == null ? null : visualizerController.getVisualizer();
}
Aggregations