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..bb7846cc3 100644 --- a/lib/src/impl/agora_rtc_engine_impl.dart +++ b/lib/src/impl/agora_rtc_engine_impl.dart @@ -46,6 +46,8 @@ import 'package:meta/meta.dart'; import 'platform/global_video_view_controller.dart'; +import 'package:path/path.dart' as path show join; + // ignore_for_file: public_member_api_docs int? _mockRtcEngineNativeHandle; @@ -1152,6 +1154,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