Skip to content

Commit 18515f2

Browse files
authored
Merge pull request #348 from AgoraIO/dev/4.2.1
Dev/4.2.2
2 parents 188fa99 + c1ee2b5 commit 18515f2

File tree

302 files changed

+13955
-7205
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

302 files changed

+13955
-7205
lines changed

Android/APIExample-Audio/app/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ dependencies {
4848
implementation fileTree(dir: "${localSdkPath}", include: ['*.jar', '*.aar'])
4949
}
5050
else{
51-
def agora_sdk_version = "4.2.1"
51+
def agora_sdk_version = "4.2.2"
5252
// case 1: full single lib with voice only
5353
implementation "io.agora.rtc:voice-sdk:${agora_sdk_version}"
5454
// case 2: partial libs with voice only

Android/APIExample-Audio/app/src/main/java/io/agora/api/example/common/BaseFragment.java

+11
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ protected final void showLongToast(final String msg)
5454
});
5555
}
5656

57+
protected final void showShortToast(final String msg)
58+
{
59+
runOnUIThread(() -> {
60+
Context context = getContext();
61+
if(context == null){
62+
return;
63+
}
64+
Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
65+
});
66+
}
67+
5768
protected final void runOnUIThread(Runnable runnable){
5869
this.runOnUIThread(runnable, 0);
5970
}

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public void onDestroy()
235235
@Override
236236
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
237237
if (parent == audioScenario) {
238-
engine.setAudioScenario(Constants.AudioScenario.valueOf(audioScenario.getSelectedItem().toString()).ordinal());
238+
engine.setAudioScenario(Constants.AudioScenario.getValue(Constants.AudioScenario.valueOf(audioScenario.getSelectedItem().toString())));
239239
}
240240
}
241241

@@ -356,8 +356,8 @@ private void joinChannel(String channelId)
356356
/**In the demo, the default is to enter as the anchor.*/
357357
engine.setClientRole(Constants.CLIENT_ROLE_BROADCASTER);
358358
engine.setAudioProfile(
359-
Constants.AudioProfile.valueOf(audioProfile.getSelectedItem().toString()).ordinal(),
360-
Constants.AudioScenario.valueOf(audioScenario.getSelectedItem().toString()).ordinal()
359+
Constants.AudioProfile.getValue(Constants.AudioProfile.valueOf(audioProfile.getSelectedItem().toString())),
360+
Constants.AudioScenario.getValue(Constants.AudioScenario.valueOf(audioScenario.getSelectedItem().toString()))
361361
);
362362

363363
/**Please configure accessToken in the string_config file.

Android/APIExample-Audio/app/src/main/java/io/agora/api/example/examples/advanced/VoiceEffects.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ private void joinChannel(String channelId) {
384384
engine.setClientRole(Constants.CLIENT_ROLE_BROADCASTER);
385385
// audio config
386386
engine.setAudioProfile(
387-
Constants.AudioProfile.valueOf(audioProfile.getSelectedItem().toString()).ordinal(),
388-
Constants.AudioScenario.valueOf(audioScenario.getSelectedItem().toString()).ordinal()
387+
Constants.AudioProfile.getValue(Constants.AudioProfile.valueOf(audioProfile.getSelectedItem().toString())),
388+
Constants.AudioScenario.getValue(Constants.AudioScenario.valueOf(audioScenario.getSelectedItem().toString()))
389389
);
390390

391391
/**Please configure accessToken in the string_config file.
@@ -566,7 +566,7 @@ public void onItemSelected(AdapterView<?> parent, View view, int position, long
566566
}
567567

568568
if (parent == audioScenario) {
569-
engine.setAudioScenario(Constants.AudioScenario.valueOf(audioScenario.getSelectedItem().toString()).ordinal());
569+
engine.setAudioScenario(Constants.AudioScenario.getValue(Constants.AudioScenario.valueOf(audioScenario.getSelectedItem().toString())));
570570
return;
571571
}
572572

Android/APIExample-Audio/app/src/main/java/io/agora/api/example/examples/basic/JoinChannelAudio.java

+145-96
Large diffs are not rendered by default.

Android/APIExample-Audio/app/src/main/java/io/agora/api/example/examples/basic/JoinChannelAudioByToken.java

+1-123
Original file line numberDiff line numberDiff line change
@@ -46,51 +46,13 @@
4646
public class JoinChannelAudioByToken extends BaseFragment implements View.OnClickListener
4747
{
4848
private static final String TAG = JoinChannelAudioByToken.class.getSimpleName();
49-
private Spinner audioProfileInput;
50-
private Spinner audioScenarioInput;
5149
private EditText et_app_id, et_channel, et_token;
52-
private Button mute, join, speaker;
53-
private SeekBar record, playout, inear;
54-
private Switch inEarSwitch;
50+
private Button join;
5551
private RtcEngine engine;
5652
private int myUid;
5753
private boolean joined = false;
5854
private AudioSeatManager audioSeatManager;
5955

60-
private SeekBar.OnSeekBarChangeListener seekBarChangeListener = new SeekBar.OnSeekBarChangeListener() {
61-
@Override
62-
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
63-
if(engine == null){
64-
return;
65-
}
66-
if(seekBar.getId() == record.getId()){
67-
engine.adjustRecordingSignalVolume(progress);
68-
}
69-
else if(seekBar.getId() == playout.getId()){
70-
engine.adjustPlaybackSignalVolume(progress);
71-
}
72-
else if(seekBar.getId() == inear.getId()){
73-
if(progress == 0){
74-
engine.enableInEarMonitoring(false);
75-
}
76-
else {
77-
engine.enableInEarMonitoring(true);
78-
engine.setInEarMonitoringVolume(progress);
79-
}
80-
}
81-
}
82-
83-
@Override
84-
public void onStartTrackingTouch(SeekBar seekBar) {
85-
86-
}
87-
88-
@Override
89-
public void onStopTrackingTouch(SeekBar seekBar) {
90-
91-
}
92-
};
93-
9456
@Override
9557
public void onCreate(@Nullable Bundle savedInstanceState)
9658
{
@@ -114,47 +76,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
11476
et_app_id = view.findViewById(R.id.et_app_id);
11577
et_channel = view.findViewById(R.id.et_channel);
11678
et_token = view.findViewById(R.id.et_token);
117-
audioProfileInput = view.findViewById(R.id.audio_profile_spinner);
118-
audioScenarioInput = view.findViewById(R.id.audio_scenario_spinner);
119-
audioScenarioInput.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
120-
@Override
121-
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
122-
if(joined){
123-
int scenario = Constants.AudioScenario.valueOf(audioScenarioInput.getSelectedItem().toString()).ordinal();
124-
engine.setAudioScenario(scenario);
125-
}
126-
}
127-
128-
@Override
129-
public void onNothingSelected(AdapterView<?> parent) {
130-
131-
}
132-
});
13379
view.findViewById(R.id.btn_join).setOnClickListener(this);
134-
mute = view.findViewById(R.id.microphone);
135-
mute.setOnClickListener(this);
136-
speaker = view.findViewById(R.id.btn_speaker);
137-
speaker.setOnClickListener(this);
138-
speaker.setActivated(true);
139-
record = view.findViewById(R.id.recordingVol);
140-
playout = view.findViewById(R.id.playoutVol);
141-
inear = view.findViewById(R.id.inEarMonitorVol);
142-
record.setOnSeekBarChangeListener(seekBarChangeListener);
143-
playout.setOnSeekBarChangeListener(seekBarChangeListener);
144-
inear.setOnSeekBarChangeListener(seekBarChangeListener);
145-
inEarSwitch = view.findViewById(R.id.inEarMonitorSwitch);
146-
inEarSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
147-
if(engine == null){
148-
return;
149-
}
150-
engine.enableInEarMonitoring(isChecked);
151-
inear.setEnabled(isChecked);
152-
});
153-
record.setEnabled(false);
154-
playout.setEnabled(false);
155-
inear.setEnabled(false);
156-
inEarSwitch.setEnabled(false);
157-
15880
audioSeatManager = new AudioSeatManager(
15981
view.findViewById(R.id.audio_place_01),
16082
view.findViewById(R.id.audio_place_02),
@@ -189,7 +111,6 @@ private boolean createRtcEngine(String appId) {
189111
* The SDK uses this class to report to the app on SDK runtime events.
190112
*/
191113
config.mEventHandler = iRtcEngineEventHandler;
192-
config.mAudioScenario = Constants.AudioScenario.valueOf(audioScenarioInput.getSelectedItem().toString()).ordinal();
193114
config.mAreaCode = ((MainApplication)getActivity().getApplication()).getGlobalSettings().getAreaCode();
194115
engine = RtcEngine.create(config);
195116
/**
@@ -254,47 +175,16 @@ public void onClick(View v)
254175

255176
if (createRtcEngine(appId)) {
256177
joinChannel(channelId, token);
257-
audioProfileInput.setEnabled(false);
258178
}
259179
}
260180
else
261181
{
262182
joined = false;
263183
join.setText(getString(R.string.join));
264-
speaker.setText(getString(R.string.speaker));
265-
speaker.setEnabled(false);
266-
mute.setText(getString(R.string.closemicrophone));
267-
mute.setEnabled(false);
268-
audioProfileInput.setEnabled(true);
269-
record.setEnabled(false);
270-
playout.setEnabled(false);
271-
inear.setEnabled(false);
272-
inEarSwitch.setEnabled(false);
273-
inEarSwitch.setChecked(false);
274184
audioSeatManager.downAllSeats();
275185
destroyRtcEngine();
276186
}
277187
}
278-
else if (v.getId() == R.id.microphone)
279-
{
280-
if(engine == null){
281-
return;
282-
}
283-
mute.setActivated(!mute.isActivated());
284-
mute.setText(getString(mute.isActivated() ? R.string.openmicrophone : R.string.closemicrophone));
285-
/**Turn off / on the microphone, stop / start local audio collection and push streaming.*/
286-
engine.muteLocalAudioStream(mute.isActivated());
287-
}
288-
else if (v.getId() == R.id.btn_speaker)
289-
{
290-
if(engine == null){
291-
return;
292-
}
293-
speaker.setActivated(!speaker.isActivated());
294-
speaker.setText(getString(speaker.isActivated() ? R.string.speaker : R.string.earpiece));
295-
/**Turn off / on the speaker and change the audio playback route.*/
296-
engine.setEnableSpeakerphone(speaker.isActivated());
297-
}
298188
}
299189

300190
/**
@@ -305,12 +195,6 @@ private void joinChannel(String channelId, String token)
305195
/**In the demo, the default is to enter as the anchor.*/
306196
engine.setClientRole(Constants.CLIENT_ROLE_BROADCASTER);
307197

308-
int profile = Constants.AudioProfile.valueOf(audioProfileInput.getSelectedItem().toString()).ordinal();
309-
engine.setAudioProfile(profile);
310-
311-
int scenario = Constants.AudioScenario.valueOf(audioScenarioInput.getSelectedItem().toString()).ordinal();
312-
engine.setAudioScenario(scenario);
313-
314198
engine.setDefaultAudioRoutetoSpeakerphone(true);
315199

316200
ChannelMediaOptions option = new ChannelMediaOptions();
@@ -387,14 +271,8 @@ public void onJoinChannelSuccess(String channel, int uid, int elapsed)
387271
@Override
388272
public void run()
389273
{
390-
speaker.setEnabled(true);
391-
mute.setEnabled(true);
392274
join.setEnabled(true);
393275
join.setText(getString(R.string.leave));
394-
record.setEnabled(true);
395-
playout.setEnabled(true);
396-
inear.setEnabled(inEarSwitch.isChecked());
397-
inEarSwitch.setEnabled(true);
398276
audioSeatManager.upLocalSeat(uid);
399277
}
400278
});

0 commit comments

Comments
 (0)