类android.media.audiofx.AudioEffect源码实例Demo

下面列出了怎么用android.media.audiofx.AudioEffect的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Muzesto   文件: MusicService.java
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);
        }
    }
}
 
源代码2 项目: Telegram-FOSS   文件: AudioRecordJNI.java
private static boolean isGoodAudioEffect(AudioEffect effect){
	Pattern globalImpl=makeNonEmptyRegex("adsp_good_impls"), globalName=makeNonEmptyRegex("adsp_good_names");
	AudioEffect.Descriptor desc=effect.getDescriptor();
	VLog.d(effect.getClass().getSimpleName()+": implementor="+desc.implementor+", name="+desc.name);
	if(globalImpl!=null && globalImpl.matcher(desc.implementor).find()){
		return true;
	}
	if(globalName!=null && globalName.matcher(desc.name).find()){
		return true;
	}
	if(effect instanceof AcousticEchoCanceler){
		Pattern impl=makeNonEmptyRegex("aaec_good_impls"), name=makeNonEmptyRegex("aaec_good_names");
		if(impl!=null && impl.matcher(desc.implementor).find())
			return true;
		if(name!=null && name.matcher(desc.name).find())
			return true;
	}
	if(effect instanceof NoiseSuppressor){
		Pattern impl=makeNonEmptyRegex("ans_good_impls"), name=makeNonEmptyRegex("ans_good_names");
		if(impl!=null && impl.matcher(desc.implementor).find())
			return true;
		if(name!=null && name.matcher(desc.name).find())
			return true;
	}
	return false;
}
 
源代码3 项目: Telegram   文件: AudioRecordJNI.java
private static boolean isGoodAudioEffect(AudioEffect effect){
	Pattern globalImpl=makeNonEmptyRegex("adsp_good_impls"), globalName=makeNonEmptyRegex("adsp_good_names");
	AudioEffect.Descriptor desc=effect.getDescriptor();
	VLog.d(effect.getClass().getSimpleName()+": implementor="+desc.implementor+", name="+desc.name);
	if(globalImpl!=null && globalImpl.matcher(desc.implementor).find()){
		return true;
	}
	if(globalName!=null && globalName.matcher(desc.name).find()){
		return true;
	}
	if(effect instanceof AcousticEchoCanceler){
		Pattern impl=makeNonEmptyRegex("aaec_good_impls"), name=makeNonEmptyRegex("aaec_good_names");
		if(impl!=null && impl.matcher(desc.implementor).find())
			return true;
		if(name!=null && name.matcher(desc.name).find())
			return true;
	}
	if(effect instanceof NoiseSuppressor){
		Pattern impl=makeNonEmptyRegex("ans_good_impls"), name=makeNonEmptyRegex("ans_good_names");
		if(impl!=null && impl.matcher(desc.implementor).find())
			return true;
		if(name!=null && name.matcher(desc.name).find())
			return true;
	}
	return false;
}
 
源代码4 项目: webrtc_android   文件: WebRtcAudioEffects.java
private static boolean isAcousticEchoCancelerExcludedByUUID() {
  if (Build.VERSION.SDK_INT < 18)
    return false;
  for (Descriptor d : getAvailableEffects()) {
    if (d.type.equals(AudioEffect.EFFECT_TYPE_AEC)
        && d.uuid.equals(AOSP_ACOUSTIC_ECHO_CANCELER)) {
      return true;
    }
  }
  return false;
}
 
源代码5 项目: webrtc_android   文件: WebRtcAudioEffects.java
private static boolean isNoiseSuppressorExcludedByUUID() {
  if (Build.VERSION.SDK_INT < 18)
    return false;
  for (Descriptor d : getAvailableEffects()) {
    if (d.type.equals(AudioEffect.EFFECT_TYPE_NS) && d.uuid.equals(AOSP_NOISE_SUPPRESSOR)) {
      return true;
    }
  }
  return false;
}
 
源代码6 项目: webrtc_android   文件: WebRtcAudioEffects.java
private boolean effectTypeIsVoIP(UUID type) {
  if (Build.VERSION.SDK_INT < 18)
    return false;

  return (AudioEffect.EFFECT_TYPE_AEC.equals(type) && isAcousticEchoCancelerSupported())
      || (AudioEffect.EFFECT_TYPE_NS.equals(type) && isNoiseSuppressorSupported());
}
 
源代码7 项目: webrtc_android   文件: WebRtcAudioEffects.java
private boolean effectTypeIsVoIP(UUID type) {
  if (Build.VERSION.SDK_INT < 18)
    return false;

  return (AudioEffect.EFFECT_TYPE_AEC.equals(type) && isAcousticEchoCancelerSupported())
      || (AudioEffect.EFFECT_TYPE_NS.equals(type) && isNoiseSuppressorSupported());
}
 
源代码8 项目: webrtc_android   文件: WebRtcAudioEffects.java
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;
}
 
源代码9 项目: misound   文件: PlayerService.java
@Override
public void onDestroy() {
    // Check that we're not being destroyed while something is still playing.
    if (isPlaying()) {
        Log.e(LOGTAG, "Service being destroyed while still playing.");
    }
    // release all MediaPlayer resources, including the native player and wakelocks
    Intent i = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
    i.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
    i.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
    sendBroadcast(i);
    mPlayer.release();
    mPlayer = null;

    mAudioManager.abandonAudioFocus(mAudioFocusListener);
    //mAudioManager.unregisterRemoteControlClient(mRemoteControlClient);

    // make sure there aren't any other messages coming
    mDelayedStopHandler.removeCallbacksAndMessages(null);
    mMediaplayerHandler.removeCallbacksAndMessages(null);

    if (mCursor != null) {
        mCursor.close();
        mCursor = null;
    }

    unregisterReceiver(mIntentReceiver);
    if (mUnmountReceiver != null) {
        unregisterReceiver(mUnmountReceiver);
        mUnmountReceiver = null;
    }
    mWakeLock.release();
    mWorker.quit();
    super.onDestroy();
}
 
源代码10 项目: Music-Player   文件: MultiPlayer.java
/**
 * @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;
}
 
源代码11 项目: Music-Player   文件: NavigationUtil.java
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();
        }
    }
}
 
源代码12 项目: MusicPlayer   文件: MultiPlayer.java
/**
 * @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;
}
 
源代码13 项目: MusicPlayer   文件: NavigationUtil.java
public static void openEqualizer(@NonNull final Activity activity) {
    final int sessionId = MusicPlayerRemote.getAudioSessionId();
    if (sessionId == AudioEffect.ERROR_BAD_VALUE) {
        Toasty.error(activity, activity.getResources().getString(R.string.no_audio_ID)).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) {
            Toasty.error(activity, activity.getResources().getString(R.string.no_equalizer)).show();
        }
    }
}
 
源代码14 项目: Noyze   文件: EqualizerVolumePanel.java
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();
    }
}
 
@Override
public void onEnableStatusChange(AudioEffect effect, boolean enabled) {
    final IAudioEffect ieffect = mRefEffect.get();
    final IAudioEffect.OnEnableStatusChangeListener listener = mListener;

    if (ieffect != null && listener != null) {
        listener.onEnableStatusChange(ieffect, enabled);
    }
}
 
源代码16 项目: Orin   文件: NavigationUtil.java
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();
        }
    }
}
 
@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;
}
 
源代码18 项目: coursera-android   文件: MediaPlaybackService.java
@Override
public void onDestroy() {
    // Check that we're not being destroyed while something is still playing.
    if (isPlaying()) {
        Log.e(LOGTAG, "Service being destroyed while still playing.");
    }
    // release all MediaPlayer resources, including the native player and wakelocks
    Intent i = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
    i.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
    i.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
    sendBroadcast(i);
    mPlayer.release();
    mPlayer = null;

    mAudioManager.abandonAudioFocus(mAudioFocusListener);
    //mAudioManager.unregisterRemoteControlClient(mRemoteControlClient);
    
    // make sure there aren't any other messages coming
    mDelayedStopHandler.removeCallbacksAndMessages(null);
    mMediaplayerHandler.removeCallbacksAndMessages(null);

    if (mCursor != null) {
        mCursor.close();
        mCursor = null;
    }

    unregisterReceiver(mIntentReceiver);
    if (mUnmountReceiver != null) {
        unregisterReceiver(mUnmountReceiver);
        mUnmountReceiver = null;
    }
    mWakeLock.release();
    super.onDestroy();
}
 
源代码19 项目: RetroMusicPlayer   文件: MultiPlayer.java
/**
 * @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;
}
 
源代码20 项目: RetroMusicPlayer   文件: Util.java
public static boolean hasEqualizer() {
    for (AudioEffect.Descriptor effect : AudioEffect.queryEffects()) {
        if (EQUALIZER_UUID.equals(effect.type)) {
            return true;
        }
    }
    return false;
}
 
源代码21 项目: VinylMusicPlayer   文件: MultiPlayer.java
/**
 * @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;
}
 
源代码22 项目: VinylMusicPlayer   文件: SettingsActivity.java
private boolean hasEqualizer() {
    final Intent effects = new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL);
    if (getActivity() != null) {
        PackageManager pm = getActivity().getPackageManager();
        ResolveInfo ri = pm.resolveActivity(effects, 0);
        return ri != null;
    }
    return false;
}
 
源代码23 项目: VinylMusicPlayer   文件: NavigationUtil.java
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();
        }
    }
}
 
源代码24 项目: Muzesto   文件: MusicService.java
@Override
public void onDestroy() {
    if (D) Log.d(TAG, "Destroying service");
    super.onDestroy();
    // Remove any sound effects
    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);

    if (TimberUtils.isJellyBeanMR2())
        mHandlerThread.quitSafely();
    else mHandlerThread.quit();

    mPlayer.release();
    mPlayer = null;

    mAudioManager.abandonAudioFocus(mAudioFocusListener);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        mSession.release();

    getContentResolver().unregisterContentObserver(mMediaStoreObserver);

    closeCursor();

    unregisterReceiver(mIntentReceiver);
    if (mUnmountReceiver != null) {
        unregisterReceiver(mUnmountReceiver);
        mUnmountReceiver = null;
    }

    mWakeLock.release();
}
 
源代码25 项目: Audinaut   文件: DownloadService.java
@Override
public void onDestroy() {
    super.onDestroy();
    instance = null;

    if (currentPlaying != null) currentPlaying.setPlaying(false);
    lifecycleSupport.onDestroy();

    Intent i = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
    i.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, audioSessionId);
    i.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
    sendBroadcast(i);

    mediaPlayer.release();
    if (nextMediaPlayer != null) {
        nextMediaPlayer.release();
    }
    mediaPlayerLooper.quit();
    shufflePlayBuffer.shutdown();
    effectsController.release();

    if (bufferTask != null) {
        bufferTask.cancel();
        bufferTask = null;
    }
    if (nextPlayingTask != null) {
        nextPlayingTask.cancel();
        nextPlayingTask = null;
    }
    if (proxy != null) {
        proxy.stop();
        proxy = null;
    }
    Notifications.hidePlayingNotification(this, this, handler);
    Notifications.hideDownloadingNotification(this, this, handler);

    unregisterReceiver(audioNoisyReceiver);
}
 
源代码26 项目: mobile-manager-tool   文件: MusicLibrary.java
/**
 * Respond to clicks on actionbar options
 */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
     case R.id.action_search:
         onSearchRequested();
         break;

     case R.id.action_settings:
     	startActivityForResult(new Intent(this, SettingsHolder.class),0);
         break;

     case R.id.action_eqalizer:
 	    final Intent intent = new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL);
         if (getPackageManager().resolveActivity(intent, 0) == null) {
      	startActivity(new Intent(this, SimpleEq.class));
     	}
     	else{
     		intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, MusicUtils.getCurrentAudioId());
     		startActivity(intent);
     	}
         break;

     case R.id.action_shuffle_all:
     	shuffleAll();
         break;

        default:
            return super.onOptionsItemSelected(item);
    }
    return true;
}
 
源代码27 项目: odyssey   文件: GaplessPlayer.java
/**
 * Stops media playback
 */
synchronized void stop() {
    stopReleaseTask();
    // Check if a player exists otherwise there is nothing to do.
    if (mCurrentMediaPlayer != null) {
        // Check if the player for the next song exists already
        if (mNextMediaPlayer != null) {
            // Remove the next player from the currently playing one.
            mCurrentMediaPlayer.setNextMediaPlayer(null);
            // Release the MediaPlayer, not usable after this command
            mNextMediaPlayer.release();

            // Reset variables to clean internal state
            mNextMediaPlayer = null;
            mSecondPrepared = false;
            mSecondPreparing = false;
        }

        // Check if the currently active player is ready
        if (mCurrentPrepared) {
            /*
             * Signal android desire to close audio effect session
             */
            Intent audioEffectIntent = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
            audioEffectIntent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, mCurrentMediaPlayer.getAudioSessionId());
            audioEffectIntent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, mPlaybackService.getPackageName());
            mPlaybackService.sendBroadcast(audioEffectIntent);

            if (BuildConfig.DEBUG) {
                Log.v(TAG, "Closing effect for session: " + mCurrentMediaPlayer.getAudioSessionId());
            }
        }
        // Release the current player
        mCurrentMediaPlayer.release();

        // Reset variables to clean internal state
        mCurrentMediaPlayer = null;
        mCurrentPrepared = false;
    }
}
 
源代码28 项目: odyssey   文件: GaplessPlayer.java
private void dumpAudioEffectsState() {
    AudioEffect.Descriptor[] effects = AudioEffect.queryEffects();
    Log.v(TAG, "Found audio effects: " + effects.length);
    for (AudioEffect.Descriptor effect : effects) {
        Log.v(TAG, "AudioEffect: " + effect.name + " connect mode: " + effect.connectMode + " implementor: " + effect.implementor);
    }
}
 
源代码29 项目: Phonograph   文件: MultiPlayer.java
/**
 * @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;
}
 
源代码30 项目: Phonograph   文件: NavigationUtil.java
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();
        }
    }
}
 
 类所在包
 同包方法