PlayerPreload class
全局预加载控制器。单例,使用 plugin-level MethodChannel('player_plugin')。
典型用法(短剧 swiper):
await PlayerPreload.configure(maxConcurrent: 2, maxDiskBytes: 300 * 1024 * 1024);
await PlayerPreload.preload([
PreloadRequest(url: nextUrl, decryptionKey: key, priority: 10),
PreloadRequest(url: prevUrl, decryptionKey: key, priority: 5),
]);
// 切集后只保留最新窗口:
await PlayerPreload.cancelExcept([newNextUrl, newPrevUrl]);
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
cancel(
List< String> urls) → Future<void> - 按 URL 精确取消;已在途任务会 cancel + 清半成品 .enc。幂等。
-
cancelExcept(
List< String> keepUrls) → Future<void> -
只保留
keepUrls对应任务(包括 pending 和 inflight),其余全部 cancel。 场景切换 / 退出短剧页等批量清理时用。 -
configure(
{int? maxConcurrent, int? maxDiskBytes}) → Future< void> -
运行时调整并发数和磁盘预算。不回溯已在途任务。
默认:
maxConcurrent=2,maxDiskBytes=300MB。 -
preload(
List< PreloadRequest> requests) → Future<void> - 入队或更新预加载任务。同 url 重复调以最新 priority 为准。 命中完整 .enc + marker 的任务自动跳过,不重复下载。
-
shutdownAllPlayers(
) → Future< void> - 宿主页面退出时批量清理所有活跃加密播放器实例。 对齐 iOS FFmpegDecryptPlayer.shutdownAllActiveInstances。