本文整理汇总了Java中android.media.audiofx.AudioEffect类的典型用法代码示例。如果您正苦于以下问题:Java AudioEffect类的具体用法?Java AudioEffect怎么用?Java AudioEffect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AudioEffect类属于android.media.audiofx包,在下文中一共展示了AudioEffect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openEqualizer
import android.media.audiofx.AudioEffect; //导入依赖的package包/类
public static void openEqualizer(@NonNull final Activity activity) {
final int sessionId = MusicPlayerRemote.getAudioSessionId();
if (sessionId == AudioEffect.ERROR_BAD_VALUE) {
Toast.makeText(activity, activity.getResources().getString(R.string.no_audio_ID), Toast.LENGTH_LONG).show();
} else {
try {
final Intent effects = new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL);
effects.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, sessionId);
effects.putExtra(AudioEffect.EXTRA_CONTENT_TYPE, AudioEffect.CONTENT_TYPE_MUSIC);
activity.startActivityForResult(effects, 0);
} catch (@NonNull final ActivityNotFoundException notFound) {
Toast.makeText(activity, activity.getResources().getString(R.string.no_equalizer), Toast.LENGTH_SHORT).show();
}
}
}
示例2: onDestroy
import android.media.audiofx.AudioEffect; //导入依赖的package包/类
@Override
public void onDestroy() {
if (D) Logger.d(TAG, "Destroying service");
super.onDestroy();
final Intent audioEffectsIntent = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
audioEffectsIntent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
audioEffectsIntent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
sendBroadcast(audioEffectsIntent);
mAlarmManager.cancel(mShutdownIntent);
mPlayerHandler.removeCallbacksAndMessages(null);
mPlayer.release();
mPlayer = null;
mAudioManager.abandonAudioFocus(mAudioFocusListener);
mMediaSession.release();
mPlayerHandler.removeCallbacksAndMessages(null);
unregisterReceiver(mIntentReceiver);
mWakeLock.release();
}
示例3: pause
import android.media.audiofx.AudioEffect; //导入依赖的package包/类
public void pause() {
if (D) Log.d(TAG, "Pausing playback");
synchronized (this) {
mPlayerHandler.removeMessages(FADEUP);
if (mIsSupposedToBePlaying) {
final Intent intent = new Intent(
AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
sendBroadcast(intent);
mPlayer.pause();
notifyChange(META_CHANGED);
setIsSupposedToBePlaying(false, true);
}
}
}
示例4: pause
import android.media.audiofx.AudioEffect; //导入依赖的package包/类
/**
* Temporarily pauses playback.
*/
public void pause() {
if (mPlayerHandler == null) return;
LogUtils.d(TAG, "Pausing playback");
synchronized (this) {
if (mPlayerHandler != null) {
mPlayerHandler.removeMessages(MusicServiceConstants.FADEUP);
}
if (mIsSupposedToBePlaying) {
final Intent intent = new Intent(
AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
sendBroadcast(intent);
if (mPlayer != null) {
mPlayer.pause();
}
setIsSupposedToBePlaying(false, true);
stopShakeDetector(false);
}
}
}
示例5: release
import android.media.audiofx.AudioEffect; //导入依赖的package包/类
private void release(AudioEffect effect) {
if (null != effect) {
effect.setControlStatusListener(null);
effect.setEnableStatusListener(null);
if (effect instanceof Equalizer) {
((Equalizer) effect).setParameterListener(null);
} else if (effect instanceof BassBoost) {
((BassBoost) effect).setParameterListener(null);
} else if (effect instanceof Virtualizer) {
((Virtualizer) effect).setParameterListener(null);
}
effect.release();
}
}
示例6: getAvailableEffects
import android.media.audiofx.AudioEffect; //导入依赖的package包/类
private static Descriptor[] getAvailableEffects() {
if (cachedEffects != null) {
return cachedEffects;
}
// The caching is best effort only - if this method is called from several
// threads in parallel, they may end up doing the underlying OS call
// multiple times. It's normally only called on one thread so there's no
// real need to optimize for the multiple threads case.
cachedEffects = AudioEffect.queryEffects();
return cachedEffects;
}
示例7: startEffectsPanel
import android.media.audiofx.AudioEffect; //导入依赖的package包/类
private void startEffectsPanel() {
try {
final Intent effects = new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL);
effects.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getContext().getPackageName());
effects.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, MusicUtils.getAudioSessionId());
effects.putExtra(AudioEffect.EXTRA_CONTENT_TYPE, AudioEffect.CONTENT_TYPE_MUSIC);
startActivityForResult(effects, REQUEST_EQ);
} catch (final ActivityNotFoundException ignored) {
Toast.makeText(getActivity(), "No system equalizer found", Toast.LENGTH_SHORT).show();
}
}
示例8: setDataSource
import android.media.audiofx.AudioEffect; //导入依赖的package包/类
/**
* @param path The path of the file, or the http/rtsp URL of the stream
* you want to play
* return True if the <code>player</code> has been prepared and is
* ready to play, false otherwise
*/
void setDataSource(final String path) {
Logger.d(TAG, "setDataSourceImpl, path: " + path);
try {
mCurrentMediaPlayer.reset();
mCurrentMediaPlayer.setOnPreparedListener(this);
mCurrentMediaPlayer.setDataSource(path);
mCurrentMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mCurrentMediaPlayer.prepareAsync();
preparing = true;
mService.get().mIsSupposedToBePlaying = false;
} catch (final IOException e) {
e.printStackTrace();
}
mCurrentMediaPlayer.setOnCompletionListener(this);
mCurrentMediaPlayer.setOnErrorListener(this);
mCurrentMediaPlayer.setOnBufferingUpdateListener(this);
final Intent intent = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION);
intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, mService.get().getPackageName());
mService.get().sendBroadcast(intent);
//return true;
resetBufferPercent();
mService.get().notifyChange(PLAYSTATE_CHANGED);
}
示例9: setDataSourceImpl
import android.media.audiofx.AudioEffect; //导入依赖的package包/类
/**
* @param player The {@link MediaPlayer} to use
* @param path The path of the file, or the http/rtsp URL of the stream
* you want to play
* @return True if the <code>player</code> has been prepared and is
* ready to play, false otherwise
*/
private boolean setDataSourceImpl(@NonNull final MediaPlayer player, @NonNull final String path) {
if (context == null) {
return false;
}
try {
player.reset();
player.setOnPreparedListener(null);
if (path.startsWith("content://")) {
player.setDataSource(context, Uri.parse(path));
} else {
player.setDataSource(path);
}
player.setAudioStreamType(AudioManager.STREAM_MUSIC);
player.prepare();
} catch (Exception e) {
return false;
}
player.setOnCompletionListener(this);
player.setOnErrorListener(this);
final Intent intent = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION);
intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, context.getPackageName());
intent.putExtra(AudioEffect.EXTRA_CONTENT_TYPE, AudioEffect.CONTENT_TYPE_MUSIC);
context.sendBroadcast(intent);
return true;
}
示例10: isAcousticEchoCancelerExcludedByUUID
import android.media.audiofx.AudioEffect; //导入依赖的package包/类
@TargetApi(18)
private static boolean isAcousticEchoCancelerExcludedByUUID() {
for (Descriptor d : getAvailableEffects()) {
if (d.type.equals(AudioEffect.EFFECT_TYPE_AEC)
&& d.uuid.equals(AOSP_ACOUSTIC_ECHO_CANCELER)) {
return true;
}
}
return false;
}
示例11: isNoiseSuppressorExcludedByUUID
import android.media.audiofx.AudioEffect; //导入依赖的package包/类
@TargetApi(18)
private static boolean isNoiseSuppressorExcludedByUUID() {
for (Descriptor d : getAvailableEffects()) {
if (d.type.equals(AudioEffect.EFFECT_TYPE_NS) && d.uuid.equals(AOSP_NOISE_SUPPRESSOR)) {
return true;
}
}
return false;
}
示例12: effectTypeIsVoIP
import android.media.audiofx.AudioEffect; //导入依赖的package包/类
@TargetApi(18)
private boolean effectTypeIsVoIP(UUID type) {
if (!WebRtcAudioUtils.runningOnJellyBeanMR2OrHigher())
return false;
return (AudioEffect.EFFECT_TYPE_AEC.equals(type) && isAcousticEchoCancelerSupported())
|| (AudioEffect.EFFECT_TYPE_NS.equals(type) && isNoiseSuppressorSupported());
}
示例13: create
import android.media.audiofx.AudioEffect; //导入依赖的package包/类
@Override
public AudioEffect create(int audioSession) {
try {
return new LoudnessEnhancer(audioSession);
} catch (RuntimeException e) {
// NOTE: some devices doesn't support LoudnessEnhancer class and may throw an exception
// (ME176C throws IllegalArgumentException)
Log.w(TAG, "Failed to instantiate loudness enhancer class", e);
}
return null;
}
示例14: onDestroy
import android.media.audiofx.AudioEffect; //导入依赖的package包/类
@Override
public void onDestroy() {
super.onDestroy();
Extras.getInstance().setwidgetPosition(100);
audioWidget.cleanUp();
audioWidget = null;
Equalizers.EndEq();
BassBoosts.EndBass();
Virtualizers.EndVirtual();
Loud.EndLoudnessEnhancer();
Reverb.EndReverb();
receiverCleanup();
Extras.getInstance().eqSwitch(false);
audioManager.abandonAudioFocus(this);
removeProgress();
fastplay = false;
isPlaying = false;
paused = false;
stopMediaplayer();
if (!Extras.getInstance().hideLockscreen()) {
if (mediaSessionLockscreen != null) {
mediaSessionLockscreen.release();
mediaSessionLockscreen = null;
}
}
Intent i = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
if (Helper.isActivityPresent(this, i)) {
i.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, audioSession());
i.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, this.getPackageName());
sendBroadcast(i);
} else {
Log.d(TAG, "no activity found");
}
if (!Extras.getInstance().hideNotify()) {
removeNotification();
}
}
示例15: onOptionsItemSelected
import android.media.audiofx.AudioEffect; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
switch (id) {
case android.R.id.home:
FragmentManager fm = getSupportFragmentManager();
if (fm.getBackStackEntryCount() > 0) {
fm.popBackStack();
} else {
fragmentLoader(setContainerId(), setFragment());
}
return true;
case R.id.system_eq:
Intent intent = new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL);
if (intent.getAction() != null && Helper.isActivityPresent(MainActivity.this, intent)){
intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, musicXService.audioSession());
startActivityForResult(intent, EQ);
}else {
Toast.makeText(this, "No app found to handle equalizer", Toast.LENGTH_SHORT).show();
}
break;
case R.id.play_save_queue:
multiQueuePlay();
break;
}
return super.onOptionsItemSelected(item);
}