Type Function Library native.* Return value Video Revision 2017.3060 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 (server).
This feature is only supported on Android and iOS.
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.
If you require video support on other platforms, then you must use the media.playVideo() function instead.
native.newVideo( centerX, centerY, width, height )
Numbers. The x and y coordinates that correspond to the center of the video object.
Numbers. The width and 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( "http://www.coronalabs.com/video/bbb/BigBuckBunny_640x360.m4v", media.RemoteSource )
-- Add video event listener
video:addEventListener( "video", videoListener )
-- Play video
video:play()