buildSeekThumbnailSlot function

Widget buildSeekThumbnailSlot(
  1. SlotBuildContext ctx,
  2. double width,
  3. double height
)

构建 seek 缩略图插槽的默认实现。 Builds the default seek thumbnail slot content.

监听播放进度、总时长、拖拽状态、缩略图等变化, 在拖拽进度条时显示对应时间点的缩略图和时间文本。

Listens to playback progress, duration, drag state, and thumbnail changes; displays a thumbnail and time text at the corresponding seek position.

Implementation

Widget buildSeekThumbnailSlot(
  SlotBuildContext ctx,
  double width,
  double height,
) {
  // 监听播放进度、总时长、是否正在拖拽、当前拖拽进度等
  Listenable listener = Listenable.merge([
    ctx.controller.totalDurationNotifier,
    ctx.controller.thumbnailNotifier,
    ctx.controller.isDraggingNotifier,
    ctx.controller.currentSeekTimeNotifier,
    ctx.controller.videoSizeNotifier,
  ]);
  return ListenableBuilder(
    listenable: listener,
    builder: (context, _) {
      final totalDuration = ctx.controller.totalDurationNotifier.value;
      final thumbnail = ctx.controller.thumbnailNotifier.value;
      final isDragging = ctx.controller.isDraggingNotifier.value;
      final currentSeekTime = ctx.controller.currentSeekTimeNotifier.value;
      final videoWidthHeight = ctx.controller.videoSizeNotifier.value;

      return SeekThumbnailWidget(
        isVisible: isDragging,
        currentSeekTime: currentSeekTime,
        totalDuration: totalDuration,
        thumbnail: thumbnail,
        orientation: MediaQuery.of(context).orientation,
        videoSize: videoWidthHeight,
        hasBottomMargin: ctx.animationManager.isVisible,
      );
    },
  );
}