Closed HamzaIsrar12 closed 5 months ago
Currently the webview is not exposed through the API. Could you clarify why you need to access it?
Sure, I have an Analytics SDK that injects JavaScript into webviews to automatically capture relevant events. However, this feature is somewhat buggy for certain webviews, and in our case, it's conflicting with the YouTube Player View.
When I tap the "YouTube" button in the player, instead of redirecting me to the external browser, it opens the content within the webview, which then crashes in some way.
So disableInjection
is a method from your analytics SDK? are you sure they don't have other ways to do exclude webviews? I assume they are using reflection to inject code in all webviews?
Technically you could also use reflection to access the webview. Not optimal, but maybe enough to have a workaround.
Let me know.
Yes, the disableInjection
method is a feature of the analytics SDK. I've contacted their support team about this issue, and they are aware of it, but there hasn't been an update yet.
I experimented with reflection, and it seems to be functioning correctly for me now. I'm just ensuring that it won't create any issues when Proguard is applied. 👍🏻
Thank you for your help, Peir. 😄
It encountered a Proguard issue, but I resolved it by incorporating the following keep rule:
-keep class com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.** { *; }
✨ 🚀
Nice, I'm glad it worked :)
Question
Hi Pier,
Is it possible to access the underlying WebView? I have an SDK that runs JavaScript on all WebViews, but I need to disable it for this particular WebView. This SDK is preventing me from opening YouTube videos in the external browser. Specifically, I need to call a
disableInjection(webView: WebView)
method and pass this WebView instance.Thank you!