Merge pull request #65 from screentinker/fix/android-youtube-embed-152

fix(android): YouTube error 152 — embed under a third-party domain (#4)
This commit is contained in:
screentinker 2026-06-09 15:36:49 -05:00 committed by GitHub
commit 64975fec88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 2 deletions

View file

@ -59,7 +59,7 @@ class MediaPlayerManager(
setBackgroundColor(android.graphics.Color.BLACK)
// Load via an embed wrapper with a valid youtube.com origin (Error 153 fix).
val html = com.remotedisplay.player.util.WebViewSupport.youtubeEmbedHtml(embedUrl)
if (html != null) loadDataWithBaseURL(com.remotedisplay.player.util.WebViewSupport.YT_BASE, html, "text/html", "UTF-8", null)
if (html != null) loadDataWithBaseURL(com.remotedisplay.player.util.WebViewSupport.EMBED_BASE, html, "text/html", "UTF-8", null)
else loadUrl(embedUrl)
}
}

View file

@ -159,7 +159,7 @@ class ZoneManager(
mimeType == "video/youtube" && !remoteUrl.isNullOrEmpty() -> {
val webView = createWebView()
val html = com.remotedisplay.player.util.WebViewSupport.youtubeEmbedHtml(remoteUrl)
if (html != null) webView.loadDataWithBaseURL(com.remotedisplay.player.util.WebViewSupport.YT_BASE, html, "text/html", "UTF-8", null)
if (html != null) webView.loadDataWithBaseURL(com.remotedisplay.player.util.WebViewSupport.EMBED_BASE, html, "text/html", "UTF-8", null)
else webView.loadUrl(remoteUrl)
webView.layoutParams = params
container.addView(webView); zoneViews[zone.id] = webView

View file

@ -23,6 +23,12 @@ import android.webkit.WebViewClient
object WebViewSupport {
const val YT_BASE = "https://www.youtube.com"
// Base URL the embed page is loaded under (its referrer to YouTube). It must be
// a normal embedding site, NOT youtube.com itself — a page claiming to be
// youtube.com embedding a youtube.com iframe is rejected as an invalid embed
// context ("This video is unavailable / Error 152"). A real third-party domain
// is what legitimate embeds use.
const val EMBED_BASE = "https://screentinker.com"
fun configure(webView: WebView, tag: String) {
webView.settings.apply {