WebView内容安全策略

时间:2016-07-09 01:55:23

标签: android webview vimeo

我想在WebView中从Vimeo加载视频。它有效,但预览图像无法加载,我收到此错误:

  

I / chromium:[INFO:CONSOLE(0)]"拒绝加载图片' android-webview-video-poster:default_video_poster / -5228946977756841864'因为它违反了以下内容安全政策指令:" img-src https://i.vimeocdn.com https://secure-b.vimeocdn.com https://f.vimeocdn.com https://vimeo.com https://sb.scorecardresearch.com https://ssl.google-analytics.com {{3 }} https://secure.gravatar.com https://i0.wp.com https://i1.wp.com"。                                                                    ",来源:https://i2.wp.com(0)

我该如何解决?

2 个答案:

答案 0 :(得分:6)

将以下内容添加到Content-Security-Policy元标记img-src指令:

android-webview-video-poster:

如:

<meta http-equiv="Content-Security-Policy" content="default-src * gap:; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src *; img-src * data: blob: android-webview-video-poster:; style-src * 'unsafe-inline';">

答案 1 :(得分:0)

您可以向 poster 标签添加 <video> 属性。空图像有效。无论如何,默认的 android-webview-video-poster 看起来很糟糕。