testvlc.pp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. program testvlc;
  2. {$mode objfpc}{$H+}
  3. uses
  4. {$ifdef unix} cthreads,{$endif}
  5. Sysutils, Classes, math, libvlc, vlc;
  6. Var
  7. P : TVLCMediaPlayer;
  8. LP : TVLCMediaListPlayer;
  9. I : Integer;
  10. begin
  11. // This is needed, or loading the VLC libraries will fail with a SIGFPE
  12. setexceptionmask([exInvalidOp, exDenormalized, exZeroDivide,
  13. exOverflow, exUnderflow, exPrecision]);
  14. With TVLCLibrary.Create(Nil) do
  15. Initialize;
  16. P:=TVLCMediaPlayer.Create(Nil);
  17. if ParamCount=1 then
  18. With P do
  19. try
  20. PlayFile(ParamStr(1));
  21. Repeat
  22. Sleep(100);
  23. until State in [libvlc_Ended,libvlc_Error];
  24. finally
  25. Free;
  26. end
  27. else
  28. begin
  29. LP:=TVLCMediaListPlayer.Create(Nil);
  30. try
  31. P:=TVLCMediaPlayer.Create(Nil);
  32. try
  33. LP.Player:=P;
  34. For I:=1 to ParamCount do
  35. begin
  36. TVLCMediaItem(LP.MediaItems.Add).Path:=ParamStr(i);
  37. end;
  38. LP.Play;
  39. Repeat
  40. Sleep(100);
  41. until LP.State in [libvlc_Ended,libvlc_Error];
  42. finally
  43. P.Free;
  44. end;
  45. finally
  46. LP.free;
  47. end;
  48. end;
  49. end.