当前位置: 首页>>代码示例>>Java>>正文


Java AudioEffect类代码示例

本文整理汇总了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();
        }
    }
}
 
开发者ID:kabouzeid,项目名称:Phonograph,代码行数:16,代码来源:NavigationUtil.java

示例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();
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:27,代码来源:MusicPlaybackService.java

示例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);
        }
    }
}
 
开发者ID:Vinetos,项目名称:Hello-Music-droid,代码行数:18,代码来源:MusicService.java

示例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);
        }
    }
}
 
开发者ID:komamj,项目名称:KomaMusic,代码行数:26,代码来源:MusicService.java

示例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();
    }
}
 
开发者ID:Tombarr,项目名称:Noyze,代码行数:15,代码来源:EqualizerVolumePanel.java

示例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;
}
 
开发者ID:Piasy,项目名称:AppRTC-Android,代码行数:12,代码来源:WebRtcAudioEffects.java

示例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();
    }
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:12,代码来源:AudioPlayerFragment.java

示例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);
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:37,代码来源:MusicPlaybackService.java

示例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;
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:34,代码来源:MultiPlayer.java

示例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;
}
 
开发者ID:Piasy,项目名称:AppRTC-Android,代码行数:11,代码来源:WebRtcAudioEffects.java

示例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;
}
 
开发者ID:Piasy,项目名称:AppRTC-Android,代码行数:10,代码来源:WebRtcAudioEffects.java

示例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());
}
 
开发者ID:Piasy,项目名称:AppRTC-Android,代码行数:9,代码来源:WebRtcAudioEffects.java

示例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;
}
 
开发者ID:KishanV,项目名称:Android-Music-Player,代码行数:12,代码来源:LoudnessEnhancerCompatKitKat.java

示例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();
    }
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:38,代码来源:MusicXService.java

示例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);
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:29,代码来源:MainActivity.java


注:本文中的android.media.audiofx.AudioEffect类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。