?
Solved

Delphi4 CD Audio?

Posted on 1998-11-08
9
Medium Priority
?
419 Views
Last Modified: 2010-04-04
How can I get the MediaPlayer component to play CD's without device errors? I've done this in Delphi 2 with no problem and have set the component up in the same way. Is it a bug or am I missing something new in D4?
0
Comment
Question by:xpher
  • 4
  • 4
9 Comments
 
LVL 4

Expert Comment

by:BoRiS
ID: 1346131
xpher

Let us see the code you using, we can track it down form there...

Later
BoRiS
0
 
LVL 1

Author Comment

by:xpher
ID: 1346132
I'm not actually adding code. all I am doing is placing a MediaPlayer component on the form and using the object inspector to set DeviceType to CDAudio, AutoOpen to True.

In Delphi 2 this worked. In 4 I can only get it to work if I put something like Track01.cda in the Filename of the Object Inspector.

Regards
Chris.
0
 
LVL 2

Expert Comment

by:333
ID: 1346133
Hi,
I think there is a some bug in MPlayer unit. I have this problem also. When DeviceType is set to CDAudio and I try to open, exception is raised. The same code on Delphi3 & 2 works perfect. I try to copy Open procedure code from Delphi4 mplayer.pas into my program. When i try to execute only this procedure, the exception was raised. Then I copy Open procedure code from Delphi3 mplayer.pas. Everything was OK.
So I think problem is in one missing line:

if FElementName <> '' then {<-- this line is missing in D4}
 OpenParm.lpstrElementName := PChar(FElementName);

There is one line that was changed in D4:

if FElementName <> '' then FFlags := FFlags or mci_Open_Element; {<-- D3 line}
FFlags := FFlags or mci_Open_Element; {<-- D4 line}

So, FElementName is something like file name (i'm not sure). If you change this two lines in D4 mplayer.pas, everything should be ok. At least it works by me.

A.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:xpher
ID: 1346134
333

I'm new to this so find things a bit difficult to follow. I think I found the right parts to change but it doesn't seem to make a difference. Am I supposed to recompile or some other such frightening action?

A little more assistance would be greatly appreciated.

Regards
Chris :)
0
 
LVL 2

Expert Comment

by:333
ID: 1346135
xpher,
sure, you must recompile component.
I did it so:
1. Choose 'New Application' from menu.
2. Click 'Add to project' and choose mplayer.pas from Delphi's source directory.
3. Make changes in mplayer.pas and compile project.
4. Now, in source directory (where was mplayer.pas) should be file mplayer.dcu.
5. Close Delphi and copy file mplayer.dcu to \LIB. You can make a backup copy of old mplayer.dcu
6. That's all. Start Delphi.

A.
0
 
LVL 1

Author Comment

by:xpher
ID: 1346136
333

Perfect. It worked like a treat.
Do you want to send as answer so I can assign the points.

Regards
Chris :))
0
 
LVL 2

Accepted Solution

by:
333 earned 80 total points
ID: 1346137
Hi,
       I think there is a some bug in MPlayer unit. I have this problem also. When DeviceType is set to CDAudio and I try to open,
       exception is raised. The same code on Delphi3 & 2 works perfect. I try to copy Open procedure code from Delphi4
       mplayer.pas into my program. When i try to execute only this procedure, the exception was raised. Then I copy Open procedure
       code from Delphi3 mplayer.pas. Everything was OK.
       So I think problem is in one missing line:

       if FElementName <> '' then {<-- this line is missing in D4}
        OpenParm.lpstrElementName := PChar(FElementName);

       There is one line that was changed in D4:

       if FElementName <> '' then FFlags := FFlags or mci_Open_Element; {<-- D3 line}
       FFlags := FFlags or mci_Open_Element; {<-- D4 line}

       So, FElementName is something like file name (i'm not sure). If you change this two lines in D4 mplayer.pas, everything should
       be ok. At least it works by me.

       A.
:)
0
 
LVL 1

Author Comment

by:xpher
ID: 1346138
333

Many thanks.

I don't suppose you have had the problem of dispaying first frame of avi have you? I've foolowed instructions on this but it just flashes on and disappears.

Regards
Chris :)
0
 
LVL 2

Expert Comment

by:333
ID: 1346139
Sorry, but I never worked with avi, so i don't know.

A.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

839 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