Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Run video youtube webbrowse

Posted on 2016-09-11
10
Medium Priority
?
148 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 23

Accepted Solution

by:
Ferruccio Accalai earned 2000 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 23

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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 23

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
 
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 23

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 23

Expert Comment

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

971 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