summaryrefslogtreecommitdiff
path: root/fpcsrc/packages/libvlc/example/testvlc.pp
blob: 5f3914f638d5a454775ef24f7163fef53bd64c96 (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
program testvlc;

{$mode objfpc}{$H+}

uses
{$ifdef unix} cthreads,{$endif}
  Sysutils, Classes, math, libvlc, vlc;

Var
  P :  TVLCMediaPlayer;
  LP : TVLCMediaListPlayer;
  I : Integer;

begin
  // This is needed, or loading the VLC libraries will fail with a SIGFPE
  setexceptionmask([exInvalidOp, exDenormalized, exZeroDivide,
                     exOverflow, exUnderflow, exPrecision]);
  P:=TVLCMediaPlayer.Create(Nil);
  if ParamCount=1 then
    With P do
      try
        PlayFile(ParamStr(1));
        Repeat
          Sleep(100);
        until State in [libvlc_Ended,libvlc_Error];
      finally
        Free;
      end
  else
    begin
    LP:=TVLCMediaListPlayer.Create(Nil);
    try
      P:=TVLCMediaPlayer.Create(Nil);
      try
        LP.Player:=P;
        For I:=1 to ParamCount do
          begin
          TVLCMediaItem(LP.MediaItems.Add).Path:=ParamStr(i);
          end;
        LP.Play;
        Repeat
          Sleep(100);
        until LP.State in [libvlc_Ended,libvlc_Error];
      finally
        P.Free;
      end;
    finally
      LP.free;
    end;
    end;
end.