enableLocalCache static method

Future<void> enableLocalCache(
  1. bool enable,
  2. String maxBufferMemoryKB,
  3. String localCacheDir,
  4. DocTypeForIOS docTypeForIOS,
)

开启本地缓存 开启之后,就会缓存到本地文件中。 setCacheFileClearConfig 缓存相关配置

Implementation

static Future<void> enableLocalCache(bool enable, String maxBufferMemoryKB,
    String localCacheDir, DocTypeForIOS docTypeForIOS) {
  var map = {
    'enable': enable,
    'maxBufferMemoryKB': maxBufferMemoryKB,
    'localCacheDir': localCacheDir,
  };

  if (Platform.isIOS) {
    // docTypeForIOS的取值代表沙盒目录路径类型 "0":Documents, "1":Library, "2":Caches, 其他:Documents
    map['docTypeForIOS'] = docTypeForIOS.index.toString();
  } else {
    // 安卓不需设置docType,直接传递localCacheDir
  }

  return FlutterAliPlayerFactory.methodChannel
      .invokeMethod("enableLocalCache", map);
}