【问题标题】:is there any other way to view youtube video on delphi?有没有其他方法可以在 delphi 上查看 youtube 视频?
【发布时间】:2011-04-25 07:03:12
【问题描述】:

我看到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>

【问题讨论】:

    标签: delphi video activex youtube flash


    【解决方案1】:

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

    【讨论】:

    【解决方案2】:

    这绝对有效。我在我的应用程序(ClipMate)中尝试了它,这是一个用 Delphi2007 编写的剪贴板应用程序。它可以使用 TWebBrowser 将任何文本剪辑显示为 HTML。我复制了您的示例 HTML,在 ClipMate 中将其视为 HTML,然后代理预告片立即启动。这是 - 您在 Delphi 应用程序中的 TWebBrowser 中呈现的 HTML。相同的代码在 D5、D7、D2007 中有效,我确认它在 D2009、D2010 中有效。 见:http://www.thornsoft.com/images/support/YoutubeClipMate.png

    【讨论】:

    • 感谢克里斯·桑顿!不错的应用!
    猜你喜欢
    • 2022-08-12
    • 2022-10-06
    • 2012-06-28
    • 2012-11-28
    • 2021-08-03
    • 1970-01-01
    • 1970-01-01
    • 2016-03-01
    • 2016-05-28
    相关资源
    最近更新 更多