Video
TsgcHTMLComponent_Video — 渲染一个响应式 HTML5 视频或音频播放器,外加一个 YouTube 嵌入辅助功能,适用于 Delphi、C++ Builder 和 .NET。
TsgcHTMLComponent_Video — 渲染一个响应式 HTML5 视频或音频播放器,外加一个 YouTube 嵌入辅助功能,适用于 Delphi、C++ Builder 和 .NET。
一个 HTML5 媒体播放器,发出 <video> 或 <audio> 元素。设置来源和播放选项,然后读取 HTML 属性。
赋值 Src 和 MediaType,切换 Controls、Autoplay 和 Responsive,然后读取 HTML — 或使用静态的 Build 和 BuildYouTube 辅助方法。
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");
您最常使用的成员。
Src 设置媒体 URL,MediaType(TsgcHTMLMediaType:mtVideo、mtAudio)选择渲染的元素。
Controls、Autoplay、Loop 和 Muted 直接映射到 HTML5 媒体属性。
Width 和 Height 设置播放器尺寸;Responsive 将视频包装在 16:9 响应式比例容器中。
Poster 在视频播放前显示一个占位帧;VideoID 设置 DOM id。
BuildYouTube(aVideoID, aWidth, aHeight) 通过单个静态调用返回一个响应式 YouTube iframe 嵌入。
Build(aSrc, aMediaType, aControls) 通过单个静态调用返回播放器 HTML;HTML 渲染已配置的实例。