在WebView中真的需要一些帮助

时间:2014-03-19 11:07:12

标签: android video android-webview

为什么我不能正常播放网站上的视频。我正在尝试使用Webview。什么时候在VideoView中,视频有效,但没有我想要的那么多(没有滚动条)。因此,我尝试使用WebView。此代码显示视频,但不播放。当我向我需要的网站插入链接时,我看到一个白色的屏幕。也在手机上测试过。在manifest.xml我已经授予了互联网权限。

wv = (WebView) findViewById(R.id.webView);
        wv.setWebChromeClient(new WebChromeClient());
        wv.getSettings().setAllowFileAccess(true);
        wv.getSettings().setJavaScriptEnabled(true);
        wv.getSettings().setPluginState(WebSettings.PluginState.ON);
        wv.setWebViewClient(new WebViewClient());
        wv.setBackgroundColor(0x00000000);
        wv.getSettings().setBuiltInZoomControls(true);
        String html = "<iframe width='420' height='345' src='http://m.ochepyatki.ru/video.php?vkey=be38112&f=11395221100' frameborder='0' allowfullscreen></iframe>";
        wv.loadDataWithBaseURL(null, html, "text/html", "UTF-8", null);



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.example.MyParserIP"
          android:versionCode="1"
          android:versionName="1.0">
    <uses-sdk android:minSdkVersion="12"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <application android:label="@string/app_name" android:icon="@drawable/ic_launcher" android:hardwareAccelerated="true">
        <activity android:name="MyActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>
</manifest>

不起作用

1 个答案:

答案 0 :(得分:1)

你能检查你添加的Manifest.xml

吗? 应用程序标记中的

android:hardwareAccelerated="true"。如果你没有添加,那么在android manifest.xml中添加它。

OR

您可以在活动中执行此方法。

if(Build.VERSION.SDK_INT >= 11)
        webview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);