码迷,mamicode.com
首页 > 其他好文 > 详细

车载系统 降噪处理

时间:2016-08-02 19:07:27      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:

private AudioManager.OnAudioFocusChangeListener mAudioFocusListener = new AudioManager.OnAudioFocusChangeListener() {
public void onAudioFocusChange(int focusChange) {
switch (focusChange) {
case AudioManager.AUDIOFOCUS_GAIN: // 之前的音量 1
if (mAudioManager != null)
mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC,
(int) (mMaxVolum * 0.8), 0);
if (mIsLossAutioFocus) {
weDriveResume();
mIsLossAutioFocus = false;
}
break;

case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK: // 降音处理 -3
if (mAudioManager != null)
mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC,
(int) (mMaxVolum * 0.3), 0);
break;

case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT: // 失去音频焦点 暂停播放 -2
mIsLossAutioFocus = true;
weDrivePause();
break;

case AudioManager.AUDIOFOCUS_LOSS: // -1
// weDrivePause();
break;

default:
break;
}
}
};
//   请求焦点
mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

if (mAudioManager != null)
    mAudioManager.requestAudioFocus(mAudioFocusListener,AudioManager.STREAM_MUSIC,AudioManager.AUDIOFOCUS_GAIN);

// 放弃焦点
if (mAudioManager != null)
mAudioManager.abandonAudioFocus(mAudioFocusListener);

车载系统 降噪处理

标签:

原文地址:http://www.cnblogs.com/wutianlong/p/5730192.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!