ADD: wlxMplayer - wlx plugin which uses mplayer to play multimedia files

This commit is contained in:
b4rr4cuda 2008-04-22 17:16:39 +00:00
commit 580cc9ef8d
5 changed files with 480 additions and 15 deletions

View file

@ -48,7 +48,6 @@ type
edtRename: TEdit;
//---------------------
dgPanel: TDrawGrid;
// Colm:TPanelColumnsClass;
ActiveColm:String;
//---------------------
pnAltSearch: TPanel;
@ -990,11 +989,6 @@ begin
// DebugLn(Self.Height - pnlHeader.Height - pnlFooter.Height);
dgPanel.Align:=alClient;
// dgPanel.DefaultDrawing:=False;
//------------------------------------------------------
// Colm:=TPanelColumnsClass.Create;
// ColSet.GetColumnSet(ActiveColm).Load(gIni);
// dgPanel.ColCount:=ColSet.GetColumnSet(ActiveColm).ColumnsCount;
//------------------------------------------------------
dgPanel.Options:=[goFixedVertLine, goFixedHorzLine, goTabs, goRowSelect, goColSizing, goHeaderHotTracking, goHeaderPushedLook];
dgPanel.TitleStyle := tsStandard;
dgPanel.TabStop:=False;
@ -1057,10 +1051,6 @@ begin
pnlFile:=TFilePanel.Create(AOwner, dgPanel,lblLPath,lblCommandPath, lblDriveInfo, cmbCommand);
// setup column widths
//// dgPanel.ColCount:=ColSet.GetColumnSet(ActiveColm).ColumnsCount;
// if ColSet.GetColumnSet(ActiveColm).ColumnsCount>0 then
// for x:=0 to ColSet.GetColumnSet(ActiveColm).ColumnsCount-1 do
// dgPanel.ColWidths[x]:=ColSet.GetColumnSet(ActiveColm).GetColumnWidth(x);
SetColWidths;
end;
@ -1068,11 +1058,6 @@ destructor TFrameFilePanel.Destroy;
begin
if assigned(pnlFile) then
FreeAndNil(pnlFile);
//---------------------
// if assigned(Colm) then
// Colm.Free;
//---------------------
inherited Destroy;
end;

View file

@ -0,0 +1,34 @@
WlxMplayer
-------------------------------------------------------------------------
This is WLX (Lister) plugin for Double Commander.
Work only on GTK widgeset of DC.
Copyright (C) 2008 Dmitry Kolomiets (B4rr4cuda@rambler.ru)
Class TExProcess used in plugin was written by Anton Rjeshevsky.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
While the gui interface for wlx isn't developed to use this plugin add to doublecmd.ini these lines and edit them.
[Lister Plugins]
PluginCount=1
Plugin1Name=WlxMplayer
Plugin1Detect=(EXT="MPG")|(EXT="AVI")|(EXT="MPEG")|(EXT="FLV")
Plugin1Path=*Here you must write path to compiled plugin*

View file

@ -0,0 +1,66 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<PathDelim Value="/"/>
<Version Value="6"/>
<General>
<MainUnit Value="0"/>
<IconPath Value="./"/>
<TargetFileExt Value=""/>
<ActiveEditorIndexAtStart Value="0"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
<Language Value=""/>
<CharSet Value=""/>
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<Units Count="2">
<Unit0>
<Filename Value="wlxMplayer.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="wlxMplayer"/>
<CursorPos X="29" Y="80"/>
<TopLine Value="59"/>
<EditorIndex Value="0"/>
<UsageCount Value="23"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
<Filename Value="wlxplugin.pas"/>
<UnitName Value="WLXPlugin"/>
<CursorPos X="53" Y="27"/>
<TopLine Value="9"/>
<EditorIndex Value="1"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit1>
</Units>
<JumpHistory Count="0" HistoryIndex="-1"/>
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>
<CodeGeneration>
<Generate Value="Faster"/>
</CodeGeneration>
<Linking>
<Options>
<ExecutableType Value="Library"/>
</Options>
</Linking>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
</CONFIG>

View file

@ -0,0 +1,295 @@
{
WlxMplayer
-------------------------------------------------------------------------
This is WLX (Lister) plugin for Double Commander.
Work only on GTK widgeset of DC.
Copyright (C) 2008 Dmitry Kolomiets (B4rr4cuda@rambler.ru)
Class TExProcess used in plugin was written by Anton Rjeshevsky.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
}
library wlxMplayer;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
Classes,
sysutils,
gtk,gdk,glib,
process,
math,
WLXPlugin;
type
{ TExProcess }
TExProcess = class
protected
p: TProcess;
s: string;
function _GetExitStatus(): integer;
public
RezList:TStringList;
constructor Create(commandline: string);
procedure Execute;
destructor Destroy;
procedure OnReadLn(str: string);
property ExitStatus: integer read _GetExitStatus;
end;
const buf_len = 3000;
{ TExProcess }
function TExProcess._GetExitStatus(): integer;
begin
Result:=p.ExitStatus;
end;
constructor TExProcess.Create(commandline: string);
begin
RezList:=TStringList.Create;
s:='';
p:=TProcess.Create(nil);
p.CommandLine:=commandline;
p.Options:=[poUsePipes,poNoConsole];
end;
procedure TExProcess.Execute;
var
buf: string;
i, j, c, n: integer;
begin
p.Execute;
repeat
SetLength(buf, buf_len);
SetLength(buf, p.output.Read(buf[1], length(buf))); //waits for the process output
// cut the incoming stream to lines:
s:=s + buf; //add to the accumulator
repeat //detect the line breaks and cut.
i:=Pos(#13, s);
j:=Pos(#10, s);
if i=0 then i:=j;
if j=0 then j:=i;
if j = 0 then Break; //there are no complete lines yet.
OnReadLn(Copy(s, 1, min(i, j) - 1)); //return the line without the CR/LF characters
s:=Copy(s, max(i, j) + 1, length(s) - max(i, j)); //remove the line from accumulator
until false;
until buf = '';
if s <> '' then OnReadLn(s);
end;
destructor TExProcess.Destroy;
begin
RezList.Free;
p.Free;
end;
procedure TExProcess.OnReadLn(str: string);
begin
RezList.Add(str);
end;
type
//Class implementing mplayer control
{ TGtkPlayer }
TGtkPlayer=class(TThread)
public
//---------------------
widget:pGtkWidget; //the integrable widget
mySocket:PGtkWidget; //the socket
fileName:string; //filename
xid:TWindow; //X window handle
pr:TProcess; //mplayer's process
pmplayer:string; //path to mplayer
//---------------------
constructor Create(AFilename:String);
destructor destroy; override;
procedure SetParentWidget(AWidget:PGtkWidget);
protected
procedure Execute; override;
private
end;
{ TGtkPlayer }
constructor TGtkPlayer.Create(AFilename:String);
var pf:TExProcess;
begin
inherited Create(true);
filename:='"'+AFilename+'"';
pf:=TExProcess.Create('which mplayer');
pf.Execute;
pmplayer:=pf.RezList[0]+' ';
pf.Free;
writeln('PLUGIN : found mplayer in :' + pmplayer);
end;
destructor TGtkPlayer.destroy;
begin
if pr.Running then
pr.Terminate(0);
pr.Free;
inherited destroy;
end;
procedure TGtkPlayer.SetParentWidget(AWidget: PGtkWidget);
begin
widget := gtk_vbox_new(FALSE,0);
mySocket := gtk_socket_new();
gtk_container_add (GTK_CONTAINER(widget), mySocket);
gtk_widget_show(mySocket);
gtk_widget_show(widget);
//*****
gtk_container_add (GTK_CONTAINER (Awidget), widget);
gtk_widget_realize(mySocket);
gtk_widget_hide(AWidget);
xid:=(PGdkWindowPrivate(widget^.window))^.xwindow;
end;
procedure TGtkPlayer.Execute;
begin
pr:=TProcess.Create(nil);
pr.Options := Pr.Options + [poWaitOnExit,poNoConsole{,poUsePipes}]; //mplayer stops if poUsePipes used.
// pr.CommandLine:='/usr/local/bin/mplayer '+fileName+' -wid '+IntToStr(xid);
pr.CommandLine:=pmplayer+fileName+' -wid '+IntToStr(xid);
pr.Execute;
end;
//Custom class contains info for plugin windows
type
{ TPlugInfo }
TPlugInfo = class
private
fControls:TStringList;
public
fFileToLoad:string;
fShowFlags:integer;
//etc
constructor Create;
destructor Destroy; override;
function AddControl(AItem: TGtkPlayer):integer;
end;
{ TPlugInfo }
constructor TPlugInfo.Create;
begin
fControls:=TStringlist.Create;
end;
destructor TPlugInfo.Destroy;
begin
while fControls.Count>0 do
begin
TGtkPlayer(fControls.Objects[0]).Free;
fControls.Delete(0);
end;
inherited Destroy;
end;
function TPlugInfo.AddControl(AItem: TGtkPlayer): integer;
begin
fControls.AddObject(inttostr(Integer(AItem)),TObject(AItem));
end;
{Plugin main part}
var List:TStringList;
function ListLoad(ParentWin:thandle;FileToLoad:pchar;ShowFlags:integer):thandle; stdcall;
var p:TGtkPlayer; GButton1,GFix:PGtkWidget;
begin
gFix:=gtk_vbox_new(true,5);
gtk_container_add(GTK_CONTAINER(PGtkWidget(ParentWin)),gFix);
gtk_widget_show(gFix);
p:=TGtkPlayer.Create(string(FileToLoad));
p.SetParentWidget(GFix);
//Create list if none
if not assigned(List) then
List:=TStringList.Create;
//add to list new plugin window and it's info
List.AddObject(IntToStr(integer(p.widget)),TPlugInfo.Create);
with TPlugInfo(List.Objects[List.Count-1]) do
begin
fFileToLoad:=FileToLoad;
fShowFlags:=ShowFlags;
AddControl(p);
end;
Result:=integer(p.widget);
p.Resume;
end;
procedure ListCloseWindow(ListWin:thandle); stdcall;
var Index:integer; s:string;
begin
if assigned(List) then
begin
writeln('ListCloseWindow quit, List Item count: '+inttostr(List.Count));
s:=IntToStr(ListWin);
Index:=List.IndexOf(s);
if Index>-1 then
begin
TPlugInfo(List.Objects[index]).Free;
List.Delete(Index);
writeln('List item n: '+inttostr(Index)+' Deleted');
end;
//Free list if it has zero items
If List.Count=0 then List.Free;
end;
end;
exports
ListLoad,
ListCloseWindow;
begin
end.

View file

@ -0,0 +1,85 @@
// Lister API definitions.
// This unit is written by Christian Ghisler, it's from Total Commander
// Lister API Guide, which can be found at http://ghisler.com.
// Version: 1.8.
unit WLXPlugin;
interface
{$IFDEF MSWINDOWS}
uses
Windows;{$ENDIF}
const
lc_copy=1;
lc_newparams=2;
lc_selectall=3;
lc_setpercent=4;
lcp_wraptext=1;
lcp_fittowindow=2;
lcp_ansi=4;
lcp_ascii=8;
lcp_variable=12;
lcp_forceshow=16;
lcp_fitlargeronly=32;
lcp_center=64;
lcs_findfirst=1;
lcs_matchcase=2;
lcs_wholewords=4;
lcs_backwards=8;
itm_percent=$FFFE;
itm_fontstyle=$FFFD;
itm_wrap=$FFFC;
itm_fit=$FFFB;
itm_next=$FFFA;
itm_center=$FFF9;
LISTPLUGIN_OK=0;
LISTPLUGIN_ERROR=1;
const MAX_PATH=32000;
type
tListDefaultParamStruct=record
size,
PluginInterfaceVersionLow,
PluginInterfaceVersionHi:longint;
DefaultIniName:array[0..MAX_PATH-1] of char;
end;
pListDefaultParamStruct=^tListDefaultParamStruct;
type tdateformat=record
wYear,wMonth,wDay:word;
end;
pdateformat=^tdateformat;
type ttimeformat=record
wHour,wMinute,wSecond:word;
end;
ptimeformat=^ttimeformat;
type HBITMAP = type LongWord;
{ Function prototypes: Functions need to be defined exactly like this!}
{
function ListLoad(ParentWin:thandle;FileToLoad:pchar;ShowFlags:integer):thandle; stdcall;
function ListLoadNext(ParentWin,PluginWin:thandle;FileToLoad:pchar;ShowFlags:integer):integer; stdcall;
procedure ListCloseWindow(ListWin:thandle); stdcall;
procedure ListGetDetectString(DetectString:pchar;maxlen:integer); stdcall;
function ListSearchText(ListWin:thandle;SearchString:pchar;
SearchParameter:integer):integer; stdcall;
function ListSearchDialog(ListWin:thandle;FindNext:integer):integer; stdcall;
function ListSendCommand(ListWin:thandle;Command,Parameter:integer):integer; stdcall;
function ListPrint(ListWin:thandle;FileToPrint,DefPrinter:pchar;
PrintFlags:integer;var Margins:trect):integer; stdcall;
function ListNotificationReceived(ListWin:thandle;Message,wParam,lParam:integer):integer; stdcall;
procedure ListSetDefaultParams(dps:pListDefaultParamStruct); stdcall;
function ListGetPreviewBitmap(FileToLoad:pchar;width,height:integer;
contentbuf:pchar;contentbuflen:integer):hbitmap; stdcall;
}
implementation
end.