2006. február 25., szombat

How to select a sound card for the TMediaPlayer when two sound cards are installed


Problem/Question/Abstract:

How to select a sound card for the TMediaPlayer when two sound cards are installed

Answer:

procedure send(name: string; out: integer; );
var
  lpset: MCI_WAVE_SET_PARMS;
begin
  with MediaPlayer1 do
  begin
    try
      filename := name;
      Open;
      lpset.wOutput := out; {number of the sound card. zero through number of outputs-1}
      mciSendCommand(DeviceID, MCI_SET, MCI_WAVE_OUTPUT, longint(@lpset));
      Play;
    except
      on EMCIDeviceError do
        statusbar := '[OUTPUT FAILED]:' + IntToStr(out);
    else
      ShowMessage(Exception(ExceptObject).Message);
    end;
  end;
end;


Note that for MIDI files the right command to pass to MCI is related to the sequencer port, not to the wave port, so the following adjustments have to be made:


var
  lpset: MCI_SEQ_SET_PARMS;

  {number of the sound card. zero thru number of outputs-1}
  lpset.dwPort := mydeviceid;
  mciSendCommand(DeviceID, MCI_SET, MCI_SEQ_SET_PORT, longint(@lpset));

Nincsenek megjegyzések:

Megjegyzés küldése