神龙卡流播放和加密播放代码(0)

  • 主题发起人 主题发起人 jingtao
  • 开始时间 开始时间
J

jingtao

Unregistered / Unconfirmed
GUEST, unregistred user!
03年刚毕业时弄的,其实是翻译了神龙卡的官方SDK而已:unit FmpAPI;interfaceuses 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 & Contrastconst FMP_MAX_BSC = 1000;const FMP_DEF_BSC = 500;
// REALmagic capabilitiesconst 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 calibrationconst 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 pathnameconst MAXCUSTFILTER = 40;
// maximum size of custom filter bufferconst 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 Handlefunction 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;
//-----Add-----------------------------------------------procedure SetVGA(hStream: Byte);
begin
FMPSet(hStream, FMPI_VID_TV, Set_VGA);
end;
procedure SetNTSC(hStream: Byte);
begin
FMPSet(hStream, FMPI_VID_TV, {FMPF_NTSC} $1 or Set_TV);
end;
procedure SetPAL(hStream: Byte);
begin
FMPSet(hStream, FMPI_VID_TV, {FMPF_PAL} $3 or Set_TV);
end;
procedure SetPAL60(hStream: Byte);
begin
FMPSet(hStream, FMPI_VID_TV, {FMPF_PAL60} $9 or Set_TV);
end;

end.
 
unit Unit_FrmMain;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;type TFrmMain = class(TForm) Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Memo1: TMemo;
OpenDialog1: TOpenDialog;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure FormResize(Sender: TObject);
private { Private declarations } procedure MyHwndMove(var Msg: TMessage);
message WM_MOVE;
procedure MyHwndSize(var Msg: TMessage);
message WM_SIZE;
public { Public declarations } end;
var FrmMain: TFrmMain;
ghMPEGStream: Byte = 0;
gszFileName: LPTSTR;implementationuses FmpAPI;{$R *.dfm}function MAKEDWORD(wLow, wHigh: byte): DWord;
begin
result := wlow or (whigh shl 8);
end;
(********************************************************************************* FUNCTION : FMPCallbackProc()** DESCRIPTION : FMP callback function.** PARAMETERS : bMsg - callback message* hMPEGStream - handle to MPEG stream* dwValue - value passed to callback** RETURN : 0 - success* FMPE_DOS - error encountered** COMMENTS : NONE********************************************************************************)function FMPCallbackProc(bMsg: BYTE;
hMPEGStream: BYTE;
dwValue: DWORD): WORD;
stdcall;var Buf: PBuf;
i: integer;
begin
Buf := Pointer(FMPGet(hMPEGStream, FMPI_STM_USER));
case bMsg of FMPM_BUF_CREATE: //创建缓冲区 begin
FrmMain.Memo1.Lines.Add('创建缓冲区');
//GetMem(Buf,sizeof(TBuf));
Buf := GlobalAllocPtr(GMEM_FIXED, Sizeof(TBuf));
//Buf:=GetMemory(Sizeof(TBuf));
if Buf = nil then
begin
MessageBox(0, '分配内存出错,可能是内存不足!', '错误', MB_ICONEXCLAMATION);
Result := FMPE_DOS;
Exit;
end;

FillChar(Buf^, Sizeof(TBuf), 0);
Buf^.hFile := CreateFile(gszFileName, //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);
GlobalFreePtr(Buf);
//FreeMemory(buf);
Result := FMPE_DOS;
Exit;
end;

for i := 0 to MAX_BUF_NUMBER - 1do
//GetMem(Buf^.Buffer,MAX_BUF_SIZE + 2);
Buf^.Buffer := GlobalAllocPtr(GMEM_FIXED, MAX_BUF_SIZE + 2);
//Buf^.Buffer:=GetMemory(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)));
end;

FMPM_BUF_CLOSE: //关闭缓冲区 begin
FrmMain.Memo1.Lines.Add('关闭缓冲区');
CloseHandle(Buf^.hFile);
for i := 0 to MAX_BUF_NUMBER - 1do
GlobalFreePtr(Buf^.Buffer);
//FreeMemory(Buf^.Buffer);
//FreeMemory(Buf);
GlobalFreePtr(Buf);
end;

FMPM_BUF_SEEK: //跳跃 begin
FrmMain.Memo1.Lines.Add('跳跃');
SetFilePointer(Buf^.hFile, dwValue, nil, FILE_begin
);
end;

FMPM_BUF_POS: //读数据 begin
FrmMain.Memo1.Lines.Add('读数据');
ReadFile(Buf^.hFile, Buf^.Buffer[Buf^.wIndex]^, MAX_BUF_SIZE, Buf^.dwSize, nil);
end;

FMPM_BUF_EMPTY: // 缓冲区空 begin
FrmMain.Memo1.Lines.Add('缓冲区空');
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;
end;

FMPM_COMPLETED: //操作完成 begin
if dwValue = 3 then
// 播完 begin
FrmMain.Memo1.Lines.Add('已播完');
//if ghMPEGStream <>0 then
FMPStop( ghMPEGStream );
//if AutoPlayNext then
// PostMessage(MainForm.Handle, FMP_NEXT, 0, 0) //else
//Showmessage('已播完,按停唱播下一首');
end;

end;

FMPM_ERROR: //错误 begin
FrmMain.Memo1.Lines.Add('错误');
Exit;
end;

end;

Result := 0;
end;
procedure TFrmMain.MyHwndMove(var Msg: TMessage);var Point: TPoint;
begin
FillChar(Point, Sizeof(TPoint), 0);
WindowS.ClientToScreen(Handle, Point);
FMPSet(ghMPEGStream, FMPI_VID_DEST_POS, MAKEDWORD(Point.x, Point.y));
end;
procedure TFrmMain.MyHwndSize(var Msg: TMessage);var Point: TPoint;
begin
FillChar(Point, Sizeof(TPoint), 0);
WindowS.ClientToScreen(Handle, Point);
FMPSet(ghMPEGStream, FMPI_VID_DEST_POS, MAKEWORD(Point.x, Point.y));
end;
procedure TFrmMain.FormCreate(Sender: TObject);
begin
if FMPOpenDriver = 0 then
begin
Application.MessageBox('无法打开神龙卡句柄!', pchar(Application.Title), MB_ICONINFORMATION);
Application.Terminate;
end;

end;
procedure TFrmMain.FormDestroy(Sender: TObject);
begin
if ghMPEGStream <> 0 then
begin
FMPStop(ghMPEGStream);
FMPClose(ghMPEGStream);
ghMPEGStream := 0;
end;

FMPCloseDriver();
PostQuitMessage(0);
end;
procedure TFrmMain.Button1Click(Sender: TObject);var FMPOpenStruct: TFMP_OPEN_STRUCT;
begin
if OpenDialog1.Execute then
begin
// stop and close any currently opened MPEG stream if ghMPEGStream <> 0 then
begin
FMPStop(ghMPEGStream);
FMPClose(ghMPEGStream);
ghMPEGStream := 0;
end;

FillChar(FMPOpenStruct, Sizeof(TFMP_OPEN_STRUCT), 0);
// open selected MPEG stream gszFileName := Pchar(OpenDialog1.FileName);
FMPOpenStruct.lpFileName := gszFileName;
FMPOpenStruct.dwCallBack := DWORD(@FMPCallbackProc);
ghMPEGStream := BYTE(FMPOpen(FMPF_BUFFERS, DWORD(@FMPOpenStruct)));
if ghMPEGStream = 0 then
Application.MessageBox('File open error', 'FMPBuf1 ERROR', 0);
// set video keying mode FMPSet(ghMPEGStream, FMPI_VID_KEY_MODE, FMPF_KEY_VGA);
// set video keying color FMPSet(ghMPEGStream, FMPI_VID_KEY_COL, 0);
// set video destination position SendMessage(Handle, WM_MOVE, 0, 0);
// set video destination size SendMessage(Handle, WM_SIZE, 0, 0);
end;

end;
procedure TFrmMain.Button2Click(Sender: TObject);
begin
if ghMPEGStream <> 0 then
FMPPlay(ghMPEGStream, FMPF_POS_END or FMPF_END_STOP, 0);
end;
procedure TFrmMain.Button3Click(Sender: TObject);
begin
if ghMPEGStream <> 0 then
FMPPause(ghMPEGStream);
end;
procedure TFrmMain.Button4Click(Sender: TObject);
begin
if ghMPEGStream <> 0 then
FMPStop(ghMPEGStream);
end;
procedure TFrmMain.Button5Click(Sender: TObject);
begin
if ghMPEGStream <> 0 then
begin
FMPStop(ghMPEGStream);
FMPClose(ghMPEGStream);
ghMPEGStream := 0;
end;

end;
procedure TFrmMain.FormResize(Sender: TObject);var Point: TPoint;
begin
{FillChar(Point,Sizeof(TPoint),0);
WindowS.ClientToScreen(Handle,Point);
//ClientToScreen(Point);
//ClientToScreen( hWnd, &Point );
FMPSet( ghMPEGStream, FMPI_VID_DEST_POS, MAKEWORD( Point.x, Point.y ) );
}end;

end.
 
如果需要播放加密歌曲,在这里处理: FMPM_BUF_POS: //读数据 begin
FrmMain.Memo1.Lines.Add('读数据');
ReadFile(Buf^.hFile, Buf^.Buffer[Buf^.wIndex]^, MAX_BUF_SIZE, Buf^.dwSize, nil);
end;
当时我所在的深圳新生代公司是直接简单XOR数据而已。
 
大侠出来了哈,收藏,有用时再看。
 
有没有成熟完整的双屏播放代码啊?
 
兄弟,我有一個加了密的MPEG檔案,能幫我解出來嗎?搞定了有回報的.謝謝!
 
我可以帮你试试,但不知你那具体情况是什么,加我 QQ 87797301
 
如果需要播放加密歌曲,在这里处理: FMPM_BUF_POS: //读数据 begin
FrmMain.Memo1.Lines.Add('读数据');
ReadFile(Buf^.hFile, Buf^.Buffer[Buf^.wIndex]^, MAX_BUF_SIZE, Buf^.dwSize, nil);
end;
当时我所在的深圳新生代公司是直接简单XOR数据而已。 能把加密简单举个例子吗,可以发到我的邮箱,谢谢!email: lzd123@126.com
 

Similar threads

I
回复
0
查看
585
import
I
I
回复
0
查看
587
import
I
I
回复
0
查看
588
import
I
后退
顶部