load static method

Future<MSound> load({
  1. required MSoundConfig config,
})

Implementation

static Future<MSound> load({required MSoundConfig config}) async {
  final data = await AssetManifest.loadFromAssetBundle(rootBundle);

  final soundPathItems = data
      .listAssets()
      .where((filepath) => filepath.startsWith(config.soundPath))
      .toList();

  //
  final Map<String, String> soundMap = {};
  for (var soundPath in soundPathItems) {
    final String filename = soundPath.split("/").last;
    final String name = filename.split(".").first;
    soundMap[name] = filename;
  }

  //
  return MSound(
    config: config,
    engine: MSoundEngine(
      config: config,
      soundMap: soundMap,
    ),
  );
}