About 5 years ago I have created a video player/editor tool with Lazarus/Fpc and using PasLibVlc for the video handling functionality.
This has worked fine for handling downloaded mp4 videos.
I have added support for *any* video file type via a a fileopen source item "other media files" so I can actually load for example ts files (transport stream), which unlike mp4 files can be viewed while the download is on-going.
This works very well for static ts files but if the file is being written at the same time as it is being viewed in the player I need to set the player's media length dynamically as it is being written by another process.
How can this be accomplished?
I have two event handlers in the application which update the screen as the video plays:
//Update display of current video file duration
procedure TfrmMain.vlcPlayerMediaPlayerLengthChanged(Sender: TObject; time: Int64);
var
P: int64;
begin
P := vlcPlayer.GetVideoLenInMs();
pgbProgress.Max := P div 1000;
lblTime.Caption := vlcPlayer.GetVideoLenStr('hh:mm:ss');
lblLength.Caption := vlcPlayer.GetVideoLenStr('hh:mm:ss');
end;
//Update display of the current playing position of the video
procedure TfrmMain.vlcPlayerMediaPlayerTimeChanged(Sender: TObject; time: Int64);
var
P, L: int64;
begin
if FUserAction = 0 then// not dragging with mouse
begin
P := vlcPlayer.GetVideoPosInMs() div 1000;
L := vlcPlayer.GetVideoLenInMs() div 1000;
L := L - P;
pgbProgress.Position := P + 1;
pgbProgress.Position := P ;
lblTime.Caption := vlcPlayer.GetVideoPosStr('hh:mm:ss.ms');
lblSeconds.Caption := IntToStr(P);
lblRemaining.Caption := FormatTimeDiff(L);
end;
end;
Unfortunately the vlcPlayerMediaPlayerLengthChanged() proc seems
not to be triggered or else it does not work properly when the media file being played changes its size as new content is written to the end of the file.
Have I misunderstood the way these events work and is there something else I have to do in order to make it monitor the changing length of the video file being written and played at the same time?
It has to change the progressbar's max value dynamically in order for the progress to display properly for example.
I wonder if the PasLibVlc library actually triggers the event when the file is written or if it is only ever triggered when the file is initially being loaded from disk?
Any ideas, please?
PS: I am using an HP workstation laptop running Windows10 and the latest version of VLC (just checked). DS