buildPlayControlSlot function
构建播放控制插槽的默认实现。 Builds the default play control slot content.
根据当前场景类型启用或禁用各类手势交互。 Enables or disables gesture interactions based on the current scene type.
Implementation
Widget buildPlayControlSlot(
SlotBuildContext ctx,
double width,
double height,
) {
final sceneType = ctx.controller.sceneTypeNotifier.value;
// 双击控制(场景限制)
bool enableDoubleTap = isNotSceneType(sceneType, [
SceneType.live,
]);
// 长按控制(场景限制)
bool enableLongPress = isNotSceneType(sceneType, [
SceneType.live,
SceneType.restricted,
]);
// 水平拖动控制(场景限制)
bool enableDrag = isNotSceneType(sceneType, [
SceneType.live,
SceneType.restricted,
]);
// 竖向手势控制(场景限制)
bool enableVerticalGestures = isNotSceneType(sceneType, [
SceneType.listPlayer,
]);
final autoHideControlsDuration =
ctx.controller.widgetData?.autoHideControlsDuration ??
SettingConstants.defaultAutoHideControlsDuration;
return PlayControlWidget(
autoHideControlsDuration: autoHideControlsDuration,
onVisibilityChanged: (bool isVisible) {
if (!isVisible) {
if (ctx.controller.isDraggingNotifier.value) return;
ctx.animationManager.hide();
} else {
ctx.animationManager.show();
}
// 同步目标可见性,而不是读取尚未完成的动画值
ctx.controller.controlBarVisibleNotifier.value = isVisible;
},
onDoubleTap: enableDoubleTap ? ctx.controller.togglePlayState : null,
onLongPressStart:
enableLongPress ? () => _onPlayerViewLongPress(ctx) : null,
onLongPressEnd:
enableLongPress ? () => _onPlayerViewLongPressEnd(ctx) : null,
onHorizontalDragUpdate: enableDrag
? (delta) => _onPlayerViewHorizontalDragUpdate(ctx, delta)
: null,
onHorizontalDragEnd: enableDrag
? (delta) => _onPlayerViewHorizontalDragEnd(ctx, delta)
: null,
onLeftVerticalDragUpdate: enableVerticalGestures
? (delta) => _onPlayerViewLeftVerticalDragUpdate(ctx, delta)
: null,
onLeftVerticalDragEnd: enableVerticalGestures
? (delta) => _onPlayerViewLeftVerticalDragEnd(ctx, delta)
: null,
onRightVerticalDragUpdate: enableVerticalGestures
? (delta) => _onPlayerViewRightVerticalDragUpdate(ctx, delta)
: null,
onRightVerticalDragEnd: enableVerticalGestures
? (delta) => _onPlayerViewRightVerticalDragEnd(ctx, delta)
: null,
);
}