Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

multiselect cd-playing

Posted on 2001-06-16
8
Medium Priority
?
257 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
  • 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
Technology Partners: 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!

 

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

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Integration Management Part 2
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

926 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