-
Notifications
You must be signed in to change notification settings - Fork 767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android@10 not playing files served via https://localhost #345
Comments
I believe this plugin can't access files through the |
That HTTPS url is only available inside your webview. When you use the media plugin it works outside of the webview. Provide the file path directly to the media plugin and it will play fine. If you want to use HTML5 audio then you should use the HTTPS://localhost... address as this exposes the locally stored files to the webview so they can be accessed in HTML. |
Yes, that's the case. I would argue that the media plugin should interoperate 'https://localhost' (port 80 only) urls and resolve its native file path internally. Removes the need for app developers to implement this mapping logic themselves. Better yet. A helper function provided by cordova plugin class as suggested here apache/cordova-android#1316 (comment) would abstract it for plugin developers too. |
We are experimenting with a solution similar to this, available in the file plugin 7.x apache/cordova-plugin-file#517 Does this solves your issue? |
I don't think so. That PR seems to fix an issue with the asset folder not being reachable through the WebViewAssetLoader. My second remark is referring to your comment:
|
@breautek first apologies I don't have much background with Cordova, but attempting to support an app. In reference to this comment
Are you suggesting that https://github.com/apache/cordova-plugin-file/blob/ef301bcd17bd2e86367cdf90b7f1b06a84f71f1b/src/android/FileUtils.java#L1267 could be used by other plugins to convert the https://localhost/__cdvfiles_XXXX links back into plugin java side useable links? Or that other plugins also implement the same code to perform the same conversion? I was trying to understand exactly what CordovaPluginPathHandler getPathHandler() is, some form of per plugin override? I don't see it called from anywhere in the File plugin, and looks like nothing was documented for it. My use case is another plugin, but same issue where entry.toURL is returning the web view only URL and I am then passing that into another plugin to access the file. If I can work out how to do it for the plugin I have I will happily attempt a PR for this one. |
Bug Report
Problem
Files stored on the device which are accessed through
https://localhost
should start playing, but don't. Files play fine if accessed directly from the web. A simple Html5 player is able to play the file normally throughlocalhost
.Information
LogCat logs when playing file:
Notice the error:
Command or Code
Some code snippets that can be run in chrome console when inspecting device
Download sample wav file
NOT WORKING: Play file locally with cordova-plugin-media (This is the bug)
WORKING: Play file remotely with cordova-plugin-media
WORKING: Play file locally with html5
Environment, Platform, Device
Device: Android 8.1 (API 27)
Version information
Cordova CLI: 11.0.0
Cordova Platforms: android 10.1.2
Cordova Plugins:
Checklist
The text was updated successfully, but these errors were encountered: