summaryrefslogtreecommitdiff
path: root/src/3rdparty/libvlc/fpg_vlc.pas
blob: 0eb8daba27f5ca758b0ea48412632ae3a422c064 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
unit fpg_vlc;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, libvlc, vlc, fpg_main;

Type

  { TFpgVLCPlayer }

  TFpgVLCPlayer = Class(TVLCMediaPlayer)
  private
    FParentWindow: TfpgWindow;
    procedure SetParentWindowControl(AValue: TfpgWindow);
  Protected
    Procedure SetParentWindow; override;
    Procedure SetParentWindowSize(AWidth,AHeight : Cardinal); override;
    procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  Published
    Property ParentWindow : TfpgWindow Read FParentWindow Write SetParentWindowControl;
  end;

implementation

{ TFpgVLCPlayer }

procedure TFpgVLCPlayer.SetParentWindowControl(AValue: TfpgWindow);
begin
  if FParentWindow=AValue then Exit;
  If Assigned(FParentWindow) then
    FParentWindow.RemoveFreeNotification(Self);
  FParentWindow:=AValue;
  If Assigned(FParentWindow) then
    FParentWindow.FreeNotification(Self);
end;

procedure TFpgVLCPlayer.SetParentWindow;

begin
  if Assigned(ParentWindow) then
    begin
    {$IFDEF UNIX}
    libvlc_media_player_set_xwindow(Instance, ParentWindow.WinHandle);
    {$ENDIF}
    {$IFDEF MSWINDOWS}
    libvlc_media_player_set_hwnd(Instance, Pointer(ParentWindow.WinHandle));
    {$ENDIF}
    end
  else if HaveInstance then
    begin
    {$IFDEF UNIX}
    libvlc_media_player_set_xwindow(Instance, 0);
    {$ENDIF}
    {$IFDEF MSWINDOWS}
    libvlc_media_player_set_hwnd(Instance, Nil);
    {$ENDIF}
    end
end;

procedure TFpgVLCPlayer.SetParentWindowSize(AWidth, AHeight: Cardinal);
begin
  If Assigned(ParentWindow) then
    begin
    ParentWindow.Width:=AWidth;
    ParentWindow.Height:=AHeight;
    end;
end;

procedure TFpgVLCPlayer.Notification(AComponent: TComponent;
  Operation: TOperation);
begin
  Inherited;
  if (Operation=opRemove) and (AComponent=FParentWindow) then
    FParentWindow:=Nil;
end;

end.