Solved

Run video youtube webbrowse

Posted on 2016-09-11
10
57 Views
Last Modified: 2016-09-12
Hello guys

I tried this in my delphi X7, but it didn't work

I want to know if it works in your delphi, maybe I am having some troble with my delphi and TwebBrowse


http://stackoverflow.com/questions/3931487/is-there-any-other-way-to-view-youtube-video-on-delphi

thanks
Alex
0
Comment
Question by:hidrau
  • 5
  • 5
10 Comments
 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 500 total points
ID: 41794247
That code doesn't work also on my Delphi 2010
but after a little change in code it worked so try this and see if it works in your delphi xe7

procedure TForm1.LoadHtml(HTMLStr: String);
var
  aStream: TMemoryStream;
  doc: variant;
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
    doc := WebBrowser1.Document;
    doc.clear;
    doc.write(HTMLStr);
    doc.close;
  end;
end;

Open in new window

0
 
LVL 1

Author Comment

by:hidrau
ID: 41794290
Hello Ferruccio Accalai,

thanks a lot for your reply and help.

I used your code but nothing was load in my webbrowse.

did you also use the html code that comes with that example?
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 41794295
Yes I've tested that code and in a first try it didn't work so I've changed the html (the same of course) assignment as posted above and it worked
The test result
1
 
LVL 1

Author Comment

by:hidrau
ID: 41794316
it is strange because I can run youtube site and run some video from it when I load the youtube site, but I can load the video through that code.

If I load the youtube site this way:   WebBrowser1.Navigate('www.youtube.com.br') it works :(

I am trying to understand what it could be
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 41794356
Try to navigate the same code from a local html page.
Give a try to this just to see if  it works this way (this example doesn't need activex)

procedure TForm1.Button2Click(Sender: TObject);
var
  ls: TSTrings;
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
    ls := tstringlist.create;
    try
      ls.text := '<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> ';
      ls.savetofile('c:\loadwb.htm');
    finally
      ls.free;
    end;
    WebBrowser1.Navigate('file://c:\loadwb.htm');
  end;
end;

Open in new window

1
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:hidrau
ID: 41794483
I noticed that the problem must be in IE, because I ran the code in IE and it didn't work but in Chrome, it worked fine.

As webbrowse works with IE, something wrong in my IE.

at the first time, the IE asks to allow the activex and even I allow it, the page doesn't open in my IE.

The version of my IE is 11

Just to finish the issue, could you send me the exe file so that I can test it here?

thanks again
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 41794531
Cannot upload an exe file here, but you could compile my test project attached hereWB.zip
0
 
LVL 1

Author Comment

by:hidrau
ID: 41794552
The problem is my computer, it works with yours and mine exe in other machine.
0
 
LVL 1

Author Closing Comment

by:hidrau
ID: 41794554
thanks a lot for your help
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 41794566
Glad to have helped you
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now