Difference between revisions of "love.graphics.newVideo"

(Created page)
 
(Added a warning about potential compatibility issues: https://love2d.org/forums/viewtopic.php?p=259088&sid=b4713b788863f510a31950232932d8da#p259088)
 
(2 intermediate revisions by 2 users not shown)
Line 2: Line 2:
 
Creates a new drawable [[Video]]. Currently only Ogg Theora video files are supported.
 
Creates a new drawable [[Video]]. Currently only Ogg Theora video files are supported.
 
{{newobjectnotice}}
 
{{newobjectnotice}}
 +
 
== Function ==
 
== Function ==
 
=== Synopsis ===
 
=== Synopsis ===
Line 19: Line 20:
 
=== Arguments ===
 
=== Arguments ===
 
{{param|VideoStream|videostream|A video stream object.}}
 
{{param|VideoStream|videostream|A video stream object.}}
 +
=== Returns ===
 +
{{param|Video|video|A new Video.}}
 +
 +
== Function ==
 +
{{newin|[[11.0]]|110|type=variant}}
 +
=== Synopsis ===
 +
<source lang="lua">
 +
video = love.graphics.newVideo( filename, settings )
 +
</source>
 +
=== Arguments ===
 +
{{param|string|filename|The file path to the Ogg Theora video file (or [[VideoStream]]).}}
 +
{{param|table|settings|A table containing the following fields:}}
 +
{{subparam|boolean|audio (false)|Whether to try to load the video's audio into an audio [[Source]]. If not explicitly set to true or false, it will try without causing an error if the video has no audio.}}
 +
{{subparam|number|dpiscale ([[love.graphics.getDPIScale]]())|The DPI scale factor of the video.}}
 +
=== Returns ===
 +
{{param|Video|video|A new Video.}}
 +
 +
== Function ==
 +
{{newinoldin|[[0.10.0]]|100|[[11.0]]|110|type=variant}}
 +
=== Synopsis ===
 +
<source lang="lua">
 +
video = love.graphics.newVideo( filename, loadaudio )
 +
</source>
 +
=== Arguments ===
 +
{{param|string|filename|The file path to the Ogg Theora video file.}}
 +
{{param|boolean|loadaudio (nil)|Whether to try to load the video's audio into an audio [[Source]]. If not explicitly set to true or false, it will try without causing an error if the video has no audio.}}
 +
=== Returns ===
 +
{{param|Video|video|A new Video.}}
 +
 +
== Function ==
 +
{{newinoldin|[[0.10.0]]|100|[[11.0]]|110|type=variant}}
 +
=== Synopsis ===
 +
<source lang="lua">
 +
video = love.graphics.newVideo( videostream, loadaudio )
 +
</source>
 +
=== Arguments ===
 +
{{param|VideoStream|videostream|A video stream object.}}
 +
{{param|boolean|loadaudio (nil)|Whether to try to load the video's audio into an audio [[Source]]. If not explicitly set to true or false, it will try without causing an error if the video has no audio.}}
 
=== Returns ===
 
=== Returns ===
 
{{param|Video|video|A new Video.}}
 
{{param|Video|video|A new Video.}}
Line 34: Line 73:
 
end
 
end
 
</source>
 
</source>
 +
 +
== Notes ==
 +
 +
Löve only provides the basic functionality provided by libtheora. If your video plays fine in a video player but not in Löve, try different encoding options.
  
 
== See Also ==
 
== See Also ==

Latest revision as of 12:05, 22 March 2024

Available since LÖVE 0.10.0
This function is not supported in earlier versions.

Creates a new drawable Video. Currently only Ogg Theora video files are supported.

O.png This function can be slow if it is called repeatedly, such as from love.update or love.draw. If you need to use a specific resource often, create it once and store it somewhere it can be reused!  



Function

Synopsis

video = love.graphics.newVideo( filename )

Arguments

string filename
The file path to the Ogg Theora video file.

Returns

Video video
A new Video.

Function

Synopsis

video = love.graphics.newVideo( videostream )

Arguments

VideoStream videostream
A video stream object.

Returns

Video video
A new Video.

Function

Available since LÖVE 11.0
This variant is not supported in earlier versions.

Synopsis

video = love.graphics.newVideo( filename, settings )

Arguments

string filename
The file path to the Ogg Theora video file (or VideoStream).
table settings
A table containing the following fields:
boolean audio (false)
Whether to try to load the video's audio into an audio Source. If not explicitly set to true or false, it will try without causing an error if the video has no audio.
number dpiscale (love.graphics.getDPIScale())
The DPI scale factor of the video.

Returns

Video video
A new Video.

Function

Available since LÖVE 0.10.0 and removed in LÖVE 11.0
This variant is not supported in earlier or later versions.

Synopsis

video = love.graphics.newVideo( filename, loadaudio )

Arguments

string filename
The file path to the Ogg Theora video file.
boolean loadaudio (nil)
Whether to try to load the video's audio into an audio Source. If not explicitly set to true or false, it will try without causing an error if the video has no audio.

Returns

Video video
A new Video.

Function

Available since LÖVE 0.10.0 and removed in LÖVE 11.0
This variant is not supported in earlier or later versions.

Synopsis

video = love.graphics.newVideo( videostream, loadaudio )

Arguments

VideoStream videostream
A video stream object.
boolean loadaudio (nil)
Whether to try to load the video's audio into an audio Source. If not explicitly set to true or false, it will try without causing an error if the video has no audio.

Returns

Video video
A new Video.

Examples

Load and play a video.

function love.load()
    video = love.graphics.newVideo("myvideo.ogv")
    video:play()
end

function love.draw()
    love.graphics.draw(video, 0, 0)
end

Notes

Löve only provides the basic functionality provided by libtheora. If your video plays fine in a video player but not in Löve, try different encoding options.

See Also


Other Languages