I want to play local videos in crosswalk webview. I'm getting the video path from an intent opening my activity, so it could be stored internally or on sd card.
Using this url file:///storage/emulated/0/Download/movies/movie.mp4
i get Failed to load resource: net::ERR_ACCESS_DENIED
.
Using input file dialog with URL.createObjectURL(file);
it works. But because i know the path, i dont want to select it again manually. Setting the value of input file is forbidden.
Creating a url using the path is also not possible, because it needs file or blob.
Because of possible big filesize its not possible to temporarily copy it to sd card.
This gives me file not found error:
@Override
public WebResourceResponse shouldInterceptLoadRequest(XWalkView view,
String url) {
if(url.contains("file:///storage")){
try {
return new WebResourceResponse("video/*", "UTF-8", new FileInputStream(url));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
return super.shouldInterceptLoadRequest(view, url);
}
also i have defined <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
other questions on stackoverflow asking for accessing assets, so i created this new question
On Android, LocalStorage works well but only in the current webview. Multiple webviews of the same app can't share the same data with LocalStorage.
Alternatives to WebView If you want to send users to a mobile site, build a progressive web app (PWA). If you want to display third-party web content, send an intent to installed web browsers. If you want to avoid leaving your app to open the browser, or if you want to customize the browser's UI, use Custom Tabs.
This interface was deprecated in API level 12. This interface is now obsolete.
The problem might be in accessing video file from External storage also make sure you have given read/write Run time permission . Here you can find your solution here and this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With