Author: Tomas Rutkauskas
How to select a sound card for the TMediaPlayer when two sound cards are installed
Answer:
1 procedure send(name: string; out: integer; );
2 var3 lpset: MCI_WAVE_SET_PARMS;
4 begin5 with MediaPlayer1 do6 begin7 try8 filename := name;
9 Open;
10 lpset.wOutput := out; {number of the sound card. zero through number of 11 outputs-1}12 mciSendCommand(DeviceID, MCI_SET, MCI_WAVE_OUTPUT, longint(@lpset));
13 Play;
14 except15 on EMCIDeviceError do16 statusbar := '[OUTPUT FAILED]:' + IntToStr(out);
17 else18 ShowMessage(Exception(ExceptObject).message);
19 end;
20 end;
21 end;
22 23 24 Note that for MIDI files the right command to pass to MCI is related to the
25 sequencer port, notto the wave port, so the following adjustments have to be made:
26 27 28 var29 lpset: MCI_SEQ_SET_PARMS;
30 31 {number of the sound card. zero thru number of outputs-1}32 lpset.dwPort := mydeviceid;
33 mciSendCommand(DeviceID, MCI_SET, MCI_SEQ_SET_PORT, longint(@lpset));