Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | mymokol |
Hello!
I’ve been trying to create a web app for myself to be able to play and change the volume of tracks live in chrome, so that i can share the tab audio in jitsi.
It’s been going well up until this point.
i tried to make it so that the user can choose a custom file from their own computer, so i made a FileDialog and some code that grabbed the selected file and put it in the AudioStreamPlayer’s “stream” property using load(path)
. when i went into the FileDialog and chose a file that was inside the res:// directory, it worked just fine, and my debug tool told me that the AudioStreamPlayer’s “stream” property looked something like [AudioStreamSample:2442]
but when i went outside the res:// directory and chose a file from my documents, the debug tool said [Object:Null]
.
So my question is: Is there a way to make Godot load a file that isn’t contained in the res:// directory? If so, what do i need to do?
Thanks!
EDIT: I tried to use the File class, so now the path of the chosen file gets opened by a new File in godot, it gets passed to the AudioStreamPlayer and then, instead of $AudioStreamPlayer.stream = load(current.file)
, it’s just $AudioStreamPlayer.stream = current.file
. It still shows the “stream” property as [Object:Null]
though.
On web you’re naturally blocked from accessing user’s local filesystem, with the exception of user uploading files. I haven’t found a way to do this directly from godot, but you might be able to have a javascript program which gets files via <input type="file">
and feeds it to godot using Javascript singleton.
aXu_AP | 2021-10-31 16:20
user uploading files is exactly what i’m after…
mymokol | 2021-10-31 20:38
I’m having the exact same issue as mymokol. Audio file loading works fine from res:// but doesn’t seem to load from user://
though video files load fine from res:// as well as user://
Harish | 2022-03-05 01:54