startPreLoad method

Future<int> startPreLoad(
  1. String playUrl,
  2. double preloadSizeMB,
  3. int preferredResolution, {
  4. FTXPredownlodOnCompleteListener? onCompleteListener,
  5. FTXPredownlodOnErrorListener? onErrorListener,
})

Start pre-downloading. Important Before starting pre-download, please set the cache directory SuperPlayerPlugin.setGlobalCacheFolderPath and cache size SuperPlayerPlugin.setGlobalMaxCacheSize of the playback engine first. This setting is a global configuration and needs to be consistent with the player to avoid invalidation of playback cache. playUrl: The URL to be pre-downloaded. preloadSizeMB: The pre-downloaded size (unit: MB). preferredResolution: The expected resolution, long type, value is height x width. For example, 720*1080. If multiple resolutions are not supported or not specified, pass -1. onCompleteListener: Pre-download successful callback. onErrorListener: Pre-download failed callback. Return value: Task ID, which can be used to stop pre-download stopPreload.

启动预下载。 【重要】启动预下载前,请先设置好播放引擎的缓存目录SuperPlayerPlugin.setGlobalCacheFolderPath和缓存大小SuperPlayerPlugin.setGlobalMaxCacheSize,这个设置是全局配置需和播放器保持一致,否则会造成播放缓存失效。 playUrl: 要预下载的url preloadSizeMB: 预下载的大小(单位:MB) preferredResolution 期望分辨率,long类型,值为高x宽。可参考如720*1080。不支持多分辨率或不需指定时,传-1。 onCompleteListener:预下载成功回调 onErrorListener:预下载失败回调 返回值:任务ID,可用这个任务ID停止预下载 stopPreload

Implementation

Future<int> startPreLoad(
  final String playUrl,
  final double preloadSizeMB,
  final int preferredResolution, {
  FTXPredownlodOnCompleteListener? onCompleteListener,
  FTXPredownlodOnErrorListener? onErrorListener,
}) async {
  IntMsg msg = await _api.startPreLoad(PreLoadMsg()
    ..playUrl = playUrl
    ..preloadSizeMB = preloadSizeMB
    ..preferredResolution = preferredResolution);
  int taskId = msg.value ?? -1;
  if (taskId >= 0) {
    _preloadListeners[taskId] = _PreloadListener()
        ..onCompleteListener = onCompleteListener
        ..onErrorListener = onErrorListener;
  }
  return taskId;
}