Video

TsgcHTMLComponent_Video — render a responsive HTML5 video or audio player, plus a YouTube embed helper, in Delphi, C++ Builder and .NET.

TsgcHTMLComponent_Video

An HTML5 media player that emits a <video> or <audio> element. Set the source and playback options, then read the HTML property.

Component class

TsgcHTMLComponent_Video

Renders

HTML5 <video> / <audio> media

Languages

Delphi, C++ Builder, .NET

Create it, set the source, render it

Assign Src and MediaType, toggle Controls, Autoplay and Responsive, then read HTML — or use the static Build and BuildYouTube helpers.

uses
  sgcHTML_Component_Video;

var
  oVid: TsgcHTMLComponent_Video;
begin
  oVid := TsgcHTMLComponent_Video.Create(nil);
  try
    oVid.Src := '/media/intro.mp4';
    oVid.MediaType := mtVideo;
    oVid.Controls := True;
    oVid.Poster := '/media/intro.jpg';
    oVid.Responsive := True;

    WebModule.Response := oVid.HTML;   // <video> element
  finally
    oVid.Free;
  end;
end;

// Or in a single line with the static helpers:
Result := TsgcHTMLComponent_Video.Build('/media/intro.mp4', mtVideo, True);
Result := TsgcHTMLComponent_Video.BuildYouTube('dQw4w9WgXcQ', '100%', '400');
// includes: sgcHTML_Component_Video.hpp

TsgcHTMLComponent_Video *oVid = new TsgcHTMLComponent_Video(NULL);
try
{
  oVid->Src = "/media/intro.mp4";
  oVid->MediaType = mtVideo;
  oVid->Controls = true;
  oVid->Poster = "/media/intro.jpg";
  oVid->Responsive = true;

  String html = oVid->HTML;   // <video> element
}
__finally
{
  delete oVid;
}

// Or in a single line with the static helpers:
String html = TsgcHTMLComponent_Video::Build("/media/intro.mp4", mtVideo, true);
String yt = TsgcHTMLComponent_Video::BuildYouTube("dQw4w9WgXcQ", "100%", "400");
using esegece.sgcWebSockets;

var video = new TsgcHTMLComponent_Video();
video.Src = "/media/intro.mp4";
video.MediaType = TsgcHTMLMediaType.mtVideo;
video.Controls = true;
video.Poster = "/media/intro.jpg";
video.Responsive = true;

string html = video.HTML;   // <video> element

// Or in a single line with the static helpers:
string oneLine = TsgcHTMLComponent_Video.Build("/media/intro.mp4",
    TsgcHTMLMediaType.mtVideo, true);
string yt = TsgcHTMLComponent_Video.BuildYouTube("dQw4w9WgXcQ", "100%", "400");

Key properties & methods

The members you reach for most often.

Source

Src sets the media URL and MediaType (TsgcHTMLMediaType: mtVideo, mtAudio) chooses the element rendered.

Playback

Controls, Autoplay, Loop and Muted map directly to the HTML5 media attributes.

Sizing

Width and Height set the player dimensions; Responsive wraps a video in a 16:9 responsive ratio container.

Poster

Poster shows a placeholder frame before a video plays; VideoID sets the DOM id.

YouTube

BuildYouTube(aVideoID, aWidth, aHeight) returns a responsive YouTube iframe embed in a single static call.

One-line build

Build(aSrc, aMediaType, aControls) returns the player HTML in a single static call; HTML renders a configured instance.

Keep exploring

All sgcHTML ComponentsBrowse the full feature matrix of 60+ components.
Download Free TrialThe 30-day trial ships the 60.HTML demo projects.
PricingSingle, Team and Site licenses with full source code.

Ready to Get Started?

Download the free trial and start building web UIs in Delphi, C++ Builder and .NET.