amseekbar 0.1.2 amseekbar: ^0.1.2 copied to clipboard
A seekbar for audio/video players. It shows the current time and the duration time directly in the seeker.
seekbar #
A seekbar for audio/video player with current time and duration time display
Based on this project
Getting Started #
class TestSeekBarPage extends StatefulWidget {
@override
_TestSeekBarPageState createState() {
return _TestSeekBarPageState();
}
}
class _TestSeekBarPageState extends State<TestSeekBarPage> {
double _value = 0.0;
double _totalTime = 1 * 3600 + 48.0 * 60 + 23;
Timer _progressTimer;
bool _done = false;
@override
void initState() {
_resumeProgressTimer();
super.initState();
}
_resumeProgressTimer() {
_progressTimer = Timer.periodic(const Duration(milliseconds: 1000), (_) {
setState(() {
_value += 1;
if (_value >= _totalTime) {
_value = _totalTime;
_progressTimer.cancel();
_done = true;
}
});
});
}
@override
void dispose() {
_progressTimer?.cancel();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
padding: EdgeInsets.symmetric(horizontal: 5),
alignment: Alignment.center,
color: Colors.black87,
child: SeekBar(
currentTime: _value,
durationTime: _totalTime,
onStartTrackingTouch: () {
if (!_done) {
_progressTimer?.cancel();
}
},
onProgressChanged: (value) {
_value = value * _totalTime;
},
onStopTrackingTouch: () {
if (!_done) {
_resumeProgressTimer();
}
},
),
),
);
}
}