You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2022/06/01 19:19:19 UTC

[GitHub] [cordova-plugin-media] boedy opened a new issue, #345: Android@10 not playing files served via https://localhost

boedy opened a new issue, #345:
URL: https://github.com/apache/cordova-plugin-media/issues/345

   # 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 through `localhost`.
   
   I'm thinking the issue might be related to https://github.com/apache/cordova-plugin-file or the combination. Maybe some missing metadata (MimeType??) on the response headers. The Html5 player might be more forgiving here, but I've not been able to confirm this.
   
   ## Information
   <!-- Include all relevant information that might help understand and reproduce the problem -->
   
   LogCat logs when playing file:
   ```
   2022-06-01 20:59:30.446 23784-23895/io.cordova.hellocordova V/MediaHTTPService: MediaHTTPService(android.media.MediaHTTPService@771fbf7): Cookies: null
   2022-06-01 20:59:30.456 23784-23895/io.cordova.hellocordova W/MediaPlayer: Use of stream types is deprecated for operations other than volume control
   2022-06-01 20:59:30.456 23784-23895/io.cordova.hellocordova W/MediaPlayer: See the documentation of setAudioStreamType() for what to use instead with android.media.AudioAttributes to qualify your playback use case
   2022-06-01 20:59:30.459 23784-23895/io.cordova.hellocordova W/AudioManager: Use of stream types is deprecated for operations other than volume control
   2022-06-01 20:59:30.459 23784-23895/io.cordova.hellocordova W/AudioManager: See the documentation of requestAudioFocus() for what to use instead with android.media.AudioAttributes to qualify your playback use case
   2022-06-01 20:59:30.462 23784-23895/io.cordova.hellocordova W/PluginManager: THREAD WARNING: exec() call to Media.startPlayingAudio blocked the main thread for 25ms. Plugin should use CordovaInterface.getThreadPool().
   2022-06-01 20:59:30.463 23784-23884/io.cordova.hellocordova V/MediaHTTPService: makeHTTPConnection: CookieManager created: java.net.CookieManager@73fb182
   2022-06-01 20:59:30.464 23784-23884/io.cordova.hellocordova V/MediaHTTPService: makeHTTPConnection(android.media.MediaHTTPService@771fbf7): cookieHandler: java.net.CookieManager@73fb182 Cookies: null
   2022-06-01 20:59:30.468 23784-23784/io.cordova.hellocordova I/chromium: [INFO:CONSOLE(245)] "1", source: https://localhost/plugins/cordova-plugin-media/www/Media.js (245)
   2022-06-01 20:59:30.724 23784-23846/io.cordova.hellocordova D/: PlayerBase::stop() from IPlayer
   2022-06-01 20:59:30.724 23784-23846/io.cordova.hellocordova D/AudioTrack: stop() called with 980792 frames delivered
   2022-06-01 21:00:00.719 23784-23884/io.cordova.hellocordova E/MediaPlayerNative: error (1, -2147483648)
   2022-06-01 21:00:00.720 23784-23895/io.cordova.hellocordova E/MediaPlayer: Error (1,-2147483648)
   2022-06-01 21:00:00.720 23784-23895/io.cordova.hellocordova D/AudioPlayer: AudioPlayer.onError(1, -2147483648)
   2022-06-01 21:00:00.721 23784-23895/io.cordova.hellocordova V/MediaPlayer: resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
   2022-06-01 21:00:00.721 23784-23895/io.cordova.hellocordova V/MediaPlayer: cleanDrmObj: mDrmObj=null mDrmSessionId=null
   2022-06-01 21:00:00.729 23784-23784/io.cordova.hellocordova I/chromium: [INFO:CONSOLE(261)] "[object Object]", source: https://localhost/plugins/cordova-plugin-media/www/Media.js (261)
   ```
   
   Notice the error: 
   ```
   2022-06-01 21:00:00.719 23784-23884/io.cordova.hellocordova E/MediaPlayerNative: error (1, -2147483648)
   2022-06-01 21:00:00.720 23784-23895/io.cordova.hellocordova E/MediaPlayer: Error (1,-2147483648)
   ```
   
   ### Command or Code
   <!-- What command or code is needed to reproduce the problem? -->
   Some code snippets that can be run in chrome console when inspecting device
   
   Download sample wav file
   ```
   (() => {
     const fileTransfer = new FileTransfer();
     const TIMEOUT_INTERVAL = 30 * 1000;
     const filePath = window.cordova.file.dataDirectory + "test.wav";
     
     fileTransfer.download(
       "https://github.com/prof3ssorSt3v3/media-sample-files/blob/master/jimmy-coffee.wav?raw=true",
       filePath,
       file => console.log(file.toURL()),
       error => console.error(error)
     );
   })()
   // returns: https://localhost/__cdvfile_files__/test.wav
   ```
   
   NOT WORKING: Play file locally with cordova-plugin-media (This is the bug)
   ```
   source = 'http://localhost/__cdvfile_files__/test.wav';
   track = new Media(source, null, console.error, console.log);
   track.play();
   ```
   
   WORKING: Play file remotely with cordova-plugin-media
   ```
   source = 'https://github.com/prof3ssorSt3v3/media-sample-files/blob/master/jimmy-coffee.wav?raw=true';
   track = new Media(source, null, console.error, console.log);
   track.play();
   ```
   
   WORKING: Play file locally with html5
   ```
   sound = new Audio("http://localhost/__cdvfile_files__/test.wav");
   sound.play();
   ```
   
   
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you experiencing the issue? -->
   Device: Android 8.1 (API 27)
   
   
   ### Version information
   <!-- 
   What are relevant versions you are using?
   For example:
   Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins 
   Other Frameworks: Ionic Framework and CLI version
   Operating System, Android Studio, Xcode etc.
   -->
   Cordova CLI: 11.0.0vvvv
   Cordova Platforms: android 10.1.2
   Cordova Plugins:
   
   - cordova-plugin-file-transfer 2.0.0-dev "File Transfer"
   - cordova-plugin-file 7.0.0 "File"
   - cordova-plugin-media 6.0.0 "Media"
   
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [x] I searched for existing GitHub issues
   - [x] I updated all Cordova tooling to most recent version
   - [x] I included all the necessary information above
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-media] boedy commented on issue #345: Android@10 not playing files served via https://localhost

Posted by GitBox <gi...@apache.org>.
boedy commented on issue #345:
URL: https://github.com/apache/cordova-plugin-media/issues/345#issuecomment-1147945075

   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:
   > Native could probably parse the url and transform it to a regular file:// url. I think the cordova plugin class could also provide this url transform implementation.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-media] boedy commented on issue #345: Android@10 not playing files served via https://localhost

Posted by GitBox <gi...@apache.org>.
boedy commented on issue #345:
URL: https://github.com/apache/cordova-plugin-media/issues/345#issuecomment-1147706479

   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 https://github.com/apache/cordova-android/issues/1316#issuecomment-913716498 would abstract it for plugin developers too.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-media] breautek commented on issue #345: Android@10 not playing files served via https://localhost

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #345:
URL: https://github.com/apache/cordova-plugin-media/issues/345#issuecomment-1147723171

   > 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)](https://github.com/apache/cordova-android/issues/1316#issuecomment-913716498) would abstract it for plugin developers too.
   
   We are experimenting with a solution similar to this, available in the file plugin 7.x 
   
   https://github.com/apache/cordova-plugin-file/pull/517
   
   Does this solves your issue?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-media] SteveGilvarry commented on issue #345: Android@10 not playing files served via https://localhost

Posted by GitBox <gi...@apache.org>.
SteveGilvarry commented on issue #345:
URL: https://github.com/apache/cordova-plugin-media/issues/345#issuecomment-1221444196

   @breautek first apologies I don't have much background with Cordova, but attempting to support an app. In reference to this comment
   > We are experimenting with a solution similar to this, available in the file plugin 7.x
   > 
   > [apache/cordova-plugin-file#517](https://github.com/apache/cordova-plugin-file/pull/517)
   > 
   > Does this solves your issue?
   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.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-media] boedy commented on issue #345: Android@10 not playing files served via https://localhost

Posted by GitBox <gi...@apache.org>.
boedy commented on issue #345:
URL: https://github.com/apache/cordova-plugin-media/issues/345#issuecomment-1144691105

   I believe this plugin can't access files through the `https://localhost` scope. I believe that the WebViewAssetLoader (https://github.com/apache/cordova-android/pull/1137) that was implemented in Android@10 can only be reached though the  WebView. All requests that happen outside of the WebView will not be resolved.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-media] ghenry22 commented on issue #345: Android@10 not playing files served via https://localhost

Posted by GitBox <gi...@apache.org>.
ghenry22 commented on issue #345:
URL: https://github.com/apache/cordova-plugin-media/issues/345#issuecomment-1146995902

   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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org