可這樣一來,就必須用directshow來實現播放與初衷不合.從此我就鑽進那死胡同,總是想將
directshow與activemove組件,directshow與mediaplay組件結合起來,利用IBasicVideo Interface來達到目標。可讀遍那與此相關的directsdk的頭文件,都沒有找那結合的辦法(那位大蝦實現那,請指點小弟,小弟先謝那!)。一直苦無進展,市面上有關的書都翻遍那。無用!(可見那些所謂的“高級編程技巧”都是狗屁,難度大一點的問題都回避,全是亂抄,tmd騙子),有一天小弟重讀The IBasicVideo interface supports the video propertIEs of a generic video window. Generally, this is a video renderer that draws video into a window on the display. (msdn),忽然記起在讀dephihelp是有一段相似
TPaintBox provides a canvas that applications can use for rendering an image.(dephihelp)遂想用paintbox可能可以,try->success,code如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, MPlayer, ExtCtrls, StdCtrls, Menus;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
filw1: TMenuItem;
open1: TMenuItem;
close1: TMenuItem;
Button1: TButton;
OpenDialog1: TOpenDialog;
PaintBox1: TPaintBox;
MediaPlayer1: TMediaPlayer;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure PaintBox1Paint(Sender: TObject);
procedure open1Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
imgbitmap:TBitmap;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
imgbitmap:=TBitmap.Create;
imgbitmap.Height:=200;
imgbitmap.Width:=200;
imgbitmap.Canvas.Rectangle(0,0,200,200);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
imgbitmap.Free;
end;
procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
PaintBox1.Canvas.CopyRect(Rect(0,0,200,200),imgbitmap.Canvas,Rect(0,0,200,200));
end;
procedure TForm1.open1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
MediaPlayer1.FileName:=OpenDialog1.FileName;
MediaPlayer1.Open;
MediaPlayer1.Display:=Form1;
MediaPlayer1.DisplayRect:=Rect(10,10,200,200);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
imgbitmap.Canvas.CopyRect(Rect(0,0,200,200),form1.Canvas,Rect(10,10,200,200));
PaintBox1.Invalidate;
imgbitmap.SaveToFile('d:1234567.bmp');
end;