尝试在WebView中显示视频时出现问题

时间:2015-11-09 20:06:10

标签: android webview

各位大家好

我试图在网页上显示来自网址的视频,它是流媒体,这是网址的一个例子:

https://rapidresponse-us-oem-relay11.mios.com/relay/relay/relay/device/36050280/session/0144E086FE4180BB14CFA858AE7FE05757ED73/port_3480/data_request?id=serve_stream&cam=12&stream=29&res=low

我已经完成了IOS应用程序并且工作正常,所以我知道该网址没有任何问题。

我尝试使用以下代码在WebView中显示视频:

if(message.getMessageType() == 0) {
            webView_camera.getSettings().setDomStorageEnabled(true);
            webView_camera.loadUrl(cameraUrl);

        }

我试着用这个

webView_camera.setWebChromeClient(new WebChromeClient());

但它不起作用

当应用程序运行时,只在webview中显示无法加载图像的图标。

我对此很新,所以任何帮助都会受到赞赏

更新

这是我从android获取的日志:

11-11 09:32:25.268 8316-8316/com.realstatediary.jperera.rapidsentrymaster I/WebViewFactory: Loading com.google.android.webview version 46.0.2490.76 (code 249007600)
11-11 09:32:25.294 8316-8316/com.realstatediary.jperera.rapidsentrymaster I/cr.library_loader: Time to load native libraries: 2 ms (timestamps 2963-2965)
11-11 09:32:25.294 8316-8316/com.realstatediary.jperera.rapidsentrymaster I/cr.library_loader: Expected native library version number "46.0.2490.76", actual native library version number "46.0.2490.76"
11-11 09:32:25.306 8316-8316/com.realstatediary.jperera.rapidsentrymaster V/WebViewChromiumFactoryProvider: Binding Chromium to main looper Looper (main, tid 1) {b23e619}
11-11 09:32:25.307 8316-8316/com.realstatediary.jperera.rapidsentrymaster I/cr.library_loader: Expected native library version number "46.0.2490.76", actual native library version number "46.0.2490.76"
11-11 09:32:25.309 8316-8316/com.realstatediary.jperera.rapidsentrymaster I/chromium: [INFO:library_loader_hooks.cc(118)] Chromium logging enabled: level = 0, default verbosity = 0
11-11 09:32:25.329 8316-8316/com.realstatediary.jperera.rapidsentrymaster I/cr.BrowserStartup: Initializing chromium process, singleProcess=true
11-11 09:32:25.336 8316-8316/com.realstatediary.jperera.rapidsentrymaster E/SysUtils: ApplicationContext is null in ApplicationStatus
11-11 09:32:25.417 8316-8316/com.realstatediary.jperera.rapidsentrymaster E/chromium: [ERROR:browser_gpu_channel_host_factory.cc(258)] Failed to init browser shader disk cache.
11-11 09:32:25.445 8316-8316/com.realstatediary.jperera.rapidsentrymaster E/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)
11-11 09:32:25.449 8316-8774/com.realstatediary.jperera.rapidsentrymaster W/cr.media: Requires BLUETOOTH permission
11-11 09:32:25.471 8316-8316/com.realstatediary.jperera.rapidsentrymaster I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.WebViewContentsClientAdapter$WebResourceErrorImpl>
11-11 09:32:25.472 8316-8316/com.realstatediary.jperera.rapidsentrymaster I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.WebViewContentsClientAdapter$WebResourceErrorImpl>
11-11 09:32:25.526 8316-8316/com.realstatediary.jperera.rapidsentrymaster I/art: Rejecting re-init on previously-failed class java.lang.Class<org.chromium.content.browser.FloatingWebActionModeCallback>
11-11 09:32:25.526 8316-8316/com.realstatediary.jperera.rapidsentrymaster I/art: Rejecting re-init on previously-failed class java.lang.Class<org.chromium.content.browser.FloatingWebActionModeCallback>
11-11 09:32:25.554 8316-8316/com.realstatediary.jperera.rapidsentrymaster W/art: Attempt to remove local handle scope entry from IRT, ignoring
11-11 09:32:25.562 8316-8316/com.realstatediary.jperera.rapidsentrymaster W/AwContents: onDetachedFromWindow called when already detached. Ignoring
11-11 09:32:30.958 8316-8316/com.realstatediary.jperera.rapidsentrymaster W/cr.BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 8316
11-11 09:33:18.836 8316-8398/com.realstatediary.jperera.rapidsentrymaster D/PULLBACK: Executing background pull from server

1 个答案:

答案 0 :(得分:0)

我终于做到了!

这个解决方案:

if(message.getMessageType() == 0) {
            StringBuilder html = new StringBuilder();
            html.append("<html>");
            html.append("<head>");
            html.append("</head>");
            html.append("<body>");
            html.append("<div id ='main'><img class=\"video_player_frame\"src=\""+cameraUrl+" style=\"top: 0px; border: none; width: 100%; height: 100%;\"></div>");
            html.append("</body>");
            html.append("</html>");
            webView_camera.loadData(html.toString(),"text/html", "UTF-8");
        }
相关问题