有什么其他的方式来观看德尔福YouTube视频? [英] is there any other way to view youtube video on delphi?
问题描述
试试这个示例代码,在Delphi 7和Delphi 2007中进行了测试
$ p $ $ $ $ $ $ $ $ $ $ $ $ $ b 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 =640height =390>'+
'< param name = value =http://www.youtube.com/v/L7NWdxFAHdY&hl=en_US&feature=player_embedded&version=3>'+
'< / param>< param name =allowFullScreen value =true>'+
'< / param>< param name =allowScriptAccessvalue =always>'+
'< / param>< embed src =http://www.youtube.com/v/L7NWdxFAHdY&hl=en_US&feature=player_embedded&version=3type =application / x-shockwave-flashallowfullscreen =trueallowScr iptAccess =alwayswidth =640height =390> '+
'< / embed>< / object> '+
'< / body> '+
'< / html> '
);
end;
过程TForm1.LoadHtml(HTMLStr:String);
var
aStream:TMemoryStream;
begin
WebBrowser1.Navigate('about:blank'); //重置webbrowser
而WebBrowser1.ReadyState< READYSTATE_INTERACTIVE do //等待加载空白页面
Application.ProcessMessages;
如果已分配(WebBrowser1.Document),则
begin
aStream:= TMemoryStream.Create;
尝试
aStream.WriteBuffer(指针(HTMLStr)^,长度(HTMLStr));
aStream.Seek(0,soFromBeginning);
(WebBrowser1.Document as IPersistStreamInit).Load(TStreamAdapter.Create(aStream));
终于
aStream.Free;
end;
end;
end;
i see the http://www.delphiflash.com/demo-youtube-video on how to load flash video on delphi but its not for free. is there any other way?
like html then TWebBroeser?
sampleVideo.html //this will not work on TwebBrowser is there any other way?
<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>
i tested your html code and works ok in a TWebBrowser
try this sample code, tested in Delphi 7 and 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;
这篇关于有什么其他的方式来观看德尔福YouTube视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!