Skip to content
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 14 Won't Play MP3 files #395

Open
bkervaski opened this issue Feb 14, 2024 · 2 comments
Open

Android 14 Won't Play MP3 files #395

bkervaski opened this issue Feb 14, 2024 · 2 comments

Comments

@bkervaski
Copy link

bkervaski commented Feb 14, 2024

Bug Report

Problem

On Android 14 (Pixel 5) I can no longer play MP3 files from the bundle either directly or via https://localhost.

Using Cordova Android 12.0.1 and cordova-plugin-media 7.0.0

I'm using Vite, so all of the files end up in assets/sound-abc123.mp3

Not doing anything fancy, just:

let foo = new Media('assets/sound-abc123.mp3') or https://localhost/assets/sound-abc123.mp3
foo.play()

/storage/emulated/0/Android/data/com.bundle.id/files/assets/sound-abc123.mp3: open failed: ENOENT (No such file or directory)

It WILL play, however, from the internet, i.e., new Media('https://some.website.abc/foo.mp3')

Thanks for any help!

What is expected to happen?

The sound should play.

What does actually happen?

I get a code 1 (or file not found when I experiment with other ways to get the file)

Information

This code worked on Android 12.

Command or Code

let foo = new Media('assets/sound-abc123.mp3') or https://localhost/assets/sound-abc123.mp3
foo.play()

Environment, Platform, Device

Android 14, Pixel 5

Version information

Checklist

  • [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
@michael-mathieu
Copy link

michael-mathieu commented Aug 28, 2024

Same error for me.. obviously an old bug, because I found the workaround in a code written 8 years ago :D
cf. https://github.com/gandhirajan/Cordova_Media/blob/master/www/js/index.js

function getMediaURL(s) {
    if (device.platform.toLowerCase() === "android") return "/android_asset/www/" + s;
    return s;
}

@breautek
Copy link

/storage/emulated/0/Android/data/com.bundle.id/files/assets/sound-abc123.mp3: open failed: ENOENT (No such file or directory)

To clarify com.bundle.id is YOUR application right? ENOENT is typically an error signaling that the file does not exist. Android will however produce ENOENT errors on files that exists but does not have permission to access that file.

If you're attempting to access another apps files that will no longer work over direct filesystem under Android's scoped storage system introduced in API 29.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants