Is there any other way to watch youtube videos on delphi?

I see http://www.delphiflash.com/demo-youtube-video on how to upload flash video to delphi, but it's not free. Is there another way?

like html then TWebBroeser?

sampleVideo.html // this won't 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>

      

+2


source to share


2 answers


i checked your html code and it worked fine in 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;

      

+5


source


It definitely works. I tried this in my application (ClipMate) which is a clipboard application written in Delphi2007. It can display any HTML text clip using TWebBrowser. I copied your sample HTML, viewed it as HTML in ClipMate, and the surrogate trailer shot straight up. Here is your HTML rendering in TWebBrowser, in a Delphi application. This same code worked in D5, D7, D2007 and I confirm it works in D2009, D2010. See: http://www.thornsoft.com/images/support/YoutubeClipMate.png alt text



+3


source







All Articles