因為主線程要畫圖,所以為了不影響主線程效率,播放1個視頻要用分線程讀取,但是問題是:分線程里無法播放請問是什么原因,怎樣解決?謝謝!因為考慮到效率原因,不要用同步(Synchronize)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, WMPLib_TLB,unit2;type
TForm1 = class(TForm)
wmp: TWindowsMediaPlayer;
Button1: TButton;
procedure Button1Click(Sender: TObject);
end;var
Form1: TForm1;implementation
{$R *.dfm}
var th:TMovThread;procedure TForm1.Button1Click(Sender: TObject);
begin
th:=TMovThread.Create(false);
end;
end.
unit Unit2;
interface
uses
Classes,WMPLib_TLB;type
TMovThread = class(TThread)
protected
procedure Execute; override;
end;implementation
uses unit1;procedure TMovThread.Execute;
begin
form1.wmp.URL:='d:\mov\001.avi';
form1.wmp.DoObjectVerb(-1);
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, WMPLib_TLB,unit2;type
TForm1 = class(TForm)
wmp: TWindowsMediaPlayer;
Button1: TButton;
procedure Button1Click(Sender: TObject);
end;var
Form1: TForm1;implementation
{$R *.dfm}
var th:TMovThread;procedure TForm1.Button1Click(Sender: TObject);
begin
th:=TMovThread.Create(false);
end;
end.
unit Unit2;
interface
uses
Classes,WMPLib_TLB;type
TMovThread = class(TThread)
protected
procedure Execute; override;
end;implementation
uses unit1;procedure TMovThread.Execute;
begin
form1.wmp.URL:='d:\mov\001.avi';
form1.wmp.DoObjectVerb(-1);
end;
end.
form1.wmp.URL:='d:\mov\001.avi';
form1.wmp.DoObjectVerb(-1);