XBasic3000
XBasic3000

Reputation: 3486

is there any other way to view youtube video on delphi?

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>

Upvotes: 2

Views: 6795

Answers (2)

Chris Thornton
Chris Thornton

Reputation: 15817

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

Upvotes: 4

RRUZ
RRUZ

Reputation: 136391

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;

Upvotes: 5

Related Questions