我看到有关如何在delphi上加载Flash视频的http://www.delphiflash.com/demo-youtube-video,但不是免费的。还有其他办法吗?
像html然后是TWebBroeser?
sampleVideo.html //这在TwebBrowser上不起作用还有其他方法吗?
<html>
<head>
</style>
<style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>
</head>
<body>
<object width="640" height="390">
<param name="movie" value="http://www.youtube.com/v/L7NWdxFAHdY&hl=en_US&feature=player_embedded&version=3">
</param><param name="allowFullScreen" value="true">
</param><param name="allowScriptAccess" value="always">
</param><embed src="http://www.youtube.com/v/L7NWdxFAHdY&hl=en_US&feature=player_embedded&version=3" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="390">
</embed></object>
</body>
</html>
最佳答案
我测试了您的html代码,并在 TWebBrowser
中正常工作
试试这个示例代码,在Delphi 7和Delphi 2007中测试
uses
ActiveX;
procedure TForm1.Button1Click(Sender: TObject);
begin
LoadHtml(
'<html> '+
'<head> '+
'</style> '+
' <style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>'+
'</head> '+
'<body> '+
' <object width="640" height="390"> '+
' <param name="movie" value="http://www.youtube.com/v/L7NWdxFAHdY&hl=en_US&feature=player_embedded&version=3"> '+
' </param><param name="allowFullScreen" value="true"> '+
' </param><param name="allowScriptAccess" value="always"> '+
' </param><embed src="http://www.youtube.com/v/L7NWdxFAHdY&hl=en_US&feature=player_embedded&version=3" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="390"> '+
' </embed></object> '+
'</body> '+
'</html> '
);
end;
procedure TForm1.LoadHtml(HTMLStr: String);
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;