From 457296317595360e916eb051f847aa736efdde2f Mon Sep 17 00:00:00 2001 From: ScreenTinker Date: Tue, 9 Jun 2026 15:36:24 -0500 Subject: [PATCH] fix(android): YouTube error 152 - embed under a third-party domain, not youtube.com The player loaded the YouTube embed via loadDataWithBaseURL with base https://www.youtube.com, so the embedding page claimed to BE youtube.com hosting a youtube.com iframe. YouTube rejects that as an invalid embed context -> 'This video is unavailable / Error 152 - 4' for every video (reproduced on a Pixel 10 / Android 16 emulator with multiple known-embeddable videos). Load the embed under a real third-party domain (EMBED_BASE = the product domain) so the referrer is a legitimate embedding site. The iframe still points at youtube.com/embed. Verified: video now plays. (The earlier base=youtube.com was the Error 153 fix; this supersedes it - a normal domain referrer fixes 153 too.) --- .../com/remotedisplay/player/player/MediaPlayerManager.kt | 2 +- .../java/com/remotedisplay/player/player/ZoneManager.kt | 2 +- .../java/com/remotedisplay/player/util/WebViewSupport.kt | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/android/app/src/main/java/com/remotedisplay/player/player/MediaPlayerManager.kt b/android/app/src/main/java/com/remotedisplay/player/player/MediaPlayerManager.kt index eec1910..c7c1c53 100644 --- a/android/app/src/main/java/com/remotedisplay/player/player/MediaPlayerManager.kt +++ b/android/app/src/main/java/com/remotedisplay/player/player/MediaPlayerManager.kt @@ -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) } } diff --git a/android/app/src/main/java/com/remotedisplay/player/player/ZoneManager.kt b/android/app/src/main/java/com/remotedisplay/player/player/ZoneManager.kt index 68c435b..a769f43 100644 --- a/android/app/src/main/java/com/remotedisplay/player/player/ZoneManager.kt +++ b/android/app/src/main/java/com/remotedisplay/player/player/ZoneManager.kt @@ -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 diff --git a/android/app/src/main/java/com/remotedisplay/player/util/WebViewSupport.kt b/android/app/src/main/java/com/remotedisplay/player/util/WebViewSupport.kt index d9cbcd8..cadc9bf 100644 --- a/android/app/src/main/java/com/remotedisplay/player/util/WebViewSupport.kt +++ b/android/app/src/main/java/com/remotedisplay/player/util/WebViewSupport.kt @@ -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 {