From c1d0f2f66524b194d93b77e0208088e6dddafaa0 Mon Sep 17 00:00:00 2001 From: weileifrank <1138289316@qq.com> Date: Thu, 24 Oct 2024 20:55:16 +0800 Subject: [PATCH] feat: improve logic for livestreaming screenshot --- .../api/example/examples/advanced/LiveStreaming.java | 12 ++++++++++-- .../examples/advanced/beauty/ByteDanceBeautySDK.kt | 2 +- .../src/main/res/layout/fragment_live_streaming.xml | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/LiveStreaming.java b/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/LiveStreaming.java index 746d1a8d6..3eac74bb1 100644 --- a/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/LiveStreaming.java +++ b/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/LiveStreaming.java @@ -245,6 +245,8 @@ public void onNothingSelected(AdapterView parent) { mRootBinding.spinnerScenario.setOnItemSelectedListener(this); mRootBinding.spinnerSnapshot.setOnItemSelectedListener(this); + + mRootBinding.btnLocalScreenshot.setEnabled(false); } private void resetFps() { @@ -388,6 +390,7 @@ public void onPermissionsResult(boolean allPermissionsGranted, String[] permissi } }); } else { + mRootBinding.btnLocalScreenshot.setEnabled(false); joined = false; mRootBinding.llContainerFp.setVisibility(View.GONE); isHost = false; @@ -638,7 +641,7 @@ private void takeSnapshot(int uid) { showLongToast(getString(R.string.join_channel_first)); return; } - String filePath = requireContext().getExternalCacheDir().getAbsolutePath() + "_livestreaming_snapshot.png"; + String filePath = new File(requireContext().getExternalCacheDir(), uid + "_livestreaming_snapshot.png").getAbsolutePath(); SnapshotConfig config = new SnapshotConfig(); config.filePath = filePath; if (uid == myUid) { @@ -647,7 +650,7 @@ private void takeSnapshot(int uid) { if (ret != Constants.ERR_OK) { showLongToast("takeSnapshot local error code=" + ret + ",msg=" + RtcEngine.getErrorDescription(ret)); } - }else{ + } else { if (uid != 0) { // config.position = Constants.VideoModulePosition.VIDEO_MODULE_POSITION_PRE_RENDERER; // int ret = engine.takeSnapshot(uid, config); @@ -847,6 +850,11 @@ public void onClientRoleChanged(int oldRole, int newRole, ClientRoleOptions newR Log.i(TAG, String.format("client role changed from state %d to %d", oldRole, newRole)); runOnUIThread(() -> { mRootBinding.btnPublish.setEnabled(true); + if (newRole == Constants.CLIENT_ROLE_BROADCASTER) { + mRootBinding.btnLocalScreenshot.setEnabled(true); + } else { + mRootBinding.btnLocalScreenshot.setEnabled(false); + } }); } diff --git a/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/beauty/ByteDanceBeautySDK.kt b/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/beauty/ByteDanceBeautySDK.kt index 20afa110d..ea6440e91 100644 --- a/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/beauty/ByteDanceBeautySDK.kt +++ b/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/beauty/ByteDanceBeautySDK.kt @@ -11,7 +11,7 @@ object ByteDanceBeautySDK { private const val TAG = "ByteDanceBeautySDK" - private val LICENSE_NAME = "Agora_test_20240712_20241016_io.agora.entfull_4.5.0_1770.licbag" + private val LICENSE_NAME = "Agora_test_20241014_20241214_io.agora.entfull_4.5.0_2060.licbag" private var storagePath = "" private var assetsPath = "" private var licensePath = "" diff --git a/Android/APIExample/app/src/main/res/layout/fragment_live_streaming.xml b/Android/APIExample/app/src/main/res/layout/fragment_live_streaming.xml index 2bf9a0e90..b8fdc3b32 100644 --- a/Android/APIExample/app/src/main/res/layout/fragment_live_streaming.xml +++ b/Android/APIExample/app/src/main/res/layout/fragment_live_streaming.xml @@ -79,6 +79,7 @@ android:id="@+id/btn_local_screenshot" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:enabled="false" android:layout_marginBottom="4dp" android:text="@string/local_screenshot" />