Page 2 of 3

Re: File not found, but it's exist

Posted: Mon Mar 21, 2022 10:02 pm
by ReFreezed
MrFariator wrote: Mon Mar 21, 2022 7:03 pm 2. Create a File object from those contents
This is the problem. File objects must refer to a file on disk - they cannot be created from data without touching the disk (which is probably by design), so you'd effectively have to copy the file to the save directory. It'd be nice if love.graphics.newVideo (or love.video.newVideoStream) could take data from memory directly, but I'm not sure how common or useful that is in general since video files can be very large (so you'd want to stream them).
MrFariator wrote: Mon Mar 21, 2022 7:03 pm 3. Pass the File object to love.video.newVideoStream
4. Pass the VideoStream object to love.graphics.newVideo
Since love.graphics.newVideo can take a File object directly, using a VideoStream object in-between isn't necessary.

Re: File not found, but it's exist

Posted: Tue Mar 22, 2022 2:23 am
by MrFariator
Can it? At a quick glance, to me the wiki only says that love.graphics.newVideo can take a filename or a VideoStream object as its arguments, with an optional settings table. Is there some part I'm missing, or is newVideo accepting a File object detailed on some other page? Or is this info just not represented on the wiki itself?

Re: File not found, but it's exist

Posted: Tue Mar 22, 2022 3:00 am
by ReFreezed
It's just missing from the wiki. Testing confirms it works. :)

Re: File not found, but it's exist

Posted: Tue Mar 22, 2022 8:59 pm
by zorg
ReFreezed wrote: Mon Mar 21, 2022 10:02 pm
MrFariator wrote: Mon Mar 21, 2022 7:03 pm 2. Create a File object from those contents
This is the problem. File objects must refer to a file on disk - they cannot be created from data without touching the disk (which is probably by design), so you'd effectively have to copy the file to the save directory. It'd be nice if love.graphics.newVideo (or love.video.newVideoStream) could take data from memory directly, but I'm not sure how common or useful that is in general since video files can be very large (so you'd want to stream them).
MrFariator wrote: Mon Mar 21, 2022 7:03 pm 3. Pass the File object to love.video.newVideoStream
4. Pass the VideoStream object to love.graphics.newVideo
Since love.graphics.newVideo can take a File object directly, using a VideoStream object in-between isn't necessary.
If it can take a File object, it might be able to take FileData as well, and iirc with FileData, you don't really need to copy anything to the save directory... also mostly undocumented on the wiki so a try might not be bad.

Re: File not found, but it's exist

Posted: Tue Mar 22, 2022 10:09 pm
by ReFreezed
newVideo doesn't take FileData (or ByteData or and other Data object) - you'll get an error when trying.

I feel like I'm the only one here testing things...

Re: File not found, but it's exist

Posted: Wed Mar 23, 2022 7:59 am
by zorg
ReFreezed wrote: Tue Mar 22, 2022 10:09 pm newVideo doesn't take FileData (or ByteData or and other Data object) - you'll get an error when trying.

I feel like I'm the only one here testing things...
I meant newVideoStream actually

Re: File not found, but it's exist

Posted: Wed Mar 23, 2022 8:47 am
by love2dluacode
ReFreezed wrote: Mon Mar 21, 2022 2:38 pm
love2dluacode wrote: Mon Mar 21, 2022 11:58 am

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
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.

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
well, thanks, it worked!
now i need to stream the video using videostream because it's just showing me a black screen.

Re: File not found, but it's exist

Posted: Wed Mar 23, 2022 10:44 am
by ReFreezed
love2dluacode wrote: Wed Mar 23, 2022 8:47 am well, thanks, it worked!
now i need to stream the video using videostream because it's just showing me a black screen.
Using a VideoStream object anywhere makes no difference (see the reply below). The issue is elsewhere. You'll have to describe what exactly you're doing (with code) and what you've tried. Attaching a .love file with all relevant things included would be incredibly helpful. It's very difficult to help if we don't have any information.
zorg wrote: Wed Mar 23, 2022 7:59 am I meant newVideoStream actually
Well, it's the same deal. Only files allowed.

I've now looked at LÖVE's source directly. newVideo calls newVideoStream if its first argument isn't a VideoStream already, and newVideoStream accepts nothing but a File object or a filename. (newVideo also loads the audio using the file's name and love.audio.newSource.)

Re: File not found, but it's exist

Posted: Fri Mar 25, 2022 6:39 pm
by pgimeno
There's another possibility that I've been toying with for another project, namely to mount the root directory using a call to PhysFS via FFI, to place it under the Löve filesystem.

Re: File not found, but it's exist

Posted: Fri Mar 25, 2022 11:49 pm
by zorg
pgimeno wrote: Fri Mar 25, 2022 6:39 pm There's another possibility that I've been toying with for another project, namely to mount the root directory using a call to PhysFS via FFI, to place it under the Löve filesystem.
You mean kinda like this?: https://github.com/zorggn/love-fml/blob ... #L280-L290