Type Function Library native.* Return value Video Revision Release 2022.3683 Keywords video, video view, video overlay See also media.playVideo() video
Returns a video object that can be moved and rotated. This API supports local videos (in one of the system directories) or from a remote location (streaming).
This API is not available on Windows.
Native video objects are not part of the OpenGL canvas and do not obey the display object hierarchy, so they will always appear in front of normal display objects including images, text, and vector objects.
On Android, video objects do not rotate.
native.newVideo( x, y, width, height )
Number. The x coordinate that corresponds to the center of the video object.
Number. The y coordinate that corresponds to the center of the video object.
Number. Width of the video object.
Number. Height of the video object.
See the Video documentation for a list of methods and properties.
local video = native.newVideo( display.contentCenterX, display.contentCenterY, 320, 480 ) local function videoListener( event ) print( "Event phase: " .. event.phase ) if event.errorCode then native.showAlert( "Error!", event.errorMessage, { "OK" } ) end end -- Load a video and jump to 0:30 video:load( "myVideo.m4v", system.DocumentsDirectory ) video:seek( 30 ) -- Add video event listener video:addEventListener( "video", videoListener ) -- Play video video:play() -- Stop the video and remove video:pause() video:removeSelf() video = nil
local video = native.newVideo( display.contentCenterX, display.contentCenterY, 640, 360 ) local function videoListener( event ) print( "Event phase: " .. event.phase ) if event.errorCode then native.showAlert( "Error!", event.errorMessage, { "OK" } ) end end -- Load a remote video video:load( "https://coronalabs.com/video/bbb/BigBuckBunny_640x360.m4v", media.RemoteSource ) -- Add video event listener video:addEventListener( "video", videoListener ) -- Play video video:play()