WebMultimediaPlayer loads file twice before playing


I have a xdata service which serves video file for player and there is a problem with slowness.
When I started to to solve problem, I found out that the file is always loaded twice before playing start.

I tested with dialogbox that code is called only once.

WebMultimediaPlayer1.URL := Srv+'/ProTubeService/GetVideo/?VideoId='+WebClientDataSet2.FieldByName('video_id').AsString+'&LangId='+LangsWebCDS.FieldByName('language_code').AsString+'&Authorization=' + Auth;

{ msgdlg:= TWebMessageDlg.Create(self);
msgdlg.Parent := Self;
msgdlg.ElementTitleClassName := 'dlgtitle';
msgdlg.ElementContentClassName := 'dlgcontent';
msgdlg.ElementDialogClassName := 'dlg';
msgdlg.ElementButtonClassName := 'btn btn-primary';
msgdlg.Opacity := 0.3;

Where do you see it being loaded twice?


I have logging on the service.

I cannot see a reason.
I suggest to add console.log() statements to TMultimediaPlayer.UpdateElement in WEBLib.ExtCtrls.pas to see if for some reason this is called multiple times from the moment you set the URL.


it doesn't load it when URL is set.
It loads it twice when play is called from code or when play is pressed at player.

You can look application at https://protube.qprojects.fi/ .

I cannot see a reason for this that the Object Pascal class for the TWebMultiMediaPlayer would be causing this.
Can you separately test this from HTML direct with code like in the example:

Perhaps, the browser video element performs a HTTP query info to get information first before performing the actual HTTP request to start the streaming. But this is something we have at Object Pascal level class no control over.

It seems that problem is just that.
I test it with html and result was same that it get loaded twice.

<video width="500px" height="500px"	controls="controls">

<source src="https://protube.qprojects.fi:2001/xxx/?VideoId=39&LangId=uk&Authorization=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJVc2VySWQiOjEsIlVzZXIiOiJndWVzdCIsInNjb3BlIjoicmVhZGVyIiwiaXNzIjoiWERhdGEgU2VydmVyIiwiZXhwIjoxNjUxODI1NTY1fQ.MwAmFOnzhtqiURIuuD9PLRqlSKDhq0KZfZbTZ47my0s"

5/6/2022 11:17:04 AM F:\projekti\omat\www\ProTube\Srv\video\uk\version_0.mp4 size:45686535
5/6/2022 11:17:05 AM F:\projekti\omat\www\ProTube\Srv\video\uk\version_0.mp4 size:45686535

Do you have any contact to developers of that video player, if they could say how to avoid this ?

It might be worth checking with a difference browser to see if there is a different behavior.


yes there is different behavior

Chrome + Edge windows 10 2 times
firefox windows 10 1 times
Samsung browser at samsung phone 4 times
Chrome at samsung phone 2 times
Edge at samsung phone 1 times

As it appears, this is really browser related and browser specific and sadly, not something we change the behavior of.

I'm serving videos to authenticated users in one of my projects. For this, I first tried to use Xdata server entirely, but XData server is not exactly the appropriate method for this job. I do this as follows:

User submits authentication and video filename to a function (GetVideoURL) on Xdata server. After Xdata server authentication, it creates a "presigned URL" for the video file stored in a private storage on Amazon S3 or Google Storage. The "presigned URL" created is valid only for a certain period of time. Web Core assigns this result (presigned URL) obtained from GetVideoURL function to video src.

Thus, XData server only performs the task of authentication and generating presigned URL. The video file is served by Amazon or Google servers.

When the browser video src is assigned, it can send multiple requests to the server depending on the situation (video preload attribute etc.). This may be because of pulling "metadata" information about the video. In order to meet this, the Xdata server needs to understand the incoming method options and header parameters and serve accordingly, but Xdata is not optimized for this.

I hope this experience helps some.