79809094

Date: 2025-11-04 15:39:24
Score: 2
Natty:
Report link

All is prety simple:

2 case:

A) Using webview and just url:

String videoUrl = "https://www.youtube.com/embed/"+url;

Map<String, String> headers = new HashMap<>();

headers.put("Referer", "https://your_site_here.com/");

webView.loadUrl(videoUrl, headers);

B) Using webview and html file with iframe and so one:

Change from

webView.loadData(htmlContent, "text/html; charset=utf-8", null);

TO

webView.loadDataWithBaseURL("https://www.your_site_here.com/", htmlContent, "text/html", "charset=utf-8", null);

P.S: Instead of 'your_site' is possible to use something like this: "https://"+this.getPackageName()

Reasons:
  • Blacklisted phrase (1): youtube.com
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Vadim Iordachi