testvlc.pp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. P:=TVLCMediaPlayer.Create(Nil);
  15. if ParamCount=1 then
  16. With P do
  17. try
  18. PlayFile(ParamStr(1));
  19. Repeat
  20. Sleep(100);
  21. until State in [libvlc_Ended,libvlc_Error];
  22. finally
  23. Free;
  24. end
  25. else
  26. begin
  27. LP:=TVLCMediaListPlayer.Create(Nil);
  28. try
  29. P:=TVLCMediaPlayer.Create(Nil);
  30. try
  31. LP.Player:=P;
  32. For I:=1 to ParamCount do
  33. begin
  34. TVLCMediaItem(LP.MediaItems.Add).Path:=ParamStr(i);
  35. end;
  36. LP.Play;
  37. Repeat
  38. Sleep(100);
  39. until LP.State in [libvlc_Ended,libvlc_Error];
  40. finally
  41. P.Free;
  42. end;
  43. finally
  44. LP.free;
  45. end;
  46. end;
  47. end.