Code: Select all
function love.load()
directory = love.filesystem.getWorkingDirectory()
end
function love.draw()
video = love.graphics.newVideo(directory .. "/videos/test.mp4")
video:play()
end
Code: Select all
function love.load()
directory = love.filesystem.getWorkingDirectory()
end
function love.draw()
video = love.graphics.newVideo(directory .. "/videos/test.mp4")
video:play()
end
Still doesn't work (with nativefs)zorg wrote: ↑Sun Mar 20, 2022 3:55 pm Löve's own filesystem is sandboxed; by default, you can only access two places with it:
- wherever your main.lua is,
- if you defined an identity, then a save folder in a specific place.
On windows (not sure about other OS-es), if you fuse your .love file to the executable, then you can also mount the source base directory, where the executable is, and also load files from that location.
If you need any other location, i'd suggest using the library NativeFS: https://github.com/EngineerSmith/nativefs
it's still saying that file not found (nativefs)MrFariator wrote: ↑Mon Mar 21, 2022 11:55 am Can you describe your use case a bit more? Would love.filedropped for instance work if you need to implement a general purpose video player, or is there some other reason to loading files outside the fused executable?
You also don't really say what's wrong with nativefs, so hard to help troubleshooting there.
Code: Select all
function love.load()
local nativefs = require("nativefs")
directory = nativefs.getWorkingDirectory()
end
function love.draw()
video = love.graphics.newVideo(directory .. "/videos/test.mp4")
video:play()
end
Code: Select all
video = love.graphics.newVideo(directory .. "/videos/test.mp4")
video:play()
function love.draw()
love.graphics.draw(video)
end
You're still trying to use an absolute path when using LÖVE's API. You would need to read the contents of the file using e.g. NativeFS, and then make LÖVE create the video object from the read data (as opposed to having LÖVE read the file directly). However, love.graphics.newVideo doesn't allow you to give it any data directly as far as I can tell (which is different from other parts of LÖVE's API), so you have to use the love.filedropped callback like MrFariator said to access the file or, less optimally, copy the video file you're trying to play to the save directory first and let love.graphics.newVideo load it from there.love2dluacode wrote: ↑Mon Mar 21, 2022 11:58 amCode: Select all
function love.load() local nativefs = require("nativefs") directory = nativefs.getWorkingDirectory() end function love.draw() video = love.graphics.newVideo(directory .. "/videos/test.mp4") video:play() end
Code: Select all
-- Probably your best option:
function love.filedropped(file)
video = love.graphics.newVideo(file)
video:play()
end
function love.draw()
if video then
love.graphics.draw(video)
end
end
Users browsing this forum: Ahrefs [Bot] and 6 guests