MovieTexture duration

I use GUITexture on screen to play video, by attaching a video to its texture, then on script I want to fade it programatically, but I can’t get the length/duration of that MovieTexture, on the script reference there is duration variable member of MovieTexture, but it seems always has value of -1

so how is the correct way to get the length of video or MovieTexture

Start a timer and know the time for example

void Awake()
{

startTime = Time.time;

}

if(movieTexture.isPlaying == true)
{

elpasedTime = Time.time-startTime;

}

Now, elapsedTime will return your movieTexture Duration

We don’t have a in built method to read the time but there’s a traditional way…

function Awake()
{

startTime = Time.time;

}

Now some where in update or OnGUI write this following code…

if(movieTexture.isPlaying == true)
{

elapsedTime = Time.time - startTime;

}

Now elapsedTime returns the time taken by the movieTexture