I’m trying to embed videos into Android webview. Here is the following html code:
It works fine in jsfiddle, but when I load a HTML that looks like this in Android webview, I see it successfully load the thumbnail of the video. When I click play button, it gives me a popup saying,
I hit “OK”, and it shows “The media could not be played”.
In the log, I see:
Refused to load the image 'android-webview-video-poster:default_video_poster/8443874430566469765' because it violates the following Content Security Policy directive: "img-src 'self' http://localhost:* http://localhost.twitter.com:* https://*.twitter.com https://*.twimg.com https://vine.co https://*.vine.co https://*.periscope.tv https://*.pscp.tv blob: data:".
I’ve tried https://stackoverflow.com/questions/38277526/webview-content-security-policy but I believe its the CSP in the iframe html, so I have no control over that CSP.
I read Display embedded tweet with video in Android WebView and I cannot use TweetView because I am not able to bring in new dependency to my build.gradle by just specifying an address. I am only able to add in dependency through .jar file or through maven central repository or PyPI or RubyGems or CPAN (please share/guide if either exist).
Here are the culprits:
This iframe url does not allow to load ‘android-webview-video-poster:default_video_poster’ because it specifies a CSP that prevents it:
How to fix?
Please add ‘android-webview-video-poster:default_video_poster’ to img-src of CSP in embed_source html