Skip to content

Commit

Permalink
[web] Compatible getAssetAbsolutePath function on web (#1327)
Browse files Browse the repository at this point in the history
[web] Compatible getAssetAbsolutePath function on web
  • Loading branch information
littleGnAl authored Sep 25, 2023
1 parent e93676c commit 2c5fa5a
Show file tree
Hide file tree
Showing 2 changed files with 12 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
11 changes: 11 additions & 0 deletions lib/src/impl/agora_rtc_engine_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,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 2c5fa5a

Please sign in to comment.