LiveTv或视频流在Webview(Android)中无法播放

时间:2017-08-23 09:14:37

标签: java android webview

我正在尝试在WebView中播放直播电视。 WebView在页面中显示黑屏直播区域,但它没有加载和播放流。

我在android:hardwareAccelerated="true"中添加了manifest.xml。这是我的代码:

Context context = MainActivity.this;
SharedPreferences sharedPreferences;
boolean isAppInstalled = false;

CookieManager.getInstance().setAcceptCookie(true);
CookieSyncManager.createInstance(this);
CookieSyncManager.getInstance().startSync();

sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
isAppInstalled= sharedPreferences.getBoolean("isAppInstalled", false);

if (isAppInstalled==false) {
    Intent intent1 = new Intent(getApplicationContext(), MainActivity.class);
    intent1.setAction(Intent.ACTION_MAIN);
    Intent intent2 = new Intent();
    intent2.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent1);
    intent2.putExtra(Intent.EXTRA_SHORTCUT_NAME, "EXAM");
    intent2.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.drawable.ic_launcher));
    intent2.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
    getApplicationContext().sendBroadcast(intent2);
    SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putBoolean("isAppInstalled", true);
    editor.commit();
}

wv = (WebView) findViewById(R.id.wv);
wv.setWebChromeClient(new WebChromeClient());
wv.getSettings().setPluginState(WebSettings.PluginState.ON);
wv.getSettings().setJavaScriptEnabled(true);
wv.setFocusable(true);
wv.setFocusableInTouchMode(true);
wv.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
wv.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
wv.getSettings().setDomStorageEnabled(true);
wv.getSettings().setDomStorageEnabled(true);
wv.getSettings().setAppCacheEnabled(true);
wv.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
wv.loadUrl("http://exam_URL.com");
wv.setWebViewClient(new WebViewClient());

0 个答案:

没有答案