startPreLoad method
- String playUrl,
- double preloadSizeMB,
- int preferredResolution, {
- FTXPredownlodOnCompleteListener? onCompleteListener,
- 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.
Implementation
Future<int> startPreLoad(
final String playUrl,
final double preloadSizeMB,
final int preferredResolution, {
FTXPredownlodOnCompleteListener? onCompleteListener,
FTXPredownlodOnErrorListener? onErrorListener,
}) async {
final int? value = await VodGlobalChannel.download.invoke<int>(
'startPreLoad',
{
'playUrl': playUrl,
'preloadSizeMB': preloadSizeMB,
'preferredResolution': preferredResolution,
},
);
int taskId = value ?? -1;
if (taskId >= 0) {
_preloadListeners[taskId] = _PreloadListener()
..onCompleteListener = onCompleteListener
..onErrorListener = onErrorListener;
}
return taskId;
}