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.
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 True 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.
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 True 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.
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.
-- 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.
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.)
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.
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.
Me and my stuff True 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.