x


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

more ▼

asked Jul 04 '11 at 02:37 PM

uray gravatar image

uray
76 10 10 12

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

Do you not already know the duration of the movie clip from what you see in the import settings as well as in your finder? You also know what framerate it plays so you could just create a yield for that duration.

more ▼

answered Jul 04 '11 at 02:39 PM

Anxowtf gravatar image

Anxowtf
1.6k 22 27 37

well, how do i get that value programatically during runtime then?

Jul 04 '11 at 02:40 PM uray
(comments are locked)
10|3000 characters needed characters left

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

more ▼

answered Nov 16 '11 at 06:12 AM

lakshmi8 gravatar image

lakshmi8
-9 1 1

(comments are locked)
10|3000 characters needed characters left

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

more ▼

answered Nov 16 '11 at 06:12 AM

lakshmi8 gravatar image

lakshmi8
-9 1 1

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x282
x107
x31
x9

asked: Jul 04 '11 at 02:37 PM

Seen: 1659 times

Last Updated: Nov 16 '11 at 06:12 AM