V
V
vbNoName2020-01-30 20:50:38
React Native
vbNoName, 2020-01-30 20:50:38

How to display pptx in WebView?

You need to either display the .pptx and .mp4 content inside the app or open it in a third party app installed on the device. As I understand it, opening it in a third-party application is quite problematic, so I decided to try to display the file inside the WebView.

With mp4 everything is ok, but with pptx the problem is on android. On ios everything is ok. Object {uri: 'file:///......'} is passed to source WebView Error occurs

java.lang.IllegalArgumentException: Can only download HTTP/HTTPS URIs: file:///<path_to_file>.pptx
at android.app.DownloadManager$Request.<init>(DownloadManager.java:494)
at abi36_0_0.host.exp.exponent.modules.api.components.webview.RNCWebViewManager$2.onDownloadStart(RNCWebViewManager.java:2)

Moreover, the error falls only when uploading a pptx file, when loading mp4 everything is ok. I found a piece in the DownloadManager.java code where this error is coming from. And there is an interesting thing

if (scheme == null || (!scheme.equals("http") && !scheme.equals("https"))) {
  throw new IllegalArgumentException("Can only download HTTP/HTTPS URIs: " + uri);
}

The question is the following. Why, then, does the same error not fall when trying to open a video file through WebView, if a link to it is also transmitted in the file:/// format? Maybe someone came across? How to fix it? Any ideas and suggestions are welcome. Killed 3 days already on this

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question