webview 中的
webView.settings.apply {
javaScriptEnabled = true
domStorageEnabled = true
mediaPlaybackRequiresUserGesture = false
}
webView.webViewClient = object : WebViewClient() {
override fun onPageFinished(view: WebView?, url: String?) {
super.onPageFinished(view, url)
val jsCode = """
function setPoster() {
console.log('Poster ayarlama başladı');
var videos = document.getElementsByTagName('video');
console.log('Video sayısı:', videos.length);
for(var i = 0; i < videos.length; i++) {
var video = videos[i];
video.poster = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=';
console.log('Video ' + i + ' poster ayarlandı');
}
}
setPoster();
"""
view?.evaluateJavascript(jsCode, null)
}
}
与 onPageFinished 相同,有一个名为 onPageStarted() 的方法,您可以使用它在加载之前显示您自己的自定义加载器
否则
domStorageEnabled = true; mediaPlaybackRequiresUserGesture = false;
用这两个删除并告诉我你是否得到它