Solved

Mediaplayer set time format.

Posted on 2001-06-20
5
608 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

832 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