无法清理WebViewClient的shouldInterceptRequest

问题描述

我要覆盖WebViewClient的{​​{3}},以提供本地视频流。视频可以正常播放和暂停,但用户根本无法进行擦洗-播放只是从同一位置继续。如何使用户可以更改播放位置?

shouldInterceptRequest method

代码

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    val webView = findViewById<WebView>(R.id.webView)
    WebView.setWebContentsDebuggingEnabled(true)
    webView.webViewClient = object : WebViewClient() {
        override fun shouldInterceptRequest( view: WebView?,request: WebResourceRequest?
        ): WebResourceResponse? {
            if (request?.url.toString().contains("1.mp4")) {
                return WebResourceResponse(
                    "video/mp4","UTF-8",resources.openRawResource(R.raw.movie)
                )
            }
            return super.shouldInterceptRequest(view,request)
        }
    }

    webView.loadDataWithBaseURL(
        "http://fake.com","""
        <!DOCTYPE html>
        <html>
            <p>Video 1:</p>
            <p><video src="http://fake.com/1.mp4" /></p>
        </html>
    """.trimIndent(),"text/html",StandardCharsets.UTF_8.name(),null
    )
}

scrubbing not working in webview

是存在此问题的存储库。请注意,这不是真正的用例,只是一个最小的例子。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)