You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android平台部分YouTube iframe视频无法播放问题求助

Android WebView通过iframe集成YouTube视频部分无法播放,iOS/Web平台正常

我们在Android、iOS及Web(Angular)三个平台通过iframe集成YouTube视频,仅Android平台存在部分视频无法播放的问题,iOS与Web平台可正常播放。以下是相关信息:

Android端无法播放的视频iframe

<iframe width="100%" height="100%" src="https://www.youtube.com/embed/DwenbrW2Ljs" title="YouTube video player" frameborder="0" allow="accelerometer; clipboard-write; encrypted-media; gyroscope; web-share" allowfullscreen></iframe>

可正常播放的视频iframe

<iframe width="100%" height="100%" src="https://www.youtube.com/embed/1wntBImcNqU" title="YouTube video player" frameborder="0" allow="accelerometer; clipboard-write; encrypted-media; gyroscope; web-share" allowfullscreen></iframe>
<iframe width="100%" height="100%" src="https://www.youtube.com/embed/KS_letyBOZ8" title="YouTube video player" frameborder="0" allow="accelerometer; clipboard-write; encrypted-media; gyroscope; web-share" allowfullscreen></iframe>

各平台截图

  • Android端无法播放的视频预览截图:
    Android端无法播放的视频预览
  • iOS端该视频正常预览截图:
    iOS端该视频正常预览
  • Web端该视频正常预览截图:
    Web端该视频正常预览

Android端实现代码

val webView = WebView(root.context)
webView.layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 230.dpToPx())
webView.setBackgroundColor(Color.TRANSPARENT)
webView.settings.javaScriptEnabled = true
webView.settings.domStorageEnabled = true
webView.webChromeClient = WebChromeClient()
webView.loadData(iFrame, "text/html", "utf-8")
linearYoutube.addView(webView)

我们已尝试寻找解决方案但未果,恳请协助排查此问题。

内容的提问来源于stack exchange,提问作者Chirag Savsani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 04:07:16