1

I have a c++ project with 2 WeBBrowser in a TableLayoutPanel they are set side by side, it's working fine I navigate normal but when I go to specific websites and play a video in fullscreen that sets my whole monitor to fullscreen instead of setting only the WeBBrowser itself, however on other websites that fits perfect in the WeBBrowser. Is there a way to change the way it displays fullscreen? I wanna make it display fullscreen in the WeB​Browser only. I think it has something to do with Web​Browser​Base.​Active​XInstance Property or Web​Browser.​Document Property. Most examples I find on the internet is for the old VB and not related to the fullscreen property.

Here's a similar question: WebBrowser control video element enter fullscreen

In other examples I've seen a method to extract the element by doing:

HtmlElement^  object = webBrowser1->Document->GetElementById("video");

But I have no idea how to handle that code in order to format that video then set it back to the WeBBrowser with fullscreen mode fixed.

EDIT:

I went further and I could get the <video> element just from a few websites, here's my method:

private: System::Void webBrowser1_DocumentCompleted(System::Object^  sender, System::Windows::Forms::WebBrowserDocumentCompletedEventArgs^  e) {
        HtmlElementCollection^  videoElements = webBrowser1->Document->GetElementsByTagName("video");
        videoElements[0]->SetAttribute("style", "width: 640px; height: 480px;"); //Not sure if this is a proper way to set an attribute in this element.
    }

The problem is that not every website gives you access to <video> tag elements, so for those websites I did the following code to make sure there were indeed no <video> tag elements in the source:

System::Diagnostics::Debug::Write(webBrowser1->DocumentText);

Then I didn't find any <video> tag element in the output, only a few websites provide me that. Why? How to really get and manipulate properly <video> tag elements in c++?

Simple
  • 827
  • 1
  • 9
  • 21
  • 1
    To find all ` – noseratio Apr 12 '19 at 20:09
  • @noseratio Thanks I looked in the page source for ` – Simple Apr 12 '19 at 22:19

1 Answers1

1

Then I didn't find any tag element in the output, only a few websites provide me that. Why?

Let me make an educated guess. For some of the pages you're referring to, the DOM is built dynamically and asynchronously. Which means, those <video> tags might simply not be there yet.

So, you might need to have some asynchronous polling logic in place that monitors DOM changes, specifically looking for <video> tags.

It might not be possible to come up with a 100% working solution to cover all cases, but have a look at my other post which deals with this problem.

noseratio
  • 59,932
  • 34
  • 208
  • 486