Solved

multiselect cd-playing

Posted on 2001-06-16
8
240 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

827 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