mt6735 如何做到在静音模式下音乐也被静音?
时间:10-02
整理:3721RD
点击:
[DESCRIPTION]
当情景模式切换到静音模式时,需要把音乐以及游戏音也同时做静音处理。
[SOLUTION]
1.请修改AudioService.java中的readPersistedSettings()函数中的如下这段code:将:
if(mVoiceCapable){
mRingerModeAffectedStreams &=~(1<<AudioSystem.STREAM_MUSIC);
}else{
mRingerModeAffectedStreams |=(1<<AudioSystem.STREAM_MUSIC);
}
替换为:
mRingerModeAffectedStreams |=(1<<AudioSystem.STREAM_MUSIC);
2.在AudioService.java的函数 public void adjustStreamVolume(int streamType, int direction, int flags)中有如下这么一段code:
...
// If either the CLIent forces allowing ringer modes for this adjustment,
// or the stream type is one that is affected by ringer modes
if (((flags & AudioManager.FLAG_ALLOW_RINGER_MODES) != 0) ||
(streamTypeAlias == getMasterStreamType())) {
int ringerMode = getRingerMode();
// do not vibrate if already in vibrate mode
...
请在这个if判断中按照如下方法增加一个判断条件改为:
...
// If either the client forces allowing ringer modes for this adjustment,
// or the stream type is one that is affected by ringer modes
if (((flags & AudioManager.FLAG_ALLOW_RINGER_MODES) != 0) ||
(streamTypeAlias == getMasterStreamType())||
(streamType == AudioSystem.STREAM_MUSIC)) {
int ringerMode = getRingerMode();
// do not vibrate if already in vibrate mode
...
这样修改后的效果是:
1.当系统切到静音或者震动模式时,MUSIC的会被mute,如果此时调整music的音量:
Case 1:若当前处在静音模式,第一次调节music音量会切换到震动模式,music仍被mute;
case 2:若当前处在震动模式,第一次调大Music两会切换到normal 模式,music被unmute,可以调节音量;
case 3:若情景模式切换到outdoor模式,则音乐音量会被设定为最大音量;
2.当系统为normal 模式时,播放音乐的过程中,调低music的音量,当music的音量调到0level时,会首先将系统切换到震动模式,继续调低音量会切换到静音模式。
当情景模式切换到静音模式时,需要把音乐以及游戏音也同时做静音处理。
[SOLUTION]
1.请修改AudioService.java中的readPersistedSettings()函数中的如下这段code:将:
if(mVoiceCapable){
mRingerModeAffectedStreams &=~(1<<AudioSystem.STREAM_MUSIC);
}else{
mRingerModeAffectedStreams |=(1<<AudioSystem.STREAM_MUSIC);
}
替换为:
mRingerModeAffectedStreams |=(1<<AudioSystem.STREAM_MUSIC);
2.在AudioService.java的函数 public void adjustStreamVolume(int streamType, int direction, int flags)中有如下这么一段code:
...
// If either the CLIent forces allowing ringer modes for this adjustment,
// or the stream type is one that is affected by ringer modes
if (((flags & AudioManager.FLAG_ALLOW_RINGER_MODES) != 0) ||
(streamTypeAlias == getMasterStreamType())) {
int ringerMode = getRingerMode();
// do not vibrate if already in vibrate mode
...
请在这个if判断中按照如下方法增加一个判断条件改为:
...
// If either the client forces allowing ringer modes for this adjustment,
// or the stream type is one that is affected by ringer modes
if (((flags & AudioManager.FLAG_ALLOW_RINGER_MODES) != 0) ||
(streamTypeAlias == getMasterStreamType())||
(streamType == AudioSystem.STREAM_MUSIC)) {
int ringerMode = getRingerMode();
// do not vibrate if already in vibrate mode
...
这样修改后的效果是:
1.当系统切到静音或者震动模式时,MUSIC的会被mute,如果此时调整music的音量:
Case 1:若当前处在静音模式,第一次调节music音量会切换到震动模式,music仍被mute;
case 2:若当前处在震动模式,第一次调大Music两会切换到normal 模式,music被unmute,可以调节音量;
case 3:若情景模式切换到outdoor模式,则音乐音量会被设定为最大音量;
2.当系统为normal 模式时,播放音乐的过程中,调低music的音量,当music的音量调到0level时,会首先将系统切换到震动模式,继续调低音量会切换到静音模式。