Table Of Contents

Previous topic

17.29. The Turbulenz Loader Object

Next topic

18. Low Level 2D Physics API

This Page

17.30. The Video Object

A Video object provides video-only playback.

The current playing video frame can be set as pixel data on a Texture object. The framerate of a video may be lower than the framerate of the game so it is recomended to check if the current playback possition has changed before setting it to a texture, for example:

var currentVideoPosition = video.tell;
if (currentVideoPosition &&
    lastUpdateVideoPosition !== currentVideoPosition)
{
    lastUpdateVideoPosition = currentVideoPosition;
    texture.setData(video);
}

A video object should always be destroyed when no longer needed, for example:

function cutSceneEnd()
{
    if (video)
    {
        video.destroy();
        video = null;
    }
};

17.30.1. Constructor

A Video object can be constructed with GraphicsDevice.createVideo.

17.30.2. Methods

17.30.2.1. play

Summary

Play the given video.

Syntax

video.play(position);
position (Optional)
The position in seconds where to start playing.

17.30.2.2. stop

Summary

Stop the video playback. If you pause you have to resume it before stopping.

Syntax

video.stop();

Returns true if the video was playing, false otherwise.

17.30.2.3. pause

Summary

Pause the video playback.

Syntax

video.pause();

Returns true if the video was playing, false otherwise.

17.30.2.4. resume

Summary

Resume the video playback.

Syntax

video.resume(position);
position (Optional)
The position in seconds where to resume playing.

Returns true if the video was paused, false otherwise.

17.30.2.5. rewind

Summary

Rewind the playback position to the start of the video.

Syntax

video.rewind();

Returns true if the playback position was not already at the start of the video, false otherwise.

17.30.2.6. destroy

Summary

Releases the Video; the object will be invalid after the method is called.

Syntax

video.destroy();

17.30.3. Properties

17.30.3.1. looping

Summary

True if the video should start playing again from the start when reaching the end, false if the video should stop when reaching the end.

Syntax

if (video.looping)
{
}

Note

Read Only

17.30.3.2. playing

Summary

True if the video is playing the video right now, false otherwise.

Syntax

if (video.playing)
{
}

Note

Read Only

17.30.3.3. paused

Summary

True if the video has been paused, false otherwise.

Syntax

if (video.paused)
{
}

Note

Read Only

17.30.3.4. tell

Summary

The current playback position in seconds, zero if playback has not started.

Syntax

var currentPlaybackPosition = video.tell;

Note

Read Only