And*_*rew 2 embed video android webview android-webview
我想将以下视频嵌入到 Android Web 视图中: https://www.espn.com.ar/core/video/iframe ?id=6034792&endcard=false&omniReportSuite=wdgespg
我尝试了不同的网络视图方法,但没有任何结果。没有错误,我只能查看播放器,但无法播放。
//显现:
<uses-permission android:name="android.permission.INTERNET" />
<application
...
android:hardwareAccelerated="true">
Run Code Online (Sandbox Code Playgroud)
//代码:
String html = String.format("<iframe src=\"%s\" width=\"340\" height=\"313\" style=\"border:none;overflow:hidden\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\"></iframe>", url.getSrc());
wview.loadDataWithBaseURL("https://www.espn.com.ar", html, "text/html", "UTF-8", null);
//OR
wview.loadUrl(url.getSrc());
//MY WEBVIEW:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:wheel="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true">
<WebView
android:id="@+id/wview"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
小智 5
请检查下面的代码,它对我来说工作正常,在清单上添加 android:hardwareAccelerated="true"
WebView webview = findViewById(R.id.myweb);
webview.setWebChromeClient(new WebChromeClient());
webview.getSettings().setLoadsImagesAutomatically(true);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setAllowFileAccess(true);
webview.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webview.getSettings().setPluginState(WebSettings.PluginState.ON);
webview.getSettings().setMediaPlaybackRequiresUserGesture(false);
webview.getSettings().setDomStorageEnabled(true);
webview.getSettings().setAppCacheMaxSize(1024 * 8);
webview.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
webview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webview.requestFocus(View.FOCUS_DOWN);
webview.getSettings().setAppCacheEnabled(true);
webview.loadUrl("https://www.espn.com.ar");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4519 次 |
| 最近记录: |