I'm using Delphi 10.3 for developing android mobile application. I'm using the TMediaPlayer to play the mp3 files. I want to display the current time and remaining time of the currently playing media file with the minutes and seconds (mm:ss - ref: VLC media player). But I can able display the minutes properly and I want to display the seconds with the two digits.
Please help me to display the seconds properly.
Here, I have mentioned the code that I have tried.
procedure Timer1Timer(Sender: TObject);
begin
TrackBar1.Tag := 1;
TrackBar1.Value := MediaPlayer1.CurrentTime;
CurrentMin := MediaPlayer1.CurrentTime div 1000 div 600000;
CurrentSec := MediaPlayer1.CurrentTime div 1000; // Seconds
DurationMin := MediaPlayer1.Duration div 1000 div 600000;
DurationSec := MediaPlayer1.Duration div 1000; // Seconds
LabelCurrentTime.Text := Format('%2.2d : %2.2d', [CurrentMin, CurrentSec]);
LabelRemainingTime.Text := Format('%2.2d : %2.2d', [DurationMin, DurationSec]);
TrackBar1.Tag := 0;
end;
The documentation for FMX.Media.TMediaPlayer.CurrentTime says:
and
So, given variables
we can write the following
Note the usage of 'mod' to limit seconds display to '00 .. 59'