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.

Klasa komponentu

TsgcHTMLComponent_Video

Renderuje

HTML5 <video> / <audio> media

Języki

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");

Kluczowe właściwości i metody

Składniki, po które sięgasz najczęściej.

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.

Poznawaj dalej

Wszystkie komponenty sgcHTMLPrzejrzyj pełną matrycę funkcji 60+ komponentów.
Pobierz bezpłatną wersję próbną30-dniowa wersja próbna zawiera projekty demonstracyjne 60.HTML.
CennikLicencje Single, Team i Site z pełnym kodem źródłowym.

Gotowy, aby zacząć?

Pobierz bezpłatną wersję próbną i zacznij budować interfejsy webowe w Delphi, C++ Builder i .NET.