17

I want to load a video from Vimeo in a WebView. It works, but the preview image doesn't load and I get this error:

I/chromium: [INFO:CONSOLE(0)] "Refused to load the image 'android-webview-video-poster:default_video_poster/-5228946977756841864' because it violates the following Content Security Policy directive: "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 https://secure.gravatar.com https://i0.wp.com https://i1.wp.com https://i2.wp.com". ", source: https://player.vimeo.com/video/172374044 (0)

How can I fix it?

Pang
  • 9,564
  • 146
  • 81
  • 122
  • 2
    Did you find the solution? Even I am facing the same issue. – Nitin Mesta Oct 06 '16 at 14:24
  • Did you find any solution? I am using webview_flutter_plus package in Flutter and I am getting the same issue. I tried adding this but no luck. – Jyo Oct 01 '20 at 05:09

2 Answers2

12

Add the following to Content-Security-Policy meta tag img-src directive:

android-webview-video-poster:

As in:

<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';">
n33x
  • 153
  • 1
  • 6
  • 1
    Did you notice that the video was sized incorrectly when you were seeing the error, before you added the meta tag fix? I'm getting the same error and the video itself is not sized properly to fit the android web view. – cavalleydude Jan 09 '17 at 17:27
  • Where to add that I am not JS guy, please help. – Maveňツ Jun 06 '17 at 07:59
  • Add that inside the `` tag in the HTML page – n33x Jun 07 '17 at 03:26
  • @cavalleydude I would like to not permit this to * (evryone) but 'self' is not working, see the error Refused to load the image 'android-webview:default_video_poster/4145483716572850442' because it violates the following Content Security Policy directive: "img-src 'self' data: android-webview-video-poster:". – Michael Burger Sep 05 '17 at 11:24
  • Any idea about this one: https://stackoverflow.com/questions/54470420/flutter-web-view-secure-origin – skjagini Feb 01 '19 at 03:58
1

You can add a poster attribute to your <video> tag. An empty image works. The default android-webview-video-poster looks awful anyway.