Skip to content

Commit 67c0cfb

Browse files
author
xia ning
authored
Merge pull request #199 from oOJohn6Oo/fixSwitch
[BGF] Improve the feature of switch between earpiece and speaker when play audio.
2 parents 5428e73 + 494fd11 commit 67c0cfb

13 files changed

Lines changed: 15 additions & 18 deletions

Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/AdjustVolume.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
6969
mute.setOnClickListener(this);
7070
speaker = view.findViewById(R.id.btn_speaker);
7171
speaker.setOnClickListener(this);
72+
speaker.setActivated(true);
7273
record = view.findViewById(R.id.recordingVol);
7374
playout = view.findViewById(R.id.playoutVol);
7475
inear = view.findViewById(R.id.inEarMonitorVol);
@@ -221,9 +222,9 @@ public void onClick(View v) {
221222
engine.muteLocalAudioStream(mute.isActivated());
222223
} else if (v.getId() == R.id.btn_speaker) {
223224
speaker.setActivated(!speaker.isActivated());
224-
speaker.setText(getString(speaker.isActivated() ? R.string.earpiece : R.string.speaker));
225+
speaker.setText(getString(speaker.isActivated() ? R.string.speaker : R.string.earpiece));
225226
/**Turn off / on the speaker and change the audio playback route.*/
226-
engine.setEnableSpeakerphone(speaker.isActivated());
227+
engine.setDefaultAudioRoutetoSpeakerphone(speaker.isActivated());
227228
}
228229
}
229230

Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/CustomRemoteVideoRender.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ private void joinChannel(String channelId) {
223223
engine.setupLocalVideo(new VideoCanvas(surfaceView, RENDER_MODE_HIDDEN, 0));
224224
/**Set up to play remote sound with receiver*/
225225
engine.setDefaultAudioRoutetoSpeakerphone(true);
226-
engine.setEnableSpeakerphone(true);
227226

228227
engine.registerVideoFrameObserver(videoFrameObserver);
229228
/**In the demo, the default is to enter as the anchor.*/

Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/PlayAudioFiles.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
7575
mute.setOnClickListener(this);
7676
speaker = view.findViewById(R.id.btn_speaker);
7777
speaker.setOnClickListener(this);
78+
speaker.setActivated(true);
7879
bgm = view.findViewById(R.id.btn_bgm);
7980
bgm.setOnClickListener(this);
8081
effect = view.findViewById(R.id.btn_effect);
@@ -242,9 +243,9 @@ else if (v.getId() == R.id.microphone)
242243
else if (v.getId() == R.id.btn_speaker)
243244
{
244245
speaker.setActivated(!speaker.isActivated());
245-
speaker.setText(getString(speaker.isActivated() ? R.string.earpiece : R.string.speaker));
246+
speaker.setText(getString(speaker.isActivated() ? R.string.speaker : R.string.earpiece));
246247
/**Turn off / on the speaker and change the audio playback route.*/
247-
engine.setEnableSpeakerphone(speaker.isActivated());
248+
engine.setDefaultAudioRoutetoSpeakerphone(speaker.isActivated());
248249
}
249250
else if(v.getId() == R.id.btn_bgm)
250251
{

Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/ProcessAudioRawData.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
142142
mute.setOnClickListener(this);
143143
speaker = view.findViewById(R.id.btn_speaker);
144144
speaker.setOnClickListener(this);
145+
speaker.setActivated(true);
145146
writeBackAudio = view.findViewById(R.id.writebackAudio);
146147
writeBackAudio.setOnCheckedChangeListener(this);
147148
record = view.findViewById(R.id.recordingVol);
@@ -266,9 +267,9 @@ public void onClick(View v) {
266267
engine.muteLocalAudioStream(mute.isActivated());
267268
} else if (v.getId() == R.id.btn_speaker) {
268269
speaker.setActivated(!speaker.isActivated());
269-
speaker.setText(getString(speaker.isActivated() ? R.string.earpiece : R.string.speaker));
270+
speaker.setText(getString(speaker.isActivated() ? R.string.speaker : R.string.earpiece));
270271
/**Turn off / on the speaker and change the audio playback route.*/
271-
engine.setEnableSpeakerphone(speaker.isActivated());
272+
engine.setDefaultAudioRoutetoSpeakerphone(speaker.isActivated());
272273
}
273274
}
274275

Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/ProcessRawData.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ private void joinChannel(String channelId) {
209209
));
210210
/**Set up to play remote sound with receiver*/
211211
engine.setDefaultAudioRoutetoSpeakerphone(true);
212-
engine.setEnableSpeakerphone(true);
213212

214213
int ret = engine.registerVideoFrameObserver(iVideoFrameObserver);
215214
// Enable video module should be after calling registerVideoFrameObserver

Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/PushExternalVideo.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ private void joinChannel(String channelId) {
223223
ViewGroup.LayoutParams.MATCH_PARENT));
224224
/**Set up to play remote sound with receiver*/
225225
engine.setDefaultAudioRoutetoSpeakerphone(true);
226-
engine.setEnableSpeakerphone(true);
227226

228227
/**In the demo, the default is to enter as the anchor.*/
229228
engine.setClientRole(IRtcEngineEventHandler.ClientRole.CLIENT_ROLE_BROADCASTER);

Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/RTMPStreaming.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ private void joinChannel(String channelId)
237237
));
238238
/**Set up to play remote sound with receiver*/
239239
engine.setDefaultAudioRoutetoSpeakerphone(true);
240-
engine.setEnableSpeakerphone(true);
241240

242241
/**Please configure accessToken in the string_config file.
243242
* A temporary token generated in Console. A temporary token is valid for 24 hours. For details, see

Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/SendDataStream.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ private void joinChannel(String channelId)
230230
));
231231
/**Set up to play remote sound with receiver*/
232232
engine.setDefaultAudioRoutetoSpeakerphone(true);
233-
engine.setEnableSpeakerphone(true);
234233

235234
/**Please configure accessToken in the string_config file.
236235
* A temporary token generated in Console. A temporary token is valid for 24 hours. For details, see

Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/SetAudioProfile.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
7474
mute.setOnClickListener(this);
7575
speaker = view.findViewById(R.id.btn_speaker);
7676
speaker.setOnClickListener(this);
77+
speaker.setActivated(true);
7778
}
7879

7980
@Override
@@ -199,9 +200,9 @@ else if (v.getId() == R.id.microphone)
199200
else if (v.getId() == R.id.btn_speaker)
200201
{
201202
speaker.setActivated(!speaker.isActivated());
202-
speaker.setText(getString(speaker.isActivated() ? R.string.earpiece : R.string.speaker));
203+
speaker.setText(getString(speaker.isActivated() ? R.string.speaker : R.string.earpiece));
203204
/**Turn off / on the speaker and change the audio playback route.*/
204-
engine.setEnableSpeakerphone(speaker.isActivated());
205+
engine.setDefaultAudioRoutetoSpeakerphone(speaker.isActivated());
205206
}
206207
}
207208

Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/SwitchCameraScreenShare.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ private void joinChannel(String channelId) {
359359
));
360360
/**Set up to play remote sound with receiver*/
361361
engine.setDefaultAudioRoutetoSpeakerphone(true);
362-
engine.setEnableSpeakerphone(true);
363362

364363
/**Please configure accessToken in the string_config file.
365364
* A temporary token generated in Console. A temporary token is valid for 24 hours. For details, see

0 commit comments

Comments
 (0)