Skip to content

TTMSFNCWXVideoPlayer

The TTMSFNCWXVideoPlayer is a component that plays video from a URL. Browser-native playback controls can be shown inside the component, or playback can be driven entirely from code using the exposed properties, methods, and events. The component also supports the Picture-in-Picture API, letting the video float above other application windows.

Loading video

Set the URL property to an HTTP/HTTPS URL or a local file path using the file:// protocol.

procedure TForm1.FormCreate(Sender: TObject);
begin
  TMSFNCWXVideoPlayer1.URL := 'https://example.com/video/sample.mp4';
end;

When the component is ready the OnVideoInitialized event fires. Setting AutoPlay to True starts playback as soon as the source is available.

Controlling playback

procedure TForm1.Button1Click(Sender: TObject);
begin
  TMSFNCWXVideoPlayer1.Play;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  TMSFNCWXVideoPlayer1.Pause;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  TMSFNCWXVideoPlayer1.ForwardVideo(10);  // Skip ahead 10 seconds
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  TMSFNCWXVideoPlayer1.RewindVideo(10);   // Rewind 10 seconds
end;

Tracking playback state

Duration (read-only) returns the total length of the video in seconds. CurrentTime returns the current position and can also be set to seek to a specific point.

procedure TForm1.TMSFNCWXVideoPlayer1TimeUpdate(Sender: TObject);
begin
  ProgressBar1.Position := Round(TMSFNCWXVideoPlayer1.CurrentTime);
  ProgressBar1.Max      := Round(TMSFNCWXVideoPlayer1.Duration);
end;

Poster image

The Poster property accepts a URL that points to an image shown while the video is loading or before playback begins.

TMSFNCWXVideoPlayer1.Poster := 'https://example.com/images/thumbnail.jpg';

Picture-in-Picture

Picture-in-Picture (PiP) lets the video float in a small overlay above other windows. By default the feature is disabled through the browser's built-in control — set DisablePictureInPicture to False to allow it. Toggle PiP programmatically using the PictureInPicture property.

AutoPictureInPicture (web only) automatically enters PiP mode when the user switches to another browser tab.

procedure TForm1.Button5Click(Sender: TObject);
begin
  TMSFNCWXVideoPlayer1.DisablePictureInPicture := False;
  TMSFNCWXVideoPlayer1.PictureInPicture := True;
end;

procedure TForm1.TMSFNCWXVideoPlayer1PictureInPictureEnter(Sender: TObject);
begin
  Label1.Caption := 'Video is now in Picture-in-Picture mode';
end;

procedure TForm1.TMSFNCWXVideoPlayer1PictureInPictureLeave(Sender: TObject);
begin
  Label1.Caption := 'Video returned to normal view';
end;

Playback rate and volume

procedure TForm1.FormCreate(Sender: TObject);
begin
  TMSFNCWXVideoPlayer1.PlayBackRate := 1.25;  // 1.25× speed
  TMSFNCWXVideoPlayer1.Volume := 0.9;
  TMSFNCWXVideoPlayer1.Loop := False;
  TMSFNCWXVideoPlayer1.Muted := False;
end;

Properties

Property Type Default Description
AutoPlay Boolean False Automatically starts playback as soon as the source is loaded.
AutoPictureInPicture Boolean False Automatically enters Picture-in-Picture when the user navigates away from the page (WEB only).
Controls Boolean True Shows or hides the built-in browser video controls.
CurrentTime Double 0 Gets or sets the current playback position in seconds.
DisablePictureInPicture Boolean True Prevents the browser from offering the Picture-in-Picture feature. Set to False to enable.
Duration Double Read-only. Total duration of the loaded video in seconds.
EnableContextMenu Boolean False Enables the browser right-click context menu on the control.
EnableShowDebugConsole Boolean False Shows the browser developer tools console for debugging.
IsPlaying Boolean Read-only. True when video is currently playing.
Loop Boolean False Restarts playback automatically when the video ends.
Muted Boolean False Mutes the audio track of the video.
PictureInPicture Boolean False Gets or sets whether the video is currently displayed in Picture-in-Picture mode.
PlayBackRate Double 1.0 Playback speed multiplier. 1.0 is normal speed.
Poster string '' URL of an image displayed before playback starts.
Preload TTMSFNCWXMediaPreload plAuto Controls how the browser preloads the video (plNone, plMetadata, plAuto).
URL string '' The video source URL. Supports HTTP/HTTPS and the file:// protocol.
Volume Double 1.0 Playback volume. Range: 0.0 (silent) to 1.0 (maximum).

Methods

Method Description
ForwardVideo(ASeconds: Integer) Skips forward ASeconds seconds in the video.
Pause Pauses playback at the current position.
Play Starts or resumes playback.
RewindVideo(ASeconds: Integer) Rewinds ASeconds seconds in the video.

Events

Event Description
OnEnded Fires when playback reaches the end of the video.
OnError Fires when a playback error occurs.
OnMetaDataLoaded Fires when the video metadata (e.g. duration, dimensions) has been loaded.
OnPause Fires when playback is paused.
OnPictureInPictureEnter Fires when the video enters Picture-in-Picture mode.
OnPictureInPictureLeave Fires when the video leaves Picture-in-Picture mode.
OnPlay Fires when playback starts.
OnRateChange Fires when PlayBackRate changes.
OnTimeUpdate Fires continuously as CurrentTime advances during playback.
OnVideoInitialized Fires when the video component has finished initializing.
OnVolumeChange Fires when Volume or Muted changes.