Recipe 16.3. Reading Playback Time


Problem

You want to read the current playback time of a video.

Solution

Use the time property of the NetStream object.

Discussion

The time property of the NetStream class is a read-only property that reports the playback time of the video. The value is in seconds from the start of the video. The following displays the playback time of a video in a text field:

textField.text = videoStream.time + " seconds";

Note that the value is not rounded to the nearest whole number. That means you can have values such as 1 as well as values such as 5.235. If you need whole numbers, you can use Math.round( ), Math.floor( ), or Math.ceil( ).

Since the time property is read-only, you cannot use it to control playback. If you want to control playback, use the seek( ) method as described in Recipe 16.5.

See Also

Recipes 4.3 and 16.5




ActionScript 3. 0 Cookbook
ActionScript 3.0 Cookbook: Solutions for Flash Platform and Flex Application Developers
ISBN: 0596526954
EAN: 2147483647
Year: 2007
Pages: 351

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net