还有其他方法可以在delphi上查看youtube视频吗?

时间:2010-10-14 08:46:44

标签: delphi video activex youtube flash

我看到http://www.delphiflash.com/demo-youtube-video关于如何在delphi上加载flash视频,但它不是免费的。还有其他办法吗?

喜欢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>

2 个答案:

答案 0 :(得分:5)

我测试了你的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;

答案 1 :(得分:4)

这绝对有效。我在我的应用程序(ClipMate)中尝试了它,这是一个用Delphi2007编写的剪贴板应用程序。它可以使用TWebBrowser将任何文本剪辑显示为HTML。我复制了你的示例HTML,在ClipMate中将其视为HTML,并且代理预告片正在向右发射。这是 - 在Delphi应用程序中的TWebBrowser中的HTML呈现。这个代码在D5,D7,D2007中有效,我确认它在D2009,D2010中有效。 请参阅:http://www.thornsoft.com/images/support/YoutubeClipMate.png alt text