buildDurationAndPosition method
Build the player duration label.
Implementation
Widget buildDurationAndPosition() {
return MultiValueListenableBuilder(
valueListenables: [
_durationNotifier,
_positionNotifier,
_playerStateNotifier,
],
builder: (context, values, _) {
Duration duration = values.elementAt(0);
Duration position = values.elementAt(1);
PlayerState? playerState = values.elementAt(2);
if (duration == Duration.zero) {
return const SizedBox.shrink();
}
String getPositionText() {
if (playerState == null ||
playerState.processingState == ProcessingState.completed) {
position = Duration.zero;
}
return JidoujishoTimeFormat.getVideoDurationText(position).trim();
}
String getDurationText() {
return JidoujishoTimeFormat.getVideoDurationText(duration).trim();
}
return Text(
'${getPositionText()} / ${getDurationText()}',
);
},
);
}