下面已经测试通过的:
const
MCI_SETAUDIO= $873;
MCI_SETVIDEO=$0876;
MCI_DGV_SETAUDIO_SOURCE_LEFT=1;
MCI_DGV_SETAUDIO_SOURCE_STEREO=0;
MCI_DGV_SETAUDIO_SOURCE_RIGHT=2;
MCI_DGV_SETAUDIO_SOURCE=$4004;
MCI_DGV_SETAUDIO_VALUE=$01000000;
MCI_DGV_SETAUDIO_ITEM=$00800000;
type MCI_DGV_SETAUDIO_PARMS=record
dwCallback
WORD;
dwItem
WORD;
dwValue
WORD;
dwOver
WORD;
lpstrAlgorithm
Char;
lpstrQuality
Char;
end
procedure TForm1.Button3Click(Sender: TObject);
var
s: MCI_DGV_SETAUDIO_PARMS
err:integer;
buf:array[0..1000] of char;
begin
//播放中一定要先关闭声音,否则没效果
err:=mciSendCommand(MediaPlayer1.DeviceID,MCI_SETAUDIO, MCI_SET_OFF ,integer(@s));
if(err<>0)then
begin
mciGetErrorString(err,buf,sizeof(buf) );
ShowMessage(buf);
end;
s.dwValue:=MCI_DGV_SETAUDIO_SOURCE_RIGHt;
//右声道源
s.dwItem:=MCI_DGV_SETAUDIO_SOURCE;
//下面的MCI_DGV_SETAUDIO_VALUE 一定不能少
err:=mciSendCommand(MediaPlayer1.DeviceID,MCI_SETAUDIO, MCI_DGV_SETAUDIO_VALUE or MCI_DGV_SETAUDIO_ITEM ,integer(@s));
if(err<>0)then
begin
mciGetErrorString(err,buf,sizeof(buf) );
ShowMessage(buf);
end;
//再打开声音,就是你所要的
err:=mciSendCommand(MediaPlayer1.DeviceID,MCI_SETAUDIO, MCI_SET_ON ,integer(@s));
if(err<>0)then
begin
mciGetErrorString(err,buf,sizeof(buf) );
ShowMessage(buf);
end;
end;