Solved

Run video youtube webbrowse

Posted on 2016-09-11
10
44 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 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

15 Experts available now in Live!

Get 1:1 Help Now