[Lazarus] PasLibVLC based video player does not run on Linux...

Bo Berglund bo.berglund at gmail.com
Tue Nov 21 21:17:11 CET 2023


On Tue, 21 Nov 2023 19:29:58 +0100, Bo Berglund via lazarus
<lazarus at lists.lazarus-ide.org> wrote:

>------------- Set video speed -----------------------
>To set the speed this is what I use in my code:
>  
>procedure TfrmMain.btnFFClick(Sender: TObject);
>begin
>  vlcPlayer.SetPlayRate(speSpeed.Value);
>end;
>
>It goes here:
>
>procedure TPasLibVlcPlayer.SetPlayRate(rate: Integer);
>begin
>  if (p_mi = NIL) then exit;
>  if (rate < 1) then exit;
>  if (rate > 1000) then exit;  
>  libvlc_media_player_set_rate(p_mi, rate / 100);
>end;
>
>And it winds up here:
>
>(**
> * Set movie play rate
> *
> * param p_mi the Media Player
> * param rate movie play rate to set
> * return  -1 if an error was detected, 0 otherwise (but even then, it might
> * not actually work depending on the underlying media protocol)
> *)
>
>var
>  libvlc_media_player_set_rate : function(
>    p_mi : libvlc_media_player_t_ptr;
>    rate : Single // float
>  ) : Integer; cdecl;

Now I have searched in the test application tha uses the Lazarus lclvlc package
and found this hidden inside the vlc.pp unit


procedure TCustomVLCMediaPlayer.SetPlayRate(Avalue : Integer);
begin
  if Assigned(FInstance) then
    begin
    if (Avalue< 1) then
       AValue:=1
    else if (AValue>1000) then
      AValue:=1000;
    libvlc_media_player_set_rate(FInstance,AValue/100);
    end;
end;

So there is such a function inside but how can I use it in my top level code?
I tried like this:

procedure TfrmMainVlc.btnSpeedClick(Sender: TObject);
var
  VideoSpeed: integer;
begin
  VideoSpeed := speVideoSpeed.Value;
  Fplayer.SetPlayRate(VideoSpeed);
end;

But it generates an error:
"identifier idents no member "SetPlayRate"

So I tried to trace it further and found it in unit vlc:

  TCustomVLCMediaPlayer = Class(TComponent)
  private
   ...
   procedure SetPlayRate(AValue: Integer);
   ...

So how can I get to use this function? I.e. how to publish it (it is private
now)?

If I trace it down to implementation it looks like this:

procedure TCustomVLCMediaPlayer.SetPlayRate(Avalue : Integer);
begin
  if Assigned(FInstance) then
    begin
    if (Avalue< 1) then
       AValue:=1
    else if (AValue>1000) then
      AValue:=1000;
    libvlc_media_player_set_rate(FInstance,AValue/100);
    end;
end;

So all is there but not accessible for me...


-- 
Bo Berglund
Developer in Sweden



More information about the lazarus mailing list