本文整理汇总了Java中android.media.AudioManager.setMode方法的典型用法代码示例。如果您正苦于以下问题:Java AudioManager.setMode方法的具体用法?Java AudioManager.setMode怎么用?Java AudioManager.setMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.AudioManager
的用法示例。
在下文中一共展示了AudioManager.setMode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startOutgoingRinger
import android.media.AudioManager; //导入方法依赖的package包/类
public void startOutgoingRinger(OutgoingRinger.Type type) {
AudioManager audioManager = ServiceUtil.getAudioManager(context);
audioManager.setMicrophoneMute(false);
if (type == OutgoingRinger.Type.SONAR) {
audioManager.setSpeakerphoneOn(false);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
} else {
audioManager.setMode(AudioManager.MODE_IN_CALL);
}
outgoingRinger.start(type);
}
示例2: stop
import android.media.AudioManager; //导入方法依赖的package包/类
public void stop(boolean playDisconnected) {
AudioManager audioManager = ServiceUtil.getAudioManager(context);
incomingRinger.stop();
outgoingRinger.stop();
if (playDisconnected) {
soundPool.play(disconnectedSoundId, 1.0f, 1.0f, 0, 0, 1.0f);
}
if (audioManager.isBluetoothScoOn()) {
audioManager.setBluetoothScoOn(false);
audioManager.stopBluetoothSco();
}
audioManager.setSpeakerphoneOn(false);
audioManager.setMicrophoneMute(false);
audioManager.setMode(AudioManager.MODE_NORMAL);
audioManager.abandonAudioFocus(null);
}
示例3: execute
import android.media.AudioManager; //导入方法依赖的package包/类
@Override
public void execute(AudioManager audioManager) {
if (voiceMediator.isBlueToothHeadSet()) {
if (!voiceMediator.isSuportA2DP()) {
if (audioManager.getMode() != AudioManager.MODE_NORMAL) {
Log.e(TAG, "playInChannel>>setMode(AudioManager.MODE_NORMAL)");
audioManager.setMode(AudioManager.MODE_NORMAL);
}
if (audioManager.isBluetoothScoOn()) {
audioManager.setBluetoothScoOn(false);
audioManager.stopBluetoothSco();
}
} else {
if (!audioManager.isBluetoothA2dpOn()) {
Log.e(TAG, "playInChannel>>setBluetoothA2dpOn(true)");
audioManager.setBluetoothA2dpOn(true);
}
}
}
}
示例4: switchSpeaker
import android.media.AudioManager; //导入方法依赖的package包/类
/**
* 扬声器开关
* @param context
* @param enableSpeaker 是否打开扬声器,true:打开,false:关闭
*/
public static void switchSpeaker(Context context, boolean enableSpeaker) {
try {
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
audioManager.setMode(AudioManager.ROUTE_SPEAKER);
int currVolume = audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL);
if (enableSpeaker) {
//setSpeakerphoneOn() only work when audio mode set to MODE_IN_CALL.
audioManager.setMode(AudioManager.MODE_IN_CALL);
audioManager.setSpeakerphoneOn(true);
audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL,
audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL),
AudioManager.STREAM_VOICE_CALL);
} else {
audioManager.setSpeakerphoneOn(false);
audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, currVolume,
AudioManager.STREAM_VOICE_CALL);
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例5: startIncomingRinger
import android.media.AudioManager; //导入方法依赖的package包/类
public void startIncomingRinger() {
AudioManager audioManager = ServiceUtil.getAudioManager(context);
boolean speaker = !audioManager.isWiredHeadsetOn() && !audioManager.isBluetoothScoOn();
audioManager.setMode(AudioManager.MODE_RINGTONE);
audioManager.setMicrophoneMute(false);
audioManager.setSpeakerphoneOn(speaker);
incomingRinger.start();
}
示例6: startOutgoingRinger
import android.media.AudioManager; //导入方法依赖的package包/类
public void startOutgoingRinger(OutgoingRinger.Type type) {
AudioManager audioManager = ServiceUtil.getAudioManager(context);
audioManager.setMicrophoneMute(false);
if (type == OutgoingRinger.Type.SONAR) {
audioManager.setSpeakerphoneOn(false);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
} else {
audioManager.setMode(AudioManager.MODE_IN_CALL);
}
outgoingRinger.start(type);
}
示例7: startCommunication
import android.media.AudioManager; //导入方法依赖的package包/类
public void startCommunication(boolean preserveSpeakerphone) {
AudioManager audioManager = ServiceUtil.getAudioManager(context);
incomingRinger.stop();
outgoingRinger.stop();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
} else {
audioManager.setMode(AudioManager.MODE_IN_CALL);
}
if (!preserveSpeakerphone) {
audioManager.setSpeakerphoneOn(false);
}
soundPool.play(connectedSoundId, 1.0f, 1.0f, 0, 0, 1.0f);
}
示例8: stop
import android.media.AudioManager; //导入方法依赖的package包/类
public void stop(boolean playDisconnected) {
AudioManager audioManager = ServiceUtil.getAudioManager(context);
incomingRinger.stop();
outgoingRinger.stop();
if (playDisconnected) {
soundPool.play(disconnectedSoundId, 1.0f, 1.0f, 0, 0, 1.0f);
}
if (audioManager.isBluetoothScoOn()) {
audioManager.setBluetoothScoOn(false);
audioManager.stopBluetoothSco();
}
audioManager.setSpeakerphoneOn(false);
audioManager.setMicrophoneMute(false);
audioManager.setMode(AudioManager.MODE_NORMAL);
audioManager.abandonAudioFocus(null);
}
示例9: enableVocieMode
import android.media.AudioManager; //导入方法依赖的package包/类
public static void enableVocieMode() {
AudioManager audioManager = (AudioManager) App.getInstance().getSystemService(Context.AUDIO_SERVICE);
if (Options.getInstance().audio.aec) {
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
audioManager.setSpeakerphoneOn(true);
} else {
audioManager.setMode(AudioManager.MODE_NORMAL);
audioManager.setSpeakerphoneOn(false);
}
}
示例10: startIncomingRinger
import android.media.AudioManager; //导入方法依赖的package包/类
public void startIncomingRinger() {
AudioManager audioManager = ServiceUtil.getAudioManager(context);
boolean speaker = !audioManager.isWiredHeadsetOn() && !audioManager.isBluetoothScoOn();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
} else {
audioManager.setMode(AudioManager.MODE_IN_CALL);
}
audioManager.setMicrophoneMute(false);
audioManager.setSpeakerphoneOn(speaker);
incomingRinger.start(speaker);
}
示例11: setDefaultSynthesizerParam
import android.media.AudioManager; //导入方法依赖的package包/类
/**
* 设置默认的合成引擎
*
* @param type
*/
private void setDefaultSynthesizerParam(NetType type) {
if (isSpeaking()) {
Log.e(TAG, "播放当中切换播放引擎失败");
return;
}
synthesizer.setParameter(SpeechConstant.SPEED, Integer.toString(mVoiceConfig.getVolSpeed()));
synthesizer.setParameter(SpeechConstant.VOLUME, Integer.toString(mVoiceConfig.getVolume()));
synthesizer.setParameter(SpeechConstant.VOICE_NAME, mVoiceConfig.getVolName());
synthesizer.setParameter("rdn", "0");
synthesizer.setParameter(SpeechConstant.KEY_REQUEST_FOCUS, "0");
if (mediator.isBlueToothHeadSet()) {
synthesizer.setParameter(SpeechConstant.STREAM_TYPE, Integer.toString(AudioManager.STREAM_VOICE_CALL));
} else {
synthesizer.setParameter(SpeechConstant.STREAM_TYPE, Integer.toString(AudioManager.STREAM_MUSIC));
AudioManager am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
if (am.getMode() != AudioManager.MODE_NORMAL) {
am.setMode(AudioManager.MODE_NORMAL);
}
}
//synthesizer.setParameter(SpeechConstant.ENGINE_TYPE, VoiceConfig.getSynEngineType());
/*if(type==NetType.NETWORK_TYPE_NONE||type==NetType.NETWORK_TYPE_2G){//网络关闭的状态下启动离线识别
Log.e(TAG, "离线。。。。。。。。。。。。。。。。。。。");
synthesizer.setParameter(SpeechConstant.SPEED, OFFLINE_ENGINE_SPPED);
synthesizer.setParameter(SpeechConstant.ENGINE_TYPE, SpeechConstant.TYPE_LOCAL);
synthesizer.setParameter(SpeechConstant.VOICE_NAME, "xiaoyan");
isLocalEngine=true;
}
else{*/
Log.e(TAG, "在线。。。。。。。。。。。。。。。。。。。");
//synthesizer.setParameter(SpeechConstant.SPEED,"70");
synthesizer.setParameter(SpeechConstant.VOICE_NAME, mVoiceConfig.getVolName());
//synthesizer.setParameter(SpeechConstant.VOICE_NAME, ChatRobot.isInit()&&ChatRobot.getInstance().getMode()==ChatConstant.CHILDREN_MODE?"vinn":"vixq");
synthesizer.setParameter(SpeechConstant.ENGINE_TYPE, SpeechConstant.TYPE_CLOUD);
//}
}
示例12: startRinging
import android.media.AudioManager; //导入方法依赖的package包/类
/**
* @param audioManager
*
*/
public void startRinging(AudioManager audioManager) {
if(ringtone != null) {
Log.d(THIS_FILE, "Starting ring with " + ringtone.getTitle(context));
Message msg = ringerWorker.obtainMessage(RingWorkerHandler.PROGRESS_RING);
msg.arg1 = RingWorkerHandler.PROGRESS_RING;
Log.d(THIS_FILE, "Starting ringer...");
audioManager.setMode(AudioManager.MODE_RINGTONE);
ringerWorker.sendMessage(msg);
}
}
示例13: audioOnSpeakers
import android.media.AudioManager; //导入方法依赖的package包/类
@ProtoMethod(description = "Routes the audio through the speakers", example = "media.playSound(fileName);")
@ProtoMethodParam(params = {""})
public void audioOnSpeakers(boolean b) {
AudioManager audioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
audioManager.setMode(AudioManager.MODE_IN_CALL);
audioManager.setSpeakerphoneOn(!b);
}
示例14: setAudioMode
import android.media.AudioManager; //导入方法依赖的package包/类
public void setAudioMode(int mode,Context ctx) {
if (mode != AudioManager.MODE_NORMAL && mode != AudioManager.MODE_IN_CALL) {
return;
}
AudioManager audioManager = (AudioManager) ctx.getSystemService(Context.AUDIO_SERVICE);
audioManager.setMode(mode);
}
示例15: disableVoiceMode
import android.media.AudioManager; //导入方法依赖的package包/类
public static void disableVoiceMode(){
AudioManager audioManager = (AudioManager) App.getInstance().getSystemService(Context.AUDIO_SERVICE);
audioManager.setMode(AudioManager.MODE_NORMAL);
audioManager.setSpeakerphoneOn(false);
}