mirror of
https://github.com/screentinker/screentinker.git
synced 2026-06-14 18:22:46 -06:00
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:
commit
64975fec88
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue