Solved

Mediaplayer set time format.

Posted on 2001-06-20
5
615 Views
Last Modified: 2010-04-06
I use this mediaplayer and try and set the time into normal minutes : seconds format but the results look really odd... like 153:940. Plus I was curious how I can make this refresh to show the time count down not just display the length one time.

type
  MSFRec = record
    Minutes: byte;
    Seconds: byte;
    Frames: byte;
    NotUsed: byte;
  end;

procedure TfrmMain.Song;
var
  TheLength: LongInt;
begin
MediaPlayer1.TimeFormat := tfMSF;
TheLength := MediaPlayer1.Length;
with MSFRec(TheLength) do
begin
  len := IntToStr(Minutes); {Display Minutes }
  len := len + ':' + IntToStr(Seconds); {Display Seconds}
end;
lblLen.Caption := len;
0
Comment
Question by:Dsys
  • 3
5 Comments
 
LVL 1

Accepted Solution

by:
Dennis9 earned 100 total points
ID: 6210505
Hi.
This should do the job (I hope):

//Add this function
function MilliSecondsToString(MilliSeconds: integer): string;
var i1, i2: integer;
begin
i1:=(MilliSeconds div 1000) div 60; i2:=(MilliSeconds div 1000)-(i1*60);
Result:=FormatFloat('00',i1)+':'+FormatFloat('00',i2);
end;

//Put in a Label and a timer, in the ontimer add this
Label1.caption := (MilliSecondsToString(MediaPlayer1.Length)+' - '+(MilliSecondsToString(MediaPlayer1.Position)));

//Remember to enable the timer when the Medieplayer knows what file to play


Dennis

0
 
LVL 17

Expert Comment

by:geobul
ID: 6210761
Hi,
The problem obviously is that tfMilliseconds format is supported by your device and the others are not.

Regards, Geo
0
 

Author Comment

by:Dsys
ID: 6212649
This did not work. The data is still showing up in an odd format. 234:240 and so forth...

I do not know what will work to make it show real minutes and real seconds?

geobul what do you propose?
0
 

Author Comment

by:Dsys
ID: 6212666
Oh wait a second here I was too quick to judge. Your idea might work and I did something wrong... let me try something else.
0
 

Author Comment

by:Dsys
ID: 6212672
ok so your idea was great and I had goofed up. Sorry. Thanks for the help.

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
delphi exception 7 68
code issue 8 156
Delphi Yen format 3 45
firemonkey Android Listview Sort items 7 53
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question