views:

161

answers:

2

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&amp;hl=en_US&amp;feature=player_embedded&amp;version=3"&gt;
  </param><param name="allowFullScreen" value="true">
  </param><param name="allowScriptAccess" value="always">
  </param><embed src="http://www.youtube.com/v/L7NWdxFAHdY&amp;hl=en_US&amp;feature=player_embedded&amp;version=3" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="390">
  </embed></object>
</body>
</html>
+5  A: 

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&amp;hl=en_US&amp;feature=player_embedded&amp;version=3"&gt; '+
            '  </param><param name="allowFullScreen" value="true"> '+
            '  </param><param name="allowScriptAccess" value="always"> '+
            '  </param><embed src="http://www.youtube.com/v/L7NWdxFAHdY&amp;hl=en_US&amp;feature=player_embedded&amp;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;
RRUZ
+, if it works in IE it should work in TWebBrowser the same.
TOndrej
Thanx RRUZ! works fine now.
XBasic3000
+2  A: 

This definitely works. I tried it in my app (ClipMate) which is a clipboard app written in Delphi2007. It can show any text clip as HTML by using a TWebBrowser. I copied your sample HTML, viewed it as HTML within ClipMate, and the surrogates trailer fired right up. Here is is - your HTML rendering in a TWebBrowser, in a Delphi app. This same code worked in D5, D7, D2007, and I confirm that it works in D2009, D2010. See: http://www.thornsoft.com/images/support/YoutubeClipMate.pngalt text

Chris Thornton
thanx Chris Thornton! Nice apps!
XBasic3000