Page 1 of 1
love.audio.newSource Cannot use full path
Posted: Sun Jan 08, 2023 8:36 pm
by elfrea
Hi, i've been messing with the audio lib, and i could make it work no problem.
I can load a song if i give a path like : "music/music.ogg" which is located in "E:\lovegame"
if I give it the full path : "E:\lovegame\music\music.ogg" or "E:/lovegame/music/music.ogg", I always get the File not found error.
in other words:
printCWD :
E:\lovegame\
love.audio.newSource("music\music.ogg")
OK
love.audio.newSource("E:\lovegame\music\music.ogg")
Crash (File not found)
I even have a function to check wheter or not a file exists on the file system and if i check:
isFileExists("E:\lovegame\music\music.ogg")
True
Am i missing something or is it a bug with newSource() ?
Re: love.audio.newSource Cannot use full path
Posted: Sun Jan 08, 2023 8:52 pm
by GVovkiv
elfrea wrote: ↑Sun Jan 08, 2023 8:36 pm
Hi, i've been messing with the audio lib, and i could make it work no problem.
I can load a song if i give a path like : "music/music.ogg" which is located in "E:\lovegame"
if I give it the full path : "E:\lovegame\music\music.ogg" or "E:/lovegame/music/music.ogg", I always get the File not found error.
in other words:
printCWD :
E:\lovegame\
love.audio.newSource("music\music.ogg")
OK
love.audio.newSource("E:\lovegame\music\music.ogg")
Crash (File not found)
I even have a function to check wheter or not a file exists on the file system and if i check:
isFileExists("E:\lovegame\music\music.ogg")
True
Am i missing something or is it a bug with newSource() ?
https://love2d.org/wiki/love.filesystem
In short, at current love 11.4, love filesystem functions is sandboxed to game "save" path and source. So you can't write/read content files outside of that sandbox.
Code: Select all
love.audio.newSource("E:\lovegame\music\music.ogg")
Can't found file because, for this function, you trying to access "E:\lovegame\music\music.ogg" file inside source/save directory, which doesn't exist (because, yet again, love filesystem function will look from source and save path).
In love 12.0 filesystem will be less restricted so you can wait for it (or build from source wip version, if you know how to) or you can try use libraries such as
https://github.com/EngineerSmith/nativefs, that can access any file or directory anywhere, if you need. If you just want to play sounds/other assets from source directory, then there shouldn't be any reason try to get files outside of source/save path
Re: love.audio.newSource Cannot use full path
Posted: Sun Jan 08, 2023 9:06 pm
by elfrea
Ok thanks everyone, im gonna wait for v12.
Actually what im doing is not exactly a game, its a tilemap editor with an audio player included in it, so i wanted to be able to load any song on my computer. but its ok, ive changed it so it scans all files in a music directory instead, so I just have to copy all the songs i want in that directory.
Re: love.audio.newSource Cannot use full path
Posted: Sun Jan 08, 2023 9:16 pm
by Andlac028
elfrea wrote: ↑Sun Jan 08, 2023 9:06 pm
Ok thanks everyone, im gonna wait for v12.
Actually, you can build it from source (branch 12.0-development on
Github repo), or if you are signed in Github, you can download artifacts from latest commit
here
Re: love.audio.newSource Cannot use full path
Posted: Sun Jan 08, 2023 9:24 pm
by slime
Just to be clear: your code won't work as-is in any love version including love 12.
love 12 adds the ability to mount full platform-specific paths to love's virtual filesystem via
love.filesystem.mountFullPath, rather than allowing arbitrary platform-dependent paths to be used in any API that takes a filepath. (i.e. you have to mount a folder to the virtual filesystem first, and then use a path based on the mount point parameter you've given to mountFullPath.)
Re: love.audio.newSource Cannot use full path
Posted: Fri Jan 13, 2023 7:34 pm
by elfrea
ok thanks but thats allright i dont use the love filesystem, built my own lib instead