修改Mplayer.pas文件的TMediaPlayer.Open函数,参见下面代码的注释部分,
修改完毕后将Mplayer.pas复制到lib目录下重新编译程序(build all)即可
procedure TMediaPlayer.Open;
const
DeviceName: array[TMPDeviceTypes] of PChar = ('', 'AVIVideo', 'CDAudio', 'DAT',
'DigitalVideo', 'MMMovie', 'Other', 'Overlay', 'Scanner', 'Sequencer',
'VCR', 'Videodisc', 'WaveAudio');
var
OpenParm: TMCI_Open_Parms;
DisplayR: TRect;
begin
if MCIOpened then
Close;
{must close MCI Device first before opening another}
// FillChar(OpenParm, SizeOf(TMCI_Open_Parms), #0);
file://added by rockboy 98.12
OpenParm.dwCallback := 0;
if FDeviceType <> dtAutoSelect then
{fill in Device Type}
OpenParm.lpstrDeviceType := DeviceName[FDeviceType];
OpenParm.lpstrElementName := PChar(FElementName);
FFlags := 0;
if FUseWait then
begin
if FWait then
FFlags := mci_Wait;
FUseWait := False;
end
else
FFlags := mci_Wait;
if FUseNotify then
begin
if FNotify then
FFlags := FFlags or mci_Notify;
FUseNotify := False;
end;
// FFlags := FFlags or mci_Open_Element;
file://org code;
// modified by rockboy
if FElementName <> '' then
FFlags := FFlags or mci_Open_Element;
if FDeviceType <> dtAutoSelect then
FFlags := FFlags or mci_Open_Type;
if FShareable then
FFlags := FFlags or mci_Open_Shareable;
OpenParm.dwCallback := Handle;
FError := mciSendCommand(0, mci_Open, FFlags, Longint(@OpenParm));
if FError <> 0 then
{problem opening device}
raise EMCIDeviceError.Create(ErrorMessage)
else
{device successfully opened}
begin
MCIOpened := True;
FDeviceID := OpenParm.wDeviceID;
FFrames := Length div 10;
{default frames to step = 10% of total frames}
GetDeviceCaps;
{must first get device capabilities}
if FHasVideo then
{used for video output positioning}
begin
Display := FDisplay;
{if one was set in design mode}
DisplayR := GetDisplayRect;
FDWidth := DisplayR.Right-DisplayR.Left;
FDHeight := DisplayR.Bottom-DisplayR.Top;
end;
if (FDeviceType = dtCDAudio) or (FDeviceType = dtVideodisc) then
TimeFormat := tfTMSF;
{set timeformat to use tracks}
FAutoButtons := [btNext,btPrev];
{assumed all devices can seek to start, end}
if FCanStep then
FAutoButtons := FAutoButtons + [btStep,btBack];
if FCanPlay then
Include(FAutoButtons, btPlay);
if FCanRecord then
Include(FAutoButtons, btRecord);
if FCanEject then
Include(FAutoButtons, btEject);
if Mode = mpPlaying then
AutoButtonSet(btPlay);
{e.g. CD device}
DrawAutoButtons;
end;
end;