Video
TsgcHTMLComponent_Video — render a responsive HTML5 video or audio player, plus a YouTube embed helper, in Delphi, C++ Builder and .NET.
TsgcHTMLComponent_Video — render a responsive HTML5 video or audio player, plus a YouTube embed helper, in Delphi, C++ Builder and .NET.
An HTML5 media player that emits a <video> or <audio> element. Set the source and playback options, then read the HTML property.
TsgcHTMLComponent_Video
HTML5 <video> / <audio> media
Delphi, C++ Builder, .NET
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");
The members you reach for most often.
Src sets the media URL and MediaType (TsgcHTMLMediaType: mtVideo, mtAudio) chooses the element rendered.
Controls, Autoplay, Loop and Muted map directly to the HTML5 media attributes.
Width and Height set the player dimensions; Responsive wraps a video in a 16:9 responsive ratio container.
Poster shows a placeholder frame before a video plays; VideoID sets the DOM id.
BuildYouTube(aVideoID, aWidth, aHeight) returns a responsive YouTube iframe embed in a single static call.
Build(aSrc, aMediaType, aControls) returns the player HTML in a single static call; HTML renders a configured instance.