【问题标题】:Youtube videos don't show up in WebViewYoutube 视频不显示在 WebView 中
【发布时间】:2015-12-28 00:54:30
【问题描述】:

我刚刚在我的应用中添加了一个 webview 来加载一篇带有视频和一些文本的简单文章。 文本按原样显示,但就好像视频甚至不是一个不可见的元素。

    WebView browser = (WebView) findViewById(R.id.webArticle);
    browser.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    WebSettings settings = browser.getSettings();
    settings.setBlockNetworkLoads(false);
    settings.setBlockNetworkImage(false);
    settings.setAllowContentAccess(true);
    settings.setLoadsImagesAutomatically(true);
    settings.setAllowFileAccess(true);
    settings.setJavaScriptEnabled(true);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);

    browser.loadUrl(url);

【问题讨论】:

    标签: android video webview


    【解决方案1】:

    首先,你需要添加这个

    getSettings().setPluginsEnabled(true);
    getSettings().setUserAgent(USER_MOBILE);
    

    然后添加到应用程序清单文件(在权限下):

    android:hardwareAccelerated="true"
    

    对于演示代码Play YouTube video in WebView

    play youtube video in WebView

    【讨论】:

    • 我也有硬件加速。似乎没有解决方案对我有用!
    猜你喜欢
    • 1970-01-01
    • 2011-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-17
    • 2016-04-26
    • 2015-10-13
    • 1970-01-01
    相关资源
    最近更新 更多