apache / apache/cordova-plugin-media
Can't play mp3 - No such file / Failed to connect to localhost
- Dominant language
- JavaScript
- Stars
- 391
- Forks
- 762
- PR merge metrics
- No merged PRs in 30d
Description
# Bug Report
## Problem
I cannot play mp3 files with the plugin apart from those on my online server.
### What is expected to happen?
Play mp3 file. I believe this worked a long time ago but no longer works now...
### What does actually happen?
Get error:
```/storage/emulated/0/Android/data/com.hablamedecristo.himnario2/files/test.mp3: open failed: ENOENT (No such file or directory)```
Note: when trying to access an mp3 file with cordova.file.applicationStorageDirectory or https://localhost/test.mp3, I get the error "java.net.ConnectException: Failed to connect to localhost/127.0.0.1:443"
## Information
### Command or Code
I have test.mp3 saved in the android/platform_www directory. I also can download to cordova.file.applicationStorageDirectory via the cordova-plugin-file-transfer plugin.
```
function playDownloadedAudio (fileTransferWebUrl, thisElement) {
my_media = new Media("test.mp3",
function () //success;
{ },
function (error) //error
{
alertOK(translate('Error in playback. Please contact support. \n Code: ','text') + error.code + '\n '+translate('Message:','text')+' '+error.message + '\n');
playing = false;
}
);
my_media.play();
}
```
config.xml
```
X
X
X
```
Content Security Policy
```
```
### Environment, Platform, Device
Android Target SDK = 34
Galaxy Tab A7, Android 12
### Version information
Cordova version 12.0.0
cordova-media-plugin version 7.0.0
cordova-plugin-file version 8.1.0
cordova-plugin-file-transfer version 2.0.0
Android Studio Koala 2024.1.1 Patch 2
## Checklist
- [x] I searched for existing GitHub issues
- [ ] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above
Contributor guide
Research direction
The reproduction is in the JavaScript playDownloadedAudio function, with relevant settings in config.xml; begin by reproducing it on Android 12 with the listed Cordova and plugin versions and compare local, downloaded, and online paths. Trace how the media plugin resolves those paths and verify that local or downloaded MP3 playback completes without ENOENT or localhost connection errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, javascript
- Domain
- audio-video-rtc, mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100