Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- LoadHtml(AnsiString(
- '<!DOCTYPE html>' + // we need to raise compatibility mode for the new API JavaScript
- '<html>' +
- '<head>' +
- '<meta http-equiv="X-UA-Compatible" content="IE=edge"></meta>' + // compatibility mode
- '</head>' +
- '<body>' +
- '<iframe width="560" height="315" ' + // set frame width, height
- 'src="https://www.youtube.com/embed/2po4JptcOMM?' + // set source
- 'autoplay=1&rel=0&controls=0&showinfo=0" ' + // autoplay, no related videos, no info nor controls
- 'allow="autoplay" frameborder="0">' + // allow autoplay, no border
- '</iframe>'+
- '</body>'+
- '</html>'
- ));
- end;
- procedure TForm1.LoadHtml(const HTMLStr: AnsiString);
- var
- aStream : TMemoryStream;
- begin
- WebBrowser1.Navigate('about:blank');//reset the webbrowser
- while WebBrowser1.ReadyState < READYSTATE_INTERACTIVE do //wait to load the empty page
- Application.ProcessMessages;
- if Assigned(WebBrowser1.Document) then
- begin
- aStream := TMemoryStream.Create;
- try
- aStream.WriteBuffer(Pointer(HTMLStr)^, Length(HTMLStr));
- aStream.Seek(0, soFromBeginning);
- (WebBrowser1.Document as IPersistStreamInit).Load(TStreamAdapter.Create(aStream));
- finally
- aStream.Free;
- end;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement