Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

multiselect cd-playing

Posted on 2001-06-16
8
Medium Priority
?
254 Views
Last Modified: 2010-04-06
I have a ComboBox where all the cd-rom drives is listed. Now I when the user clicks one of items, the selected drive will start playing an audio cd, if any. I would like to use the TMediaPlayer to this.
0
Comment
Question by:easysoft_studios
[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
  • 4
  • 4
8 Comments
 
LVL 5

Expert Comment

by:TheNeil
ID: 6201699
What you could try doing is setting the TMediaPlayer's filename property to be the selected drive

e.g.

MediaPlayer1.Filename := 'f:';  //Play the disc in F:
MediaPlayer1.Filename := 'g:';  //Play the disc in G:

Getting the selecton from the ComboBox is pretty simple as long as you keep a list of which entry in the list relates to which drive:

...  //Fill the combobox with your list of drives (which you've already placed in a TStringList using the format '<Drive letter>:')
  ComboBox1.Items.Clear;
  FOR iCount := 0 TO (stlDrives.Count - 1)
  DO
    Combobox1.Items.Add('Drive ' + stlDrives[iCount]);
...

  //Now use the selection in the combobox to set the media player's drive
  MediaPlayer1.Filename := stlDrives[ComboBox1.ItemIndex];

Now that you have the mediaplayer setup, just get it to start playing by doing something like:

  MediaPlayer1.Play;

The Neil =:)
0
 

Author Comment

by:easysoft_studios
ID: 6203977
I've tried what, but nothing happens when I press the play button! And that DeviceType type should I use?
0
 
LVL 5

Expert Comment

by:TheNeil
ID: 6205414
Ahh. Set the deviceType to be dtAutoSelect. You also need to open the mediaplayer (I forgot about that bit):

MediaPlayer1.Open;
MediaPlayer1.Play;

Then when you're finished (or need to switch the drive/file) you need to close the mediaplayer using:

MediaPlayer1.Close;

The Neil =:)
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.

 

Author Comment

by:easysoft_studios
ID: 6206073
Won't work!

My Windows is Danish, so I don't know if this error message is correct translated:

"MMSystem This file could not be played. Check if the filename is correct, or install a driver who support this filetype"

It's a EMCIDeviceError
0
 
LVL 5

Expert Comment

by:TheNeil
ID: 6207046
Do you have the audio CD player installed as part of Windows? I'm a bit baffled as TMediaPlayer should deal with all of this (along as Windows has the drivers installed).

I don't have an audio CD with me to test any code but from memory the following SHOULD work (as long as Windows is installed correctly)

procedure TForm1.Button1Click(Sender: TObject);
begin
  MediaPlayer1.DeviceType := dtCDAudio;
  MediaPlayer1.Filename := 'd:';
  MediaPlayer1.Open;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  MediaPlayer1.Close;
end;

I simply started a new application, dropped a TButton (Button1) and a TMediaPlayer (MediaPlayer1) and then attached the above code to the button and the close event for the form. After the button is clicked, the mediaplayer should light up and hitting the Play button will play the CD

The Neil =:(
0
 

Author Comment

by:easysoft_studios
ID: 6209708
Nop! Then I try to eject the tray, for the drive I want to play from, the tray for the other (my defualt) drive opens!

It won't ofcourse play the disc, since there isn't any, in the drive (F:) and I wan't to play from G: !!
0
 
LVL 5

Accepted Solution

by:
TheNeil earned 150 total points
ID: 6209779
Well it certainly explains the MCI error but I don't know why it won't select the drive. I've always just set the filename to be the drive letter and it's worked. Sorry but I'm out of ideas

The Neil =:(
0
 

Author Comment

by:easysoft_studios
ID: 6210794
Thanks anyway :-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
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 brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

721 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