spat
asked on
Edit Play List
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
A thorough discription or example on how this works would be greatly appreciated.
Thanks
Spat
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.
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.
///you may also "steal" playlist from MS CDplayer:
c:\windows\cdplayer.ini
c:\windows\cdplayer.ini
//there is a playlist there only if you've made it while running MS CDPLAYER
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.CurTrackPositio n : 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.SetCurTrackPosi tion (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(V alue : 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);{Set CurTrackPo sition(Tem p - 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(Ind ex : 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
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(
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
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.CurTrackPositio
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
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.SetCurTrackPosi
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(V
{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);{Set
{ 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(Ind
Var
TMSM : TMSMRec;
HMS : HMSRec;
begin
TMSM := TMSMRec(mplCD.TrackLength[
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
TMSMRec = record
Tracks: byte;
Minutes: byte;
Seconds: byte;
MSec: byte;
end;
HMSRec = Record
Hours: byte;
Minutes: byte;
Seconds: byte;
NotUsed: byte;
end;
Tracks: byte;
Minutes: byte;
Seconds: byte;
MSec: byte;
end;
HMSRec = Record
Hours: byte;
Minutes: byte;
Seconds: byte;
NotUsed: byte;
end;
ASKER
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
Thanks for your help
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
The code above is for converting the Position property into the DateTime format and back so you have no difficulties with it
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sorry, I couldn't post a comment due to some internal error...
bosism@netvision.net.il
bosism@netvision.net.il
ASKER
Thank you, this is really appreciated.
My email address is cando@ix.netcom.com.
Thanks again.
My email address is cando@ix.netcom.com.
Thanks again.
Sorry for the delay, and here you go...
ASKER
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
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
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
ASKER