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 mode " no such file or directory" #103

Open
Henry-derbug opened this issue May 18, 2024 · 2 comments
Open

Android mode " no such file or directory" #103

Henry-derbug opened this issue May 18, 2024 · 2 comments
Labels

Comments

@Henry-derbug
Copy link

Running the SimplePlayback example (processing4.2) on an android 13 (and others) phone throws the error:

java.io.FileNotFoundException: /data/user/0/processing.test.simpleplayback/files/null.wav: open failed: ENOENT (No such file or directory)

command that causes the error:
soundfile = new SoundFile(this, "null.wav");

the "null.wav" file is located in the data directory of the app.

i also checked absolute path on internal or external storage but the SoundFile Class doesnt accept sparators in the path.

The path that the SoundFile(this, "null.wav"); throws is different from the correct android path.

path from error SoundFile(this, "null.wav");
/data/user/0/processing.test.simpleplayback/files
#######
path from
SDcards = context.getExternalFilesDirs(null);
sdPath0 = SDcards[0].toString() ;
sdPath1 = SDcards[1].toString() ;
sdPath0: /storage/emulated/0/Android/data/processing.test.simpleplayback/files

what can I do to get the SoundFile playing the .wav file from internal memory or external SDCard on an android?

@kevinstadler
Copy link
Collaborator

Could you try loading the file using its full absolute path? I.e.:

new SoundFile(this, "/storage/emulated/0/Android/data/processing.test.simpleplayback/files/null.wav");

@Henry-derbug
Copy link
Author

Henry-derbug commented May 19, 2024

SoundFile Class doesnt accept sparators in the path.

java.lang.IllegalArgumentException: File /temp.wav contains a path separator

not a single one and not several in the absolute path.

I found out that openFile behaves different in java and in android, One should use streams to open files with separators but this is too sophisticated for me to find out a working code. Im so happy to use processing without deepdiving into android tricks. https://stackoverflow.com/questions/5963535/java-lang-illegalargumentexception-contains-a-path-separator

In the same android app I use output = createWriter(sdPath+logfilename+"_log"+".csv"); to write a log file to an absolute path "sdPath" and this works without rejecting the / slash file separator.

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

No branches or pull requests

2 participants