

Kod: Tümünü seç
[/Uses ComObj, ActiveX;
Procedure YouTube( VideoCode: String; WebBrowser : TWebBrowser; AutoPlay:Boolean );
var
strIcerik : String;
sStream : TStringStream;
IEpp : OleVariant;
begin
WebBrowser.Navigate('about:blank');
while WebBrowser.ReadyState < READYSTATE_INTERACTIVE do
Application.ProcessMessages;
strIcerik := ''
+ '<html><body>'
+ '<iframe width="854" height="510" src="https://www.youtube.com/embed/%EMBED%" frameborder="0" allowfullscreen></iframe>'
+ '</body></html> ';
strIcerik := StringReplace(strIcerik, '%EMBED%', VideoCode, [rfReplaceAll]);
if (VarIsEmpty(IEpp)) then
begin
IEpp := CreateOleObject('InternetExplorer.Application');
WebBrowser.Silent := True;
if Assigned(WebBrowser.Document) then
begin
sStream := TStringStream.Create;
try
sStream.WriteString(strIcerik);
sStream.Position := 0;
// NOT: uses'a ActiveX eklenecek... IPersistStreamInit için...
(WebBrowser.Document as IPersistStreamInit).Load(TStreamAdapter.Create(sStream));
finally
sStream.Free;
end;
end;
IEpp.Quit;
IEpp := UnAssigned;
end;
end;
Kod: Tümünü seç
Procedure YouTube( VideoCode: String; WebBrowser : TWebBrowser; AutoPlay:Boolean );
var
strIcerik : String;
sStream : TStringStream;
begin
WebBrowser.Navigate('about:blank');
while WebBrowser.ReadyState < READYSTATE_INTERACTIVE do
Application.ProcessMessages;
strIcerik := ''
+ '<html><body>'
+ '<iframe width="854" height="510" src="https://www.youtube.com/embed/%EMBED%" frameborder="0" allowfullscreen></iframe>'
+ '</body></html> ';
strIcerik := StringReplace(strIcerik, '%EMBED%', VideoCode, [rfReplaceAll]);
if Assigned(WebBrowser.Document) then
begin
sStream := TStringStream.Create;
try
sStream.WriteString(strIcerik);
sStream.Position := 0;
// NOT: uses'a ActiveX eklenecek... IPersistStreamInit için...
(WebBrowser.Document as IPersistStreamInit).Load(TStreamAdapter.Create(sStream));
finally
sStream.Free;
end;
end;
end;