Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Edit Play List

Posted on 1998-11-26
14
Medium Priority
?
164 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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
 
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 1320 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

636 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