Skip to content

Commit

Permalink
Compatible getAssetAbsolutePath function on web
Browse files Browse the repository at this point in the history
  • Loading branch information
littleGnAl committed Sep 19, 2023
1 parent 5724a43 commit 515f0c7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 1 addition & 3 deletions lib/src/agora_rtc_engine_ext.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ extension RtcEngineExt on RtcEngine {
/// The actual path of the Asset.
Future<String?> getAssetAbsolutePath(String assetPath) async {
final impl = this as RtcEngineImpl;
final p = await impl.engineMethodChannel
.invokeMethod<String>('getAssetAbsolutePath', assetPath);
return p;
return impl.getAssetAbsolutePath(assetPath);
}
}

Expand Down
13 changes: 13 additions & 0 deletions lib/src/impl/agora_rtc_engine_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1152,6 +1154,17 @@ class RtcEngineImpl extends rtc_engine_ex_binding.RtcEngineExImpl
}
}

Future<String?> getAssetAbsolutePath(String assetPath) async {
if (kIsWeb) {
// The assets are located in the `assets` directory.
return 'assets/$assetPath';
}

final p = await engineMethodChannel.invokeMethod<String>(
'getAssetAbsolutePath', assetPath);
return p;
}

/////////// debug ////////
/// [type] see [VideoSourceType], only [VideoSourceType.videoSourceCamera], [VideoSourceType.videoSourceRemote] supported
Expand Down

0 comments on commit 515f0c7

Please sign in to comment.