GetVideoDuration

Definition

double GetVideoDuration(string videoName)

Description

This function returns the duration of videoName video object.

Parameters

videoName
Specifies the video name. You can also use the name “this” for this parameter. In this case, “this” string refers to the name of the video to which this script is attached.

Return Value

Duration of video object.

Example 1

duration = 0.0

function Init()
    duration = GetVideoDuration("video1")

    message = string.format("\nVideo duration is (%.2f) seconds", duration)
    PrintConsole(message)
end

function Update()

end
First, we get the duration of video “video1”. Then we display the duration in the console using the PrintConsole function.

Example 2

--Name of script is GetVideoDuration2.lua

duration = 0.0

function Init()
    duration = GetVideoDuration("this")

    message = string.format("\nVideo duration is (%.2f) seconds", duration)
    PrintConsole(message)
end

function Update()

end
Assume that the above script named GetVideoDuration2.lua is attached to a video object named “video1”. In this case, string “this”  in the GetVideoDuration function will be equal to “video1”. In our example, the function GetVideoDuration returns the duration of current video, which is “video1”.
adminGetVideoDuration