videoPlayerComponent method
Implementation
Widget videoPlayerComponent(VideoPlayerController videoPlayerController, context2){
Widget component = GestureDetector(
onTap: _toggleOverlay,
onDoubleTapDown: _handleDoubleTapDown,
onDoubleTap: _handleDoubleTap,
child: Stack(
alignment: Alignment.center,
children: [
Center(
child: Stack(
alignment: Alignment.center,
children: [
AspectRatio(
aspectRatio: videoPlayerController.value.aspectRatio,
child: VideoPlayer(videoPlayerController),
),
Positioned(
right: 10,
top: 10,
child: ValueListenableBuilder<bool>(
valueListenable: overlayVisible,
builder: (BuildContext context, bool overlayVisible, Widget? child) {
return overlayVisible && widget.displayMenu ?
Container(
color: widget.pressablesBackgroundColor,
child: AnimatedOpacity(
opacity: overlayVisible ? 1.0 : 0.0,
duration: const Duration(milliseconds: 500),
child: GestureDetector(
onTap: displayVideoOptions,
child: const Icon(Icons.menu, size: 32.5)
)
)
)
: Container();
}
)
),
Positioned.fill(
left: 0,
child: Center(
child: ValueListenableBuilder<bool>(
valueListenable: overlayVisible,
builder: (BuildContext context, bool overlayVisible, Widget? child) {
return ValueListenableBuilder(
valueListenable: videoPlayerController,
builder: (BuildContext context, playerController, Widget? child) {
return overlayVisible ?
GestureDetector(
onTap: _togglePlayPause,
child: AnimatedOpacity(
opacity: overlayVisible ? 1.0 : 0.0,
duration: const Duration(milliseconds: 500),
child: displayActionIcon(videoPlayerController)
)
)
: Container();
}
);
}
)
)
),
Positioned(
left: 0,
right: 0,
bottom: 0,
child: ValueListenableBuilder<bool>(
valueListenable: overlayVisible,
builder: (BuildContext context, bool overlayVisible, Widget? child) {
return ValueListenableBuilder<bool>(
valueListenable: hasPlayedOnce,
builder: (BuildContext context, bool hasPlayedOnce, Widget? child) {
return overlayVisible && hasPlayedOnce ?
GestureDetector(
onTap: (){},
child: Container(
padding: EdgeInsets.symmetric(horizontal: 0.01 * PlatformDispatcher.instance.views.first.physicalSize.width / PlatformDispatcher.instance.views.first.devicePixelRatio, vertical: PlatformDispatcher.instance.views.first.physicalSize.height/ PlatformDispatcher.instance.views.first.devicePixelRatio * 0.01),
color: widget.overlayBackgroundColor,
child: AnimatedOpacity(
opacity: overlayVisible && hasPlayedOnce ? 1.0 : 0.0,
duration: const Duration(milliseconds: 500),
child: Column(
children: [
ValueListenableBuilder<bool>(
valueListenable: isFullScreenValue,
builder: (BuildContext context, bool isFullScreen, Widget? child) {
return Container(
padding: EdgeInsets.symmetric(horizontal: PlatformDispatcher.instance.views.first.physicalSize.width / PlatformDispatcher.instance.views.first.devicePixelRatio * 0.025),
child:Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ValueListenableBuilder<String>(
valueListenable: displayCurrentDuration,
builder: (BuildContext context, String displayCurrentDuration, Widget? child) {
return widget.durationEndDisplay == DurationEndDisplay.totalDuration ?
Text(
'$displayCurrentDuration / ${_formatDuration(videoPlayerController.value.duration)}',
style: TextStyle(fontSize: standardTextFontSize)
)
:
ValueListenableBuilder<Duration>(
valueListenable: timeRemaining,
builder: (BuildContext context, Duration timeRemaining, Widget? child) {
return Text(
'$displayCurrentDuration / -${_formatDuration(timeRemaining)}',
style: TextStyle(fontSize: standardTextFontSize)
);
}
);
}
),
GestureDetector(
onTap: () async{
if(!isFullScreen){
showFullScreenVideoPlayer(context);
isFullScreenValue.value = true;
}else{
Navigator.of(context2).pop();
isFullScreenValue.value = false;
}
},
child: Icon(isFullScreen ? Icons.fullscreen_exit : Icons.fullscreen, size: videoControlFullScreenIconSize)
)
]
)
);
}
),
SizedBox(
height: 15,
child: SliderTheme(
data: SliderThemeData(
trackHeight: 3.0,
thumbColor: widget.thumbColor,
thumbShape: const RoundSliderThumbShape(enabledThumbRadius: 5.0),
overlayShape: const RoundSliderOverlayShape(overlayRadius: 0.0),
activeTrackColor: widget.activeTrackColor,
inactiveTrackColor: widget.inactiveTrackColor
),
child: ValueListenableBuilder<double>(
valueListenable: currentPosition,
builder: (BuildContext context, double currentPosition, Widget? child) {
return Slider(
min: 0.0,
max: max(1.0, currentPosition),
value: currentPosition,
onChangeStart: ((value){
onSliderStart(value);
}),
onChanged: (newValue) {
onSliderChange(newValue);
},
onChangeEnd: (newValue){
onSliderEnd(newValue);
},
);
}
)
),
),
]
)
)
)
)
: Container();
}
);
}
)
),
]
)
),
Positioned(
left: 0,
child: ValueListenableBuilder<bool>(
valueListenable: isRewinding,
builder: (BuildContext context, bool isRewinding, Widget? child) {
return SizedBox(
width: PlatformDispatcher.instance.views.first.physicalSize.width / PlatformDispatcher.instance.views.first.devicePixelRatio * 0.5,
child: Center(
child: AnimatedOpacity(
opacity: isRewinding ? 1.0 : 0.0,
duration: const Duration(milliseconds: 250),
child: Container(
color: widget.pressablesBackgroundColor,
padding: EdgeInsets.all(PlatformDispatcher.instance.views.first.physicalSize.width / PlatformDispatcher.instance.views.first.devicePixelRatio * 0.02),
child: const Icon(FontAwesomeIcons.backward, size: 30)
)
)
)
);
}
)
),
Positioned(
right: 0,
child: ValueListenableBuilder<bool>(
valueListenable: isSkipping,
builder: (BuildContext context, bool isSkipping, Widget? child) {
return SizedBox(
width: PlatformDispatcher.instance.views.first.physicalSize.width / PlatformDispatcher.instance.views.first.devicePixelRatio * 0.5,
child: Center(
child: AnimatedOpacity(
opacity: isSkipping ? 1.0 : 0.0,
duration: const Duration(milliseconds: 250),
child: Container(
color: widget.pressablesBackgroundColor,
padding: EdgeInsets.all(PlatformDispatcher.instance.views.first.physicalSize.width / PlatformDispatcher.instance.views.first.devicePixelRatio * 0.02),
child: const Icon(FontAwesomeIcons.forward, size: 30)
)
)
)
);
}
)
)
],
)
);
return component;
}