File not found, but it's exist

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
ReFreezed
Party member
Posts: 612
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: File not found, but it's exist

Post 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.
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
MrFariator
Party member
Posts: 548
Joined: Wed Oct 05, 2016 11:53 am

Re: File not found, but it's exist

Post 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?
User avatar
ReFreezed
Party member
Posts: 612
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: File not found, but it's exist

Post by ReFreezed »

It's just missing from the wiki. Testing confirms it works. :)
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: File not found, but it's exist

Post 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.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
ReFreezed
Party member
Posts: 612
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: File not found, but it's exist

Post 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...
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: File not found, but it's exist

Post 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
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
love2dluacode
Prole
Posts: 7
Joined: Sun Mar 20, 2022 11:04 am

Re: File not found, but it's exist

Post 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.
User avatar
ReFreezed
Party member
Posts: 612
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: File not found, but it's exist

Post 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.)
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: File not found, but it's exist

Post 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.
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: File not found, but it's exist

Post 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
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Semrush [Bot] and 5 guests