Solved

multiselect cd-playing

Posted on 2001-06-16
8
248 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
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!

 

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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month4 days, 12 hours left to enroll

635 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