From 2c5fa5ac7463cfa179f9466e7ed5489f67fc5628 Mon Sep 17 00:00:00 2001 From: Littlegnal <8847263+littleGnAl@users.noreply.github.com> Date: Mon, 25 Sep 2023 19:03:13 +0800 Subject: [PATCH] [web] Compatible getAssetAbsolutePath function on web (#1327) [web] Compatible getAssetAbsolutePath function on web --- lib/src/agora_rtc_engine_ext.dart | 4 +--- lib/src/impl/agora_rtc_engine_impl.dart | 11 +++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/src/agora_rtc_engine_ext.dart b/lib/src/agora_rtc_engine_ext.dart index c18102fcf..72f90c5fb 100644 --- a/lib/src/agora_rtc_engine_ext.dart +++ b/lib/src/agora_rtc_engine_ext.dart @@ -15,9 +15,7 @@ extension RtcEngineExt on RtcEngine { /// The actual path of the Asset. Future getAssetAbsolutePath(String assetPath) async { final impl = this as RtcEngineImpl; - final p = await impl.engineMethodChannel - .invokeMethod('getAssetAbsolutePath', assetPath); - return p; + return impl.getAssetAbsolutePath(assetPath); } } diff --git a/lib/src/impl/agora_rtc_engine_impl.dart b/lib/src/impl/agora_rtc_engine_impl.dart index 7378734f0..e60d05a5b 100644 --- a/lib/src/impl/agora_rtc_engine_impl.dart +++ b/lib/src/impl/agora_rtc_engine_impl.dart @@ -1152,6 +1152,17 @@ class RtcEngineImpl extends rtc_engine_ex_binding.RtcEngineExImpl } } + Future getAssetAbsolutePath(String assetPath) async { + if (kIsWeb) { + // The assets are located in the `assets` directory. + return 'assets/$assetPath'; + } + + final p = await engineMethodChannel.invokeMethod( + 'getAssetAbsolutePath', assetPath); + return p; + } + /////////// debug //////// /// [type] see [VideoSourceType], only [VideoSourceType.videoSourceCamera], [VideoSourceType.videoSourceRemote] supported