unit jfMMSystem;
interface
uses
Windows, Messages, SysUtils,Dialogs, Variants, MMSystem,Classes;
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 = $00004004;
MCI_DGV_SETAUDIO_VALUE = $01000000;
MCI_DGV_SETAUDIO_ITEM = $00800000;
MCI_DGV_SETAUDIO_STREAM = $00004003;
MCI_DGV_SETAUDIO_VOLUME = $00004002;
type MCI_DGV_SETAUDIO_PARMS=record
dwCallback
WORD;
dwItem
WORD;
dwValue
WORD;
dwOver
WORD;
lpstrAlgorithm
Char;
lpstrQuality
Char;
end
function PlayVod(DeviceID:Word;FileName:string;SoundTrack:Byte):Byte;
implementation
//播放函数
function PlayVod(DeviceID:Word;FileName:string;SoundTrack:Byte):Byte;
var
s: MCI_DGV_SETAUDIO_PARMS
err:integer;
buf:array[0..1000] of char;
begin
Result:=1;
if (UpperCase(ExtractFileExt(FileName))='.DAT') or (UpperCase(ExtractFileExt(FileName))='.MP2') then
//转换VCD文件声道.
begin
//先关闭声音
err:=mciSendCommand(DeviceID,MCI_SETAUDIO,MCI_WAIT or MCI_SET_OFF ,integer(@s));
if(err<>0)then
begin
mciGetErrorString(err,buf,sizeof(buf) );
ShowMessage(buf);
end;
case SoundTrack of
0: //全声道声道
begin
s.dwValue:=0;
s.dwItem:=MCI_DGV_SETAUDIO_SOURCE;
end;
1: //左声道
begin
s.dwValue:=1;
s.dwItem:=MCI_DGV_SETAUDIO_SOURCE;
end;
2://右声道
begin
s.dwValue:=2;
s.dwItem:=MCI_DGV_SETAUDIO_SOURCE;
end;
end;
err:=mciSendCommand(DeviceID,MCI_SETAUDIO,MCI_WAIT or
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(DeviceID,MCI_SETAUDIO,
MCI_WAIT or MCI_SET_ON ,integer(@s));
if(err<>0)then
begin
mciGetErrorString(err,buf,sizeof(buf) );
ShowMessage(buf);
end;
end
else
if (UpperCase(ExtractFileExt(FileName))='.VOB') or (UpperCase(ExtractFileExt(FileName))='.MPG') then
//转换DVD文件声道.
begin
err:=mciSendCommand(DeviceID,MCI_SETAUDIO,MCI_WAIT or MCI_SET_On ,integer(@s));
if(err<>0)then
begin
mciGetErrorString(err,buf,sizeof(buf) );
ShowMessage(buf);
end;
case SoundTrack of
2: s.dwValue:=2;//左声道
1: s.dwValue:=1;
//右声道
end;
s.dwItem:=MCI_DGV_SETAUDIO_STREAM;
mciSendCommand(DeviceID,MCI_SETAUDIO,MCI_DGV_SETAUDIO_VALUE or MCI_DGV_SETAUDIO_ITEM,integer(@s));
end
else
Result:=0;
end;
end.