if (isShowInterface && !isLoading)
Center(
child: InkWell(
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
onTap: playPauseVideo,
child: Icon(
isPaused ? Icons.play_arrow : Icons.pause,
color: const Color(0xFFFFFFFF),
size: 40,
),
),
),
Future playPauseVideo() async{
setState(() {
isPaused = !isPaused;
});
if (isPaused) {
pausedMoment = controllerVideo.value.position;
controllerVideo.value = controllerVideo.value.copyWith(
playerState: PlayerState.paused,
isPlaying: false,
);
} else {
controllerVideo.value = controllerVideo.value.copyWith(
playerState: PlayerState.playing,
isPlaying: true,
);
changeVideoPosition(seconds: pausedMoment.inSeconds);
}
}
Future changeVideoPosition({required int seconds}) async {
controllerVideo.removeListener(update);
setState(() {
isUpdate = true;
isLoading = true;
});
await Future.delayed(const Duration(milliseconds: 10));
controllerVideo = YoutubePlayerController(
initialVideoId: widget.videoId.toString(),
flags: YoutubePlayerFlags(
autoPlay: true,
hideControls: true,
showLiveFullscreenButton: false,
startAt: seconds,
),
);
setState(() {
isUpdate = false;
});
oldMoment = const Duration();
controllerVideo.addListener(update);
}
void _dragEndActions() {
_controller.updateValue(
_controller.value.copyWith(isControlsVisible: false, isDragging: false),
);
_controller.seekTo(_position, allowSeekAhead: true);
setState(() {
_touchDown = false;
});
_controller.play();
if (widget.changeVideoPosition != null) {
widget.changeVideoPosition!();
}
}
ProgressBar(
isExpanded: true,
colors: const ProgressBarColors(),
controller: controllerVideo,
changeVideoPosition: () {
changeVideoPosition(seconds: controllerVideo.value.position.inSeconds);
},
),
if (!isLoading)
Row(
children: [
Expanded(
child: InkWell(
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
onTap: showInterface,
onDoubleTap: () {
changeVideoPosition(seconds: controllerVideo.value.position.inSeconds - 5);
},
child: const SizedBox(height: double.infinity),
),
),
Expanded(
child: InkWell(
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
onTap: showInterface,
onDoubleTap: () {
changeVideoPosition(seconds: controllerVideo.value.position.inSeconds + 5);
},
child: const SizedBox(height: double.infinity),
),
),
],
),