From c6b409eed598dd41fed5b9f890a61f2ee988e30e Mon Sep 17 00:00:00 2001 From: xianing Date: Tue, 2 Nov 2021 20:09:41 +0800 Subject: [PATCH 1/3] fix regression issues --- .../api/example/examples/advanced/PlayAudioFiles.java | 10 ++++++++-- .../Advanced/CustomAudioRender/CustomAudioRender.swift | 10 ++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/PlayAudioFiles.java b/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/PlayAudioFiles.java index a87575ef1..421429755 100644 --- a/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/PlayAudioFiles.java +++ b/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/PlayAudioFiles.java @@ -22,6 +22,8 @@ import com.yanzhenjie.permission.AndPermission; import com.yanzhenjie.permission.runtime.Permission; +import java.text.SimpleDateFormat; + import io.agora.api.component.Constant; import io.agora.api.example.R; import io.agora.api.example.annotation.Example; @@ -200,6 +202,7 @@ public void onDestroy() /**leaveChannel and Destroy the RtcEngine instance*/ if(engine != null) { + stopProgressTimer(); engine.leaveChannel(); } handler.post(RtcEngine::destroy); @@ -267,11 +270,12 @@ else if(v.getId() == R.id.bgmStart) { sliderSpeed.setProgress(50); engine.startAudioMixing(currentMusic, false, false, -1, 0); - engine.getAudioFileInfo(currentMusic); startProgressTimer(); } else if(v.getId() == R.id.bgmStop){ engine.stopAudioMixing(); + progressText.setText("00:00"); + mixingProgressBar.setProgress(0); stopProgressTimer(); } else if(v.getId() == R.id.bgmResume){ @@ -327,7 +331,9 @@ private void stopProgressTimer() { } private void startProgressTimer() { - final int result = (int) ((float) engine.getAudioMixingCurrentPosition() / (float) engine.getAudioFileInfo(Constant.URL_PLAY_AUDIO_FILES) * 100); + String timeString = new SimpleDateFormat("mm:ss").format(engine.getAudioMixingDuration()); + progressText.setText(timeString); + final int result = (int) ((float) engine.getAudioMixingCurrentPosition() / (float) engine.getAudioMixingDuration() * 100); mixingProgressBar.setProgress(Long.valueOf(result).intValue()); handler.postDelayed(this::startProgressTimer, 500); } diff --git a/macOS/APIExample/Examples/Advanced/CustomAudioRender/CustomAudioRender.swift b/macOS/APIExample/Examples/Advanced/CustomAudioRender/CustomAudioRender.swift index 31d2e06de..b9c4bee34 100644 --- a/macOS/APIExample/Examples/Advanced/CustomAudioRender/CustomAudioRender.swift +++ b/macOS/APIExample/Examples/Advanced/CustomAudioRender/CustomAudioRender.swift @@ -157,8 +157,8 @@ class CustomAudioRender: BaseViewController { agoraKit.disableVideo() // set proxy configuration - let proxySetting = GlobalSettings.shared.proxySetting.selectedOption().value - agoraKit.setCloudProxy(AgoraCloudProxyType.init(rawValue: UInt(proxySetting)) ?? .noneProxy) +// let proxySetting = GlobalSettings.shared.proxySetting.selectedOption().value +// agoraKit.setCloudProxy(AgoraCloudProxyType.init(rawValue: UInt(proxySetting)) ?? .noneProxy) // set live broadcaster mode agoraKit.setChannelProfile(.liveBroadcasting) @@ -167,10 +167,8 @@ class CustomAudioRender: BaseViewController { // setup external audio source exAudio.setupExternalAudio(withAgoraKit: agoraKit, sampleRate: UInt32(sampleRate), channels: UInt32(audioChannel), audioCRMode: .sdkCaptureExterRender, ioType: .remoteIO) - // important!! this example is using onPlaybackAudioFrame to do custom rendering - // by default the audio output will still be processed by SDK hence below api call is mandatory to disable that behavior - agoraKit.setParameters("{\"che.audio.external_render\": true}") - agoraKit.setParameters("{\"che.audio.keep.audiosession\": true}") + + agoraKit.enableExternalAudioSink(sampleRate, channels: audioChannel) // start joining channel // 1. Users can only see each other after they join the From 760f69ad73c8e6de9544bbdf1b490fae1cfe0e7c Mon Sep 17 00:00:00 2001 From: xianing Date: Tue, 2 Nov 2021 23:22:44 +0800 Subject: [PATCH 2/3] fix regression issues --- .../examples/advanced/PlayAudioFiles.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/PlayAudioFiles.java b/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/PlayAudioFiles.java index 421429755..89144ec19 100644 --- a/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/PlayAudioFiles.java +++ b/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/PlayAudioFiles.java @@ -331,10 +331,9 @@ private void stopProgressTimer() { } private void startProgressTimer() { - String timeString = new SimpleDateFormat("mm:ss").format(engine.getAudioMixingDuration()); - progressText.setText(timeString); - final int result = (int) ((float) engine.getAudioMixingCurrentPosition() / (float) engine.getAudioMixingDuration() * 100); - mixingProgressBar.setProgress(Long.valueOf(result).intValue()); + engine.getAudioFileInfo(Constant.URL_PLAY_AUDIO_FILES); + int position = engine.getAudioMixingCurrentPosition(); + handler.post(()->mixingProgressBar.setProgress(position)); handler.postDelayed(this::startProgressTimer, 500); } /** @@ -513,8 +512,17 @@ public void onUserOffline(int uid, int reason) @Override public void onRequestAudioFileInfo(AudioFileInfo info, int error) { - Log.d(TAG, "onRequestAudioFileInfo: "+info.durationMs); - handler.post(()-> mixingProgressBar.setMax(info.durationMs)); + if(info.durationMs > 0 && progressText.getText().equals("00:00")) { + Log.d(TAG, "onRequestAudioFileInfo: "+info.durationMs); + handler.post(new Runnable() { + @Override + public void run() { + mixingProgressBar.setMax(info.durationMs); + String timeString = new SimpleDateFormat("mm:ss").format(info.durationMs); + progressText.setText(timeString); + } + }); + } } }; @@ -541,9 +549,6 @@ else if(seekBar.getId() == R.id.mixingVolBar){ * @param volume: Audio mixing volume. The value ranges between 0 and 100 (default). */ engine.adjustAudioMixingVolume(progress); - }else if(seekBar.getId() == R.id.mixingProgress){ - String durationText = io.agora.api.example.utils.TextUtils.durationFormat((long) progress); - progressText.setText(durationText); }else if(seekBar.getId() == R.id.slider_speed_fg_audio_file){ updateSpeedTitle(); } From dc90bd0cd3d8658ee31d76b4f00b1d0e4c5fbd7f Mon Sep 17 00:00:00 2001 From: xianing Date: Wed, 3 Nov 2021 10:56:18 +0800 Subject: [PATCH 3/3] fix regression issues --- .../examples/advanced/PlayAudioFiles.java | 34 ++++++++----------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/PlayAudioFiles.java b/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/PlayAudioFiles.java index 89144ec19..5ea177c56 100644 --- a/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/PlayAudioFiles.java +++ b/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/PlayAudioFiles.java @@ -22,8 +22,6 @@ import com.yanzhenjie.permission.AndPermission; import com.yanzhenjie.permission.runtime.Permission; -import java.text.SimpleDateFormat; - import io.agora.api.component.Constant; import io.agora.api.example.R; import io.agora.api.example.annotation.Example; @@ -202,7 +200,6 @@ public void onDestroy() /**leaveChannel and Destroy the RtcEngine instance*/ if(engine != null) { - stopProgressTimer(); engine.leaveChannel(); } handler.post(RtcEngine::destroy); @@ -270,12 +267,11 @@ else if(v.getId() == R.id.bgmStart) { sliderSpeed.setProgress(50); engine.startAudioMixing(currentMusic, false, false, -1, 0); + engine.getAudioFileInfo(currentMusic); startProgressTimer(); } else if(v.getId() == R.id.bgmStop){ engine.stopAudioMixing(); - progressText.setText("00:00"); - mixingProgressBar.setProgress(0); stopProgressTimer(); } else if(v.getId() == R.id.bgmResume){ @@ -327,15 +323,19 @@ else if (v.getId() == R.id.btn_effect) } private void stopProgressTimer() { + mixingProgressBar.setProgress(0); handler.removeCallbacksAndMessages(null); } private void startProgressTimer() { - engine.getAudioFileInfo(Constant.URL_PLAY_AUDIO_FILES); - int position = engine.getAudioMixingCurrentPosition(); - handler.post(()->mixingProgressBar.setProgress(position)); - handler.postDelayed(this::startProgressTimer, 500); + if(engine != null) { + int currentPosition = engine.getAudioMixingCurrentPosition(); + if (mixingProgressBar.getMax() != 0 && !mixingProgressBar.isPressed()) + mixingProgressBar.setProgress(currentPosition); + handler.postDelayed(this::startProgressTimer, 1000); + } } + /** * @param channelId Specify the channel name that you want to join. * Users that input the same channel name join the same channel.*/ @@ -512,17 +512,8 @@ public void onUserOffline(int uid, int reason) @Override public void onRequestAudioFileInfo(AudioFileInfo info, int error) { - if(info.durationMs > 0 && progressText.getText().equals("00:00")) { - Log.d(TAG, "onRequestAudioFileInfo: "+info.durationMs); - handler.post(new Runnable() { - @Override - public void run() { - mixingProgressBar.setMax(info.durationMs); - String timeString = new SimpleDateFormat("mm:ss").format(info.durationMs); - progressText.setText(timeString); - } - }); - } + Log.d(TAG, "onRequestAudioFileInfo: "+info.durationMs); + handler.post(()-> mixingProgressBar.setMax(info.durationMs)); } }; @@ -549,6 +540,9 @@ else if(seekBar.getId() == R.id.mixingVolBar){ * @param volume: Audio mixing volume. The value ranges between 0 and 100 (default). */ engine.adjustAudioMixingVolume(progress); + }else if(seekBar.getId() == R.id.mixingProgress){ + String durationText = io.agora.api.example.utils.TextUtils.durationFormat((long) progress); + progressText.setText(durationText); }else if(seekBar.getId() == R.id.slider_speed_fg_audio_file){ updateSpeedTitle(); }