import 'package:flutter/material.dart'; import 'package:video_player/video_player.dart'; class YSVideoProgressView extends StatefulWidget { final VideoPlayerController playerController; const YSVideoProgressView({Key? key, required this.playerController}) : super(key: key); @override YSVideoProgressViewState createState() => YSVideoProgressViewState(); } class YSVideoProgressViewState extends State { String _startTime = '00:00:00'; @override void initState() { widget.playerController.addListener(() { Duration position = widget.playerController.value.position; _startTime = '${'${position.inHours}'.padLeft(2,'0')}:${'${position.inMinutes}'.padLeft(2,'0')}:${'${position.inSeconds}'.padLeft(2,'0')}'; setState(() {}); }); super.initState(); } @override Widget build(BuildContext context) { return Container( margin: EdgeInsets.only(top: MediaQuery.of(context).size.height-50,left: 15,right: 15), child: Row( children: [ SizedBox( width: 100, child: Row( children: [ GestureDetector( onTap: (){ widget.playerController.value.isPlaying?widget.playerController.pause() : widget.playerController.play(); setState(() {}); }, child: Icon(widget.playerController.value.isPlaying?Icons.pause:Icons.play_arrow,size: 25,color: Colors.white,), ), Container( alignment: Alignment.center, width: 75, child: Text(_startTime,style: const TextStyle(fontSize: 12,color: Colors.white),), ) ], ), ), SizedBox( width: MediaQuery.of(context).size.width-130, height:6.5, child: VideoProgressIndicator( widget.playerController, allowScrubbing: true, colors: const VideoProgressColors(playedColor: Colors.white,backgroundColor: Colors.black), ) ), ], ), ); } }