Solved

Edit Play List

Posted on 1998-11-26
14
144 Views
Last Modified: 2010-04-04
I have been having a lot of trouble creating an "Edit Play List" dialog for my application. I have no idea how to make the mediaplayer play cd tracks from a list of numbers and still stay in TMSF time format. I dont even know if an "Edit Play List" works by playing from a list of numbers.

A thorough discription or example on how this works would be greatly appreciated.

Thanks
Spat
0
Comment
Question by:spat
  • 7
  • 4
  • 2
  • +1
14 Comments
 

Author Comment

by:spat
ID: 1348180
Edited text of question
0
 
LVL 5

Expert Comment

by:scrapdog
ID: 1348181
For the source code of a working CD-player:

http://sunsite.icm.edu.pl/delphi/ftp/d10free/cdplayer.zip

Looking at this might solve some of your problems you are having implementing your CD-player.


0
 
LVL 1

Expert Comment

by:duke_n
ID: 1348182
///you may also "steal" playlist from MS CDplayer:
c:\windows\cdplayer.ini
0
 
LVL 1

Expert Comment

by:duke_n
ID: 1348183
//there is a playlist there only if you've made it while running MS CDPLAYER
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1348184
For example: you have a list of track numbers, yeah? Then you set the start playing time of the mpl, and the ending time as the first track should start and end. If you don't do this, you'll get the plying continue to the next track without notifying you. So you've set that. Now you get the notification event when the playing is stopped, and you do the same with the next track from the list.
OK, now, to get comfy with the "Position" format, I post a part from a unit I wrote for a small CD player years ago:
________________________________________________________________
Function TfrmCDPlay.TimeToPosition(Value : TDateTime) : LongInt;
Var
 Temp : TDateTime;
 TMSM : TMSMRec;
 i : Integer;
 Hours, Minutes, Seconds, MSec: Word;
begin
  Temp := 0;
  i := 1;
  If Value >= CDLength then
  Begin
    i := NumTracks;
    Temp := CDLength - TrackLength(i);
    end
  else
  While (Value > Temp + TrackLength(i))and(i <> NumTracks) Do
  Begin
    Temp := Temp + TrackLength(i);
    inc(i);
    end;

  DecodeTime(Temp - Value, Hours, Minutes, Seconds, MSec);
  TMSM.Tracks := i;
  TMSM.Minutes := Hours*60 + Minutes;
  TMSM.Seconds := Seconds;
  TMSM.MSec := MSec;
  Result := LongInt(TMSM);
end;

Function TfrmCDPlay.TrackToPosition(Value : Byte) : LongInt;
Var
 TMSM : TMSMRec;
Begin
If Value > NumTracks Then Result := TimeToPosition(CDLength)
else
Begin
 TMSM.Tracks := Value;
 TMSM.Minutes := 0;
 TMSM.Seconds := 0;
 TMSM.MSec := 0;
 Result := LongInt(TMSM);
 end;
end;

Function TfrmCDPlay.CurTrackPosition : TDateTime;
Var
 TMSM : TMSMRec;
 HMS : HMSRec;
begin
  TMSM := TMSMRec(mplCD.Position);
  HMS.Hours := TMSM.Minutes div 60;
  HMS.Minutes := TMSM.Minutes - HMS.Hours*60;
  HMS.Seconds := TMSM.Seconds;
  HMS.NotUsed := 0;
  Result := EncodeTime (HMS.Hours, HMS.Minutes, HMS.Seconds, HMS.NotUsed);
end;

procedure TfrmCDPlay.SetCurrentTrack(Value : LongInt);
Var Temp : LongInt;
{ TMSM : TMSMRec;}
Begin
{ TMSM.Tracks := Value;
 TMSM.Minutes := 0;
 TMSM.Seconds := 0;
 TMSM.MSec := 0;}
Temp := TrackToPosition(Value);
  If Playing then
  Begin
   mplCD.Pause;
   mplCD.Position := Temp;
   mplCD.Play;
   end
 else if Stopped or Paused then
   mplCD.Position := Temp;
end;

procedure TfrmCDPlay.SetCurTrackPosition (Value : TDateTime);
Var
 TMSM : TMSMRec;
 Hours, Minutes, Seconds, MSec: Word;
begin
  DecodeTime(Value, Hours, Minutes, Seconds, MSec);
  TMSM.Tracks := CurrentTrack;
  TMSM.Minutes := Hours*60 + Minutes;
  TMSM.Seconds := Seconds;
  TMSM.MSec := MSec;
  If Playing then
  Begin
   mplCD.Pause;
   mplCD.Position := LongInt(TMSM);
   mplCD.Play;
   end
 else if Stopped or Paused then
   mplCD.Position := LongInt(TMSM);
end;

Function TfrmCDPlay.CurrentTrack : LongInt;
Var
 TMSM : TMSMRec;
begin
  TMSM := TMSMRec(mplCD.Position);
  Result := TMSM.Tracks;
end;

Function TfrmCDPlay.CDPosition : TDateTime;
Var i : Integer;
Begin
Result := 0;
 For i := 1 to (CurrentTrack - 1) Do
   Result := Result + TrackLength(i);
 Result := Result + CurTrackPosition;
end;

procedure TfrmCDPlay.SetCDPosition(Value : TDateTime);
{Var
 Temp : TDateTime;
 i : Integer;}
begin
{  Temp := 0;
  i := 1;
  If Value = CDLength then
  Begin
    i := NumTracks;
    Temp := CDLength - TrackLength(i);
    end
  else
  While (Value > Temp + TrackLength(i))and(i <> NumTracks) Do
  Begin
    Temp := Temp + TrackLength(i);
    inc(i);
    end;}

  {SetCurrentTrack(i);}

 { If (CurrentTrack <> LastTrack) then
  Begin
    LastTrack := CurrentTrack;
    If PlayOne then Stop
    Else mplCD.Position := TimeToPosition(Value);{SetCurTrackPosition(Temp - Value);}
 {   If Assigned(OnTrackChange) then OnTrackChange(Self);
    end
  Else}
  If Playing then
  Begin
    mplCD.Stop;
    mplCD.Position := TimeToPosition(Value);
    If (CurrentTrack <> LastTrack) then
    Begin
      LastTrack := CurrentTrack;
      If not PlayOne then mplCD.Play;
      If Assigned(OnTrackChange) then OnTrackChange(Self);
      end
    else mplCD.Play;
      end
  else
  Begin
    mplCD.Position := TimeToPosition(Value);
    If (CurrentTrack <> LastTrack) then
    Begin
      LastTrack := CurrentTrack;
      If Assigned(OnTrackChange) then OnTrackChange(Self);
      end
   end;
end;

Function TfrmCDPlay.NumTracks : LongInt;
Begin
 Result := mplCD.Tracks;
end;

Function TfrmCDPlay.TrackLength(Index : Integer) : TDateTime;
Var
 TMSM : TMSMRec;
 HMS : HMSRec;
begin
  TMSM := TMSMRec(mplCD.TrackLength[Index]);
  HMS.Hours := TMSM.Tracks div 60;
  HMS.Minutes := TMSM.Tracks - HMS.Hours*60;
  HMS.Seconds := TMSM.Minutes;
  HMS.NotUsed := 0;
  Result := EncodeTime (HMS.Hours, HMS.Minutes, HMS.Seconds, HMS.NotUsed);
end;

Function TfrmCDPlay.CDLength : TDateTime;
Var
 TMSM : TMSMRec;
 HMS : HMSRec;
begin
  TMSM := TMSMRec(mplCD.Length);
  HMS.Hours := TMSM.Tracks div 60;
  HMS.Minutes := TMSM.Tracks - HMS.Hours*60;
  HMS.Seconds := TMSM.Minutes;
  HMS.NotUsed := 0;
  Result := EncodeTime (HMS.Hours, HMS.Minutes, HMS.Seconds, HMS.NotUsed);
end;
________________________________________________________________

Good luck!
--Matvey
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1348185
 TMSMRec = record
    Tracks: byte;
    Minutes: byte;
    Seconds: byte;
    MSec: byte;
  end;
  HMSRec = Record
    Hours: byte;
    Minutes: byte;
    Seconds: byte;
    NotUsed: byte;
  end;
0
 

Author Comment

by:spat
ID: 1348186
I have tried the code shown above but i cant figure out how it works or what i does. I want to make a listbox with a list of numbers in it and play the cd from the list box. The first item in the listbox is whatever track it says, then when the track is over, it will automaticly go on the next track in the list box and play it.

Thanks for your help
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 3

Expert Comment

by:Matvey
ID: 1348187
I need some time because I have no code here. But you got my word!

The code above is for converting the Position property into the DateTime format and back so you have no difficulties with it
0
 
LVL 3

Accepted Solution

by:
Matvey earned 330 total points
ID: 1348188
I made a small demo. It plays tracks from a randomized list, which In my opinion is a good presentation. Write your email please, also everybody else that want to see it...

---cheers, Matvey
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1348189
sorry, I couldn't post a comment due to some internal error...

bosism@netvision.net.il
0
 

Author Comment

by:spat
ID: 1348190
Thank you, this is really appreciated.
My email address is cando@ix.netcom.com.
Thanks again.
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1348191
Sorry for the delay, and here you go...
0
 

Author Comment

by:spat
ID: 1348192
perfect, this IS very impressive! I have raised the points to 330, I would have given you more but that was all I had. Thanks again

0
 
LVL 3

Expert Comment

by:Matvey
ID: 1348193
Thanks, I'm getting to that third T-Shirt :)
It took me not much time, but it's quite nice, and it works, so I think I'll send it to the Delphi pages, because I didn't find anything there clear enough to help with problems like yours.

Great, and c u around here-
  Matvey
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now