我用神龙卡file播放可以,但是fmp播放总是不行,帮帮我。。(100分)

  • 主题发起人 主题发起人 youbang
  • 开始时间 开始时间
Y

youbang

Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, unit2;

type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
a:integer;
hMPEGStream : byte;
function FMPCallbackProc(bMsg:BYTE; hMPEGStream:BYTE; dwValue:DWORD):WORD;stdcall;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
unit2.FMPOpenDriver;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
unit2.FMPCloseDriver;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
if hMPEGStream<>0 then
begin
FMPStop(hMPEGStream);
FMPClose(hMPEGStream);
hMPEGStream:=0;
end;
fillchar(FMPOpenStruct,sizeof(TFMP_OPEN_STRUCT),0);
FMPOpenStruct.lpFileName:=PChar('d:/1.mpg');;
FMPOpenStruct.dwCALLback:=DWORD(@FMPCallbackProc);
hMPEGStream:=FMPOpen(FMPF_FILE,DWORD(pchar('d:/1.mpg')));
// hMPEGStream:=FMPOpen(FMPF_BUFFERS,DWORD(@FMPOpenStruct));
FMPPlay(hMPEGStream,FMPF_POS_END or FMPF_END_STOP,0);
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
FMPPlay(hMPEGStream,FMPF_POS_END or FMPF_END_STOP,0);
if hMPEGStream=0 then
begin
FMPClose(hMPEGStream);
showmessage('关闭');
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
unit2.FMPOpenDriver;
hMPEGStream:=0;
end;

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
unit2.FMPCloseDriver;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
unit2.FMPCloseDriver;
end;


Function FMPCallbackProc(bMsg: Byte; hMPEGStream: Byte; dwValue: DWORD): WORD stdcall;
var
Buf:PBuf;
i:integer;
begin
// showmessage(inttostr(bmsg));
Result:= 0;
try
Buf:= Pointer(FMPGet(hMPEGStream, FMPI_STM_USER));
case bMsg of
//创建缓冲区
FMPM_BUF_CREATE:
begin
showmessage('create');
GetMem(Buf,sizeof(TBuf));
Buf := GlobalAllocPtr(GMEM_FIXED,sizeof(TBuf));
if Buf=nil then
begin
MessageBox(0,'分配内存出错,可能是内存不足!','错误',
MB_ICONEXCLAMATION);
Result:=FMPE_DOS;
Exit;
end;

Fillchar(Buf^,sizeof(TBUF),0);

Buf.hFile:= CreateFile(pChar(FMPOpenStruct.lpFileName),//TFMP_OPEN_STRUCT(dwValue).lpFileName,
GENERIC_READ,
FILE_SHARE_READ,
Nil,
OPEN_EXISTING,
0,
0);

if (Buf.hFile=INVALID_HANDLE_VALUE) then
begin
MessageBox(0,'打开文件出错!','错误',MB_ICONEXCLAMATION);
FreeMemory(buf);
//GlobalFreePtr( Buf );
Result:=FMPE_DOS;
Exit;
end;

for i := 0 to MAX_BUF_NUMBER-1 do
GetMem(Buf.Buffer,MAX_BUF_SIZE + 2);
//GlobalAllocPtr(GMEM_FIXED, MAX_BUF_SIZE + 2);

Buf.wIndex := 0;
Buf.dwSize := 0;

//存储缓冲区结构到用户段
FMPSet(hMPEGStream,FMPI_STM_USER, DWORD(Buf) );

//在到缓冲区3/4时,触发填充下一个缓冲区
FMPSet(hMPEGStream, FMPI_BUF_POS, DWORD(Trunc(MAX_BUF_SIZE* 0.75)));

//FMPSet(hMPEGStream,FMPI_BUF_MODE,FMPF_BUF_LOOP);
end;

//关闭缓冲区
FMPM_BUF_CLOSE :
begin
showmessage('close');

CloseHandle(Buf.hFile);
for i:=0 to MAX_BUF_NUMBER-1 do
FreeMemory(Buf.Buffer);
//GlobalFreePtr(Buf.Buffer);
FreeMemory(Buf);
//GlobalFreePtr(Buf);
end;

//跳跃
FMPM_BUF_SEEK:
begin
showmessage('seek');
SetFilePointer(Buf.hFile,dwValue,nil,FILE_BEGIN );
end;

//读书据
FMPM_BUF_POS:
begin
//showmessage('readfile');
//showmessage('pos'+inttostr(Buf.wIndex));

if ReadFile(Buf.hFile,Buf.Buffer[Buf.wIndex],MAX_BUF_SIZE,Buf.dwSize,nil) then
SHOWMESSAGE('READ OK');
// showmessage('pos'+inttostr(Buf.dwSize));
end;

// 缓冲区空
FMPM_BUF_EMPTY : //showmessage('Empty');//BufEmpty;
begin
showmessage('empty'+inttostr(Buf.dwSize));
FMPSet(hMPEGStream, FMPI_BUF_SIZE,Buf.dwSize );
FMPSet(hMPEGStream, FMPI_BUF_ADDRESS, DWORD(Buf.Buffer[Buf.wIndex]));
// FMPSet( ghMPEGStream, FMPI_BUF_HANDLE, (DWORD)Buf->BufferIndex[Buf->wIndex] );
Inc(Buf.wIndex);
// showmessage(inttostr(Buf.wIndex));
if (Buf.wIndex = MAX_BUF_NUMBER) then Buf.wIndex:=0;
//Buf.wIndex := MAX_BUF_NUMBER MOD Buf.wIndex;
end;

//错误
FMPM_ERROR:
begin
showmessage('error');
end;
//操作完成
FMPM_COMPLETED :
begin
showmessage('COMPLETED');
if dwValue = 3 then // 播完
begin
//if AutoPlayNext then
// PostMessage(MainForm.Handle, FMP_NEXT, 0, 0)
//else
Showmessage('已播完,按停唱播下一首');
end;
end ;
end;
except
//异常
CloseHandle(Buf.hFile);
for i:=0 to MAX_BUF_NUMBER-1 do
FreeMemory(Buf.Buffer);
FreeMemory(Buf);
end;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
if hMPEGStream<>0 then
begin
FMPClose(hMPEGStream);
end;
end;

end.


以上是我测试的代码!
unit2如下


unit Unit2;
interface
uses Windows, mmSystem;
{------------------------- FMP Commands ---------------------}
const FMP_OPEN = $01;
const FMP_CLOSE = $02;
const FMP_PLAY = $03;
const FMP_PAUSE = $04;
const FMP_STOP = $05;
const FMP_SEEK = $06;
const FMP_STEP = $07;
const FMP_GROUP = $08;
const FMP_SET = $09;
const FMP_GET = $0A;
const FMP_CALLBACK = $0B;
const FMP_SIGNAL = $0C;
const FMP_UNLOAD = $0D;
const FMP_INIT = $0E;
const FMP_CAPTURE = $0F;
const FMP_UPDATE = $10;
const FMP_FREEZE = $12;

{------------------------- FMP Errors ---------------------}
const FMPE_DOS = $0100;
const FMPE_INVALID_FLAGS = $0200;
const FMPE_HANDLE = $0300;
const FMPE_NOT_IMPLEMENT = $0400;
const FMPE_INVALID_CMD = $0500;
const FMPE_OUT_OF_MEM = $0600;
const FMPE_INDEX = $0700;
const FMPE_TYPE = $0800;
const FMPE_WRITE = $0900;
const FMPE_TOO_MANY = $0A00;
const FMPE_ITEM_INDEX = $0B00;
const FMPE_ITEM_HANDLE = $0C00;
const FMPE_ERROR = $0D00;
const FMPE_STREAM_DATA = $0E00;
const FMPE_NOT_CDXA_DRV = $0F00;
const FMPE_HARDWARE = $1000;
const FMPE_NA = $1100;
const FMPE_VALUE = $1200;
const FMPE_TIME_FMT = $1300;
const FMPE_NOT_READY = $1400;
const FMPE_POS = $1500;
const FMPE_REFUSE = $1600;
const FMPE_INVALID_INDEX = $1700;

{------------------------- FMP Messages ---------------------}
const FMPM_BUF_POS = $01;
const FMPM_BUF_EMPTY = $02;
const FMPM_BUF_SEEK = $03;
const FMPM_BUF_CREATE = $04;
const FMPM_BUF_CLOSE = $05;
const FMPM_BUF_TOTALSIZE = $06;
const FMPM_COMPLETED = $07;
const FMPM_CANCELED = $08;
const FMPM_ERROR = $09;
const FMPM_MEM_ALLOC = $0A;
const FMPM_MEM_FREE = $0B;
const FMPM_SIGNAL = $0C;
const FMPM_FIFO_START = $0D;
const FMPM_FIFO_LOW = $0E;
const FMPM_FIFO_HIGH = $0F;
const FMPM_FIFO_DROP = $10;
const FMPM_PUSH_READ = $11;
const FMPM_PUSH_SEEK = $12;
const FMPM_PUSH_CREATE = $13;

{------------------------- FMP Flags ---------------------}
const FMPF_BUF_LOW = $00000000;
const FMPF_BUF_EMS = $00010000;
const FMPF_BUF_XMS = $00020000;

const FMPF_PASCAL = $1000;
const FMPF_C = $2000;

const FMPF_TEST = $8000;

const FMPF_INSERT = $0001;
const FMPF_REMOVE = $0002;
const FMPF_GET = $0003;
const FMPF_SELECT = $0004;
const FMPF_UNSELECT = $0005;
const FMPF_HANDLE = $0000;
const FMPF_INDEX = $0020;

const FMPF_FILE = $0001;
const FMPF_BUFFERS = $0002;
const FMPF_GROUP = $0003;
const FMPF_BROADCAST = $0004;
const FMPF_EXTEND = $0010;
const FMPF_NOACCESS = $0100;

const FMPF_UNKNOWN = $0000;
const FMPF_AUDIO = $0001;
const FMPF_VIDEO = $0002;

const FMPF_POS_START = $0100;
const FMPF_POS_SET = $0200;
const FMPF_POS_END = $0300;
const FMPF_POS_CUR = $0400;

const FMPF_DONT_UPDATE = $1000;
const FMPF_UPDATE_ALL = $2000;

const FMPF_SIG_AT = $0001;
const FMPF_SIG_EVERY = $0002;
const FMPF_SIG_REMOVE = $0003;
const FMPF_SIG_REMOVE_AT = $0004;
const FMPF_SIG_REMOVE_ALL = $0005;

const FMPE_HRD = $2000;
const FMPE_HRD_NO_DMA = $2100;
const FMPE_HRD_NO_INT = $2200;
const FMPE_HRD_NO_PORT = $2300;
const FMPE_HRD_NOT_FOUND = $2400;
const FMPE_HRD_DONT_USE = $2500;

const FMPF_END_STOP = $0000;
const FMPF_END_PAUSE = $0001;
const FMPF_END_KEEP = $0002;
const FMPF_END_REPEAT = $0004;
const FMPF_END_CLOSE = $0005;

const FMPF_PAUSED = $0001;
const FMPF_STOPPED = $0002;
const FMPF_PLAYING = $0004;
const FMPF_SEEKING = $0008;
const FMPF_STEPPING = $0010;
const FMPF_CLOSED = $0020;
const FMPF_READY = (FMPF_PAUSED or FMPF_STOPPED);

const FMPF_BYTES = $0001;
const FMPF_SAMPLES = $0002;
const FMPF_MSEC = $0003;
const FMPF_HMSF = $0004;
const FMPF_HMSC = $0005;
const FMPF_FRAMES = FMPF_SAMPLES;
const FMPF_TIME = FMPF_HMSC;
const FMPF_SMPTE = FMPF_HMSF;

const FMPF_BUF_32_BITS = $0001;
const FMPF_BUF_LOOP = $0002;

const FMPF_VID_UNKNOWN = $0000;
const FMPF_VID_MPEG = $0001;
const FMPF_VID_AVI = $0002;
const FMPF_VID_MPEG2 = $0004;

const FMPF_ALL_VGA = $0001;
const FMPF_ALL_VID = $0002;
const FMPF_KEY_VGA = $0004;
const FMPF_KEY_VID = $0008;
const FMPF_KEY_MIX = $000C;
const FMPF_KEY_CALIBRATE = $000D;

const FMPF_AUD_UNKNOWN = $0000;
const FMPF_AUD_MPEG = $0001;
const FMPF_AUD_MPEG_L1 = $0002;
const FMPF_AUD_MPEG_L2 = $0004;
const FMPF_AUD_MPEG_L3 = $0008;
const FMPF_AUD_MPEG2 = $0010;
const FMPF_AUD_MPEG2_L1 = $0020;
const FMPF_AUD_MPEG2_L2 = $0040;
const FMPF_AUD_MPEG2_L3 = $0080;
const FMPF_AUD_DOLBY_AC3 = $0100;

const FMPF_AUD_WAVE = $0010;
const FMPF_AUD_VOC = $0020;
const FMPF_AUD_PCM = $0040;
const FMPF_AUD_ADPCM = $0080;

const FMPF_AUD_STEREO = $0001;
const FMPF_AUD_JSTEREO = $0002;
const FMPF_AUD_DUAL = $0003;
const FMPF_AUD_SINGLE = $0004;
const FMPF_AUD_11 = $0000;
const FMPF_AUD_10 = $0001;
const FMPF_AUD_20 = $0002;
const FMPF_AUD_30 = $0003;
const FMPF_AUD_21 = $0004;
const FMPF_AUD_31 = $0005;
const FMPF_AUD_22 = $0006;
const FMPF_AUD_32 = $0007;

const FMPF_AUD_NO_EMPH = $0001;
const FMPF_AUD_EMPH_50 = $0002;
const FMPF_AUD_EMPH_J17 = $0003;

const FMPF_AUD_COPYRIGHT = $0001;
const FMPF_AUD_ORIGINAL = $0002;

const FMPF_GRP_UNKNOWN = $0000;
const FMPF_GRP_MPEG = $0001;
const FMPF_GRP_AVI = $0002;
const FMPF_GRP_CUSTOM = $0004;
const FMPF_GRP_MPEG2_PROGRAM = $0008;
const FMPF_GRP_MPEG2_TRANSPORT = $0010;

const FMPF_PIC_BMP = $0001;
const FMPF_PIC_DIB24 = $0002;
const FMPF_PIC_TOFILE = $0004;

const FMPF_REFUSE = $0001;
const FMPF_IGNORE = $0002;

{------------------------- FMP Index ---------------------}
const FMPI_DRV_PRODUCT = $0101;
const FMPI_DRV_VERSION = $0102;
const FMPI_DRV_MAX_CHAN = $0103;
const FMPI_DRV_VID_SUP = $0104;
const FMPI_DRV_AUD_SUP = $0105;
const FMPI_DRV_GRP_SUP = $0106;
const FMPI_DRV_HDR_STAT = $0107;
const FMPI_DRV_MEMORY = $0108;
const FMPI_DRV_ID = $0109;
const FMPI_DRV_CAPABILITY = $010A;

const FMPI_STM_TYPE = $0202;
const FMPI_STM_SOURCE = $0203;
const FMPI_STM_MODE = $0204;
const FMPI_STM_TIME_FMT = $0205;
const FMPI_STM_POSITION = $0206;
const FMPI_STM_SPEED = $0207;
const FMPI_STM_USER = $0208;
const FMPI_STM_SIZE = $0209;
const FMPI_STM_SLIDE = $020A;
const FMPI_STM_PASSWD = $0210;
const FMPI_STM_FILETYPE = $0211;
const FMPI_STM_MEMFLAGS = $0212;
const FMPI_STM_FILESIZE = $0213;
const FMPI_STM_FILEORG = $0214;
const FMPI_STM_BIT_RATE = $0215;
const FMPI_STM_NOCACHE = $0216;

const FMPI_BUF_LEFT = $0301;
const FMPI_BUF_POS = $0302;
const FMPI_BUF_ADDRESS = $0303;
const FMPI_BUF_SIZE = $0304;
const FMPI_BUF_MODE = $0305;
const FMPI_BUF_TOTALSIZE = $0306;

const FMPI_VID_TYPE = $0401;
const FMPI_VID_RATE = $0402;
const FMPI_VID_SIZE = $0403;
const FMPI_VID_ASPECT = $0404;
const FMPI_VID_BIT_RATE = $0405;
const FMPI_VID_SRC_POS = $0406;
const FMPI_VID_SRC_SIZE = $0407;
const FMPI_VID_DEST_POS = $0408;
const FMPI_VID_DEST_SIZE = $0409;
const FMPI_VID_KEY_MIN = $040A;
const FMPI_VID_KEY_MAX = $040B;
const FMPI_VID_KEY_MASK = $040C;
const FMPI_VID_KEY_COL = $040D;
const FMPI_VID_KEY_MODE = $040E;
const FMPI_VID_KEY_TYPE = $040F;
const FMPI_VID_CONTRAST = $0410;
const FMPI_VID_BRIGHTNESS = $0411;
const FMPI_VID_SATURATION = $0412;
const FMPI_VID_SLIDE = $0420;
const FMPI_VID_HWND = $0413;
const FMPI_VID_KEY_COL_INDEX = $0414;
const FMPI_VID_TV = $041b;

const FMPI_VID_DEFAULTS = $1000;
const FMPI_VID_REGISTRY = $2000;

const FMPI_AUD_TYPE = $0501;
const FMPI_AUD_RATE = $0502;
const FMPI_AUD_VOLUME = $0503;
const FMPI_AUD_BIT_RATE = $0504;
const FMPI_AUD_TREBLE = $0505;
const FMPI_AUD_BASS = $0506;
const FMPI_AUD_CHANNELS = $0507;
const FMPI_AUD_EMPH = $0508;
const FMPI_AUD_RIGHTS = $0509;
const FMPI_AUD_SHIFT = $0510;
const FMPI_AUD_BAL_L = $0511;
const FMPI_AUD_BAL_R = $0512;

const FMPI_AUD_DEFAULTS = $1000;
const FMPI_AUD_REGISTRY = $2000;

const FMPI_GRP_TYPE = $0601;
const FMPI_GRP_NB = $0602;

const FMPI_FIFO_FCNTRL = $0701;
const FMPI_FIFO_SIZE = $0702;
const FMPI_FIFO_MAX = $0703;
const FMPI_FIFO_VID_SIZE = $0704;
const FMPI_FIFO_AUD_SIZE = $0705;
const FMPI_FIFO_START = $0706;
const FMPI_FIFO_LOW = $0707;
const FMPI_FIFO_HIGH = $0708;
const FMPI_FIFO_DROP = $0709;
const FMPI_FIFO_UNIT = $070A;

const FMPI_PUSH_ASYNC = $0801;
const FMPI_PUSH_SYNC = $0802;

const FMPI_OVLY_XOFFSET = $0901;
const FMPI_OVLY_YOFFSET = $0902;
const FMPI_OVLY_VGACORRECTION = $0903;
const FMPI_OVLY_STABILITY = $0904;
const FMPI_OVLY_HFREQUENCY = $0905;
const FMPI_OVLY_USEDEFAULTFREQ = $0906;
const FMPI_OVLY_COLOR_SETTING = $0907;
const FMPI_OVLY_LOWERLEVEL = $0908;
const FMPI_OVLY_UPPERLEVEL = $0909;
const FMPI_OVLY_DELTA_CALIBRATE = $090A;
const FMPI_OVLY_COLOR_CALIBRATION = $090B;

const FMPI_OVLY_DEFAULTS = $1000;
const FMPI_OVLY_REGISTRY = $2000;

const FMPI_UPD_PALETTE = $0001;
const FMPI_UPD_VGA_MODE = $0007;
const FMPI_UPD_FRAME_POS = $0008;
const FMPI_UPD_FRAME_SIZE = $0009;

{------------------------- FMP Constants ---------------------}
const FMP_MIN_AUD_VOLUME = 0;
const FMP_MAX_AUD_VOLUME = 100;
const FMP_DEF_AUD_VOLUME = 50;

const FMP_MIN_BSC = 0; // Brightness, Saturation & Contrast
const FMP_MAX_BSC = 1000;
const FMP_DEF_BSC = 500;

// REALmagic capabilities
const FMP_CAPABILITY_BORDER_ADJUST = $0001;
const FMP_CAPABILITY_KEYCOLOR_ADJUST = $0002;
const FMP_CAPABILITY_BSC_ADJUST = $0004; // Brightness, Saturation & contrast

// RGB values used for min. medium and max color calibration
const FMP_MIN_COLOR_LEVEL = $00000000;
const FMP_MEDIUM_COLOR_LEVEL = $00808080;
const FMP_MAX_COLOR_LEVEL = $00FFFFFF;
const FMP_MEDIUM_COLOR = $80;

const FMP_LOWER_RED = $01;
const FMP_LOWER_GREEN = $02;
const FMP_LOWER_BLUE = $04;
const FMP_UPPER_RED = $10;
const FMP_UPPER_GREEN = $20;
const FMP_UPPER_BLUE = $40;

const SET_VGA = 1;
const SET_TV = 0;

const MAXFILENAME = 256; // maximum length of file pathname
const MAXCUSTFILTER = 40; // maximum size of custom filter buffer
const MAX_BUF_SIZE = 40960; // maximum buffer size (< 65534)(multiple of 1024)
const MAX_BUF_NUMBER = 20; // maximum number of buffers to use

{------------------------- FMP Structures ---------------------}
Type
COLORREF = DWORD;
Type
PFMP_OPEN_STRUCT = ^TFMP_OPEN_STRUCT;
TFMP_OPEN_STRUCT = record
lpFileName: LPTSTR;
dwCallBack: DWORD;
Reserved : array[0..7] of Byte;
end;

PFMP_PUSH_STRUCT = ^TFMP_PUSH_STRUCT;
TFMP_PUSH_STRUCT = record
dwSize : DWORD;
lpBuffer: Pointer;
end;

PBuffer = ^Byte;
PBuf= ^TBuf;
TBuffer = array[0..MAX_BUF_NUMBER - 1] of PBuffer;
TBuf = record
hFile : THandle;
dwSize: DWORD;
wIndex: WORD;
Buffer: TBuffer; //PBuffer; // char *Buffer[MAX_BUF_NUMBER];
BufferIndex: array[0..MAX_BUF_NUMBER- 1] of DWord; // DWORD BufferIndex[MAX_BUF_NUMBER];
end;

PFMP_COLOR_SETTING_STRUCT = ^FMP_COLOR_SETTING_STRUCT;
FMP_COLOR_SETTING_STRUCT = record
RGBColorKey: COLORREF;
RGBUpper : COLORREF;
RGBLower : COLORREF;
Mask : Short;
end;

var

hReelDrv: HDRVR; // RealMagic Driver Handle
FMPOpenStruct:TFMP_OPEN_STRUCT;


function FMPOpenDriver: integer;
procedure FMPCloseDriver;
function FMPCommand(Command: Byte; hMPEGStream: Byte; Flags: WORD; Value: DWORD):DWORD;
function FMPGetLastError(a: Word): DWORD;

function FMPOpen(Flags: WORD; Filename: DWORD): DWORD;
function FMPClose(hStream: Byte):DWORD;
function FMPSet(hStream: Byte; Index: WORD; Value: DWORD): DWORD;
function FMPGet(hStream: Byte; Index: WORD):DWORD;
function FMPPlay(hStream: Byte; Flags: WORD; Position: DWORD): DWORD;
function FMPStep(hStream: Byte; Flags: WORD; Position: DWORD): DWORD;
function FMPCapture(hStream: Byte; Index: WORD; Position: DWORD): DWORD;
function FMPSeek(hStream: Byte; Flags: WORD; Position: DWORD): DWORD;
function FMPSignal(hStream: Byte; Flags: WORD; Position: DWORD): DWORD;
function FMPPause(hStream: Byte):DWORD;
function FMPStop(hStream: Byte):DWORD;
function FMPGroup(hStream: Byte; Flags: WORD; Value: DWORD): DWORD;
function FMPCallback(hStream: Byte; Value: DWORD): DWORD;
function FMPFreeze(hStream: Byte; Flags: WORD; Value: DWORD): DWORD;


implementation

{--------------------------------------------------------------
* FUNCTION : FMPOpenDriver()
* DESCRIPTION : Opens IMPEG32.DLL
* RETURN : non-zero if successful, 0 if failed.
---------------------------------------------------------------}
function FMPOpenDriver: integer;
const
szDriverName = 'reeldrv';
szSectionName = 'Drivers32';
begin
hReelDrv:= OpenDriver(szDriverName, szSectionName, 0);
Result := hReelDrv;
end;

{--------------------------------------------------------------
* procedure : FMPCloseDriver()
* DESCRIPTION : Closes IMPEG32.DLL
* RETURN : NONE
---------------------------------------------------------------}
procedure FMPCloseDriver;
begin
CloseDriver(hReelDrv,0,0);
hReelDrv:= 0;
end;

{--------------------------------------------------------------
* FUNCTION : FMPCommand()
* DESCRIPTION : This function interfaces with the FMP MPEG support driver
* and sends out the requested command.
* RETURN : value from SendDriverMessage
------------------------------------------------------------------}
function FMPCommand(Command: Byte; hMPEGStream: Byte; Flags: WORD; Value: DWORD):DWORD;
begin
Result:= SendDriverMessage(hReelDrv,DRV_USER+1,
MakeLParam(MakeWord(Command,hMPEGStream),Flags),Value);
end;

{-----------------------------------------------------------------
* FUNCTION : FMPGetLastError()
* DESCRIPTION : Returns last command error code.
* RETURN : last REALmagic command error code
------------------------------------------------------------------}
function FMPGetLastError(a: Word): DWORD;
begin
Result:= SendDriverMessage(hReelDrv, DRV_USER + 2, a, 0);
end;

function FMPOpen(Flags: WORD; Filename: DWORD): DWORD;
begin
Result:= FMPCommand(FMP_OPEN, 0, Flags, Filename);
end;

function FMPClose(hStream: Byte):DWORD;
begin
Result:= FMPCommand(FMP_CLOSE, hStream, 0, 0)
end;

function FMPSet(hStream: Byte; Index: WORD; Value: DWORD): DWORD;
begin
Result:= FMPCommand(FMP_SET, hStream, Index, Value);
end;

function FMPGet(hStream: Byte; Index: WORD):DWORD;
begin
Result:= FMPCommand(FMP_GET, hStream, Index, 0);
end;

function FMPPlay(hStream: Byte; Flags: WORD; Position: DWORD): DWORD;
begin
Result:= FMPCommand(FMP_PLAY, hStream, Flags, Position);
end;

function FMPStep(hStream: Byte; Flags: WORD; Position: DWORD): DWORD;
begin
Result:= FMPCommand(FMP_STEP, hStream, Flags, Position);
end;

function FMPCapture(hStream: Byte; Index: WORD; Position: DWORD): DWORD;
begin
Result:= FMPCommand(FMP_CAPTURE, hStream, Index, Position);
end;

function FMPSeek(hStream: Byte; Flags: WORD; Position: DWORD): DWORD;
begin
Result:= FMPCommand(FMP_SEEK, hStream, Flags, Position);
end;

function FMPSignal(hStream: Byte; Flags: WORD; Position: DWORD): DWORD;
begin
Result:= FMPCommand(FMP_SIGNAL, hStream, Flags, Position);
end;

function FMPPause(hStream: Byte):DWORD;
begin
Result:= FMPCommand(FMP_PAUSE, hStream, 0, 0);
end;

function FMPStop(hStream: Byte):DWORD;
begin
Result:= FMPCommand(FMP_STOP, hStream, 0, 0);
end;

function FMPGroup(hStream: Byte; Flags: WORD; Value: DWORD): DWORD;
begin
Result:= FMPCommand(FMP_GROUP, hStream, Flags, Value);
end;

function FMPCallback(hStream: Byte; Value: DWORD): DWORD;
begin
Result:= FMPCommand(FMP_CALLBACK, hStream, FMPF_PASCAL, Value);
end;

function FMPFreeze(hStream: Byte; Flags: WORD; Value: DWORD): DWORD;
begin
Result:= FMPCommand(FMP_FREEZE, hStream, Flags, Value);
end;

end.
//-----------------------------------------------------------------------------
 
怎么都没有人回答啊?
 
看来还是靠自己比较好!原来只是一个@的问题,只要修改下面一段就可以

// 缓冲区空
FMPM_BUF_EMPTY : //showmessage('Empty');//BufEmpty;
begin
// showmessage('empty'+inttostr(Buf.dwSize));
FMPSet(hMPEGStream, FMPI_BUF_SIZE,Buf.dwSize );
FMPSet(hMPEGStream, FMPI_BUF_ADDRESS, DWORD(@Buf.Buffer[Buf.wIndex]));
Inc(Buf.wIndex);
if (Buf.wIndex = MAX_BUF_NUMBER) then Buf.wIndex:=0;
Buf.wIndex := MAX_BUF_NUMBER MOD Buf.wIndex;
end;

给自己加分!
 
你好!
我是个初学者,也想用神龙卡自己做个VOD来玩玩,能教教我吗?
 
呵呵,有意思,发贴子问人问题
到后来还要自己来回答,

还有呀,你的问题还要可以给别人上了VOD的入门课啦,
把代码贴过去,哈哈,我也能做VOD?!
 

Similar threads

后退
顶部