Cap-go / capacitor-inappbrowser

Capacitor plugin in app browser with urlChangeEvent
MIT License
58 stars 37 forks source link

Can't fullscreen videos in android #93

Closed noahjames404 closed 7 months ago

noahjames404 commented 7 months ago

Hello!

When I'm trying to play a video everything works fine except for the fullscreen option, it's disabled for some reason. I wanted to modify the code, but I'm yet to figure out how in Android Studio. Youtube embed fullscreen buttons are disabled too.

noahjames404 commented 7 months ago

Oh, I just added something to the capgo-inappbrowser. This will prevent video embeds from having disabled fullscreen buttons. I'm still new to Java, and I don't know how I could make these changes persist across my computers without getting overwritten by gradle. All I did was modify it directly from my project.

I added this in the presentWebView method.

_webView.setWebChromeClient(new MyChrome());

Just put it in the WebViewDialog class

public class MyChrome extends WebChromeClient
  {
    View fullscreen = null;

    @Override
    public void onHideCustomView()
    {
      fullscreen.setVisibility(View.GONE);
      _webView.setVisibility(View.VISIBLE);
    }
    @Override
    public void onShowCustomView(View view, CustomViewCallback callback)
    {
      _webView.setVisibility(View.GONE);

      if(fullscreen != null)
      {
        ((FrameLayout)getWindow().getDecorView()).removeView(fullscreen);
      }

      fullscreen = view;
      ((FrameLayout)getWindow().getDecorView()).addView(fullscreen, new FrameLayout.LayoutParams(-1, -1));
      fullscreen.setVisibility(View.VISIBLE);
    }
  }

Reference: https://stackoverflow.com/questions/62573334/android-webview-fullscreen-on-videos-not-working

noahjames404 commented 7 months ago

For those curious how I saved those changes I used https://github.com/ds300/patch-package. It's not the best approach but with the lack of time I have and knowing it's based on Cap Browser Plugin, I need to sleep.

Here's how I saved it.

npx patch-package @capgo/inappbrowser