Getting Started with EasyAR

Description

VideoPlayerBaseBehaviour is the component to control VideoPlayer in the AR scene.

A VideoPlayerBaseBehaviour can be added to any object and the Video will be displayed on top of the object.

It should be child or grandchild to an ImageTargetBaseBehaviour to use the auto scale.

To play a transparent video, you need to set the object material to display alpha channel. EasyAR provides a sample material TransparentVideo.mat.

Public Types

enumScaleMode{None, Fill, Fit, FitWidth, FitHeight}
enumScalePlane{XY, XZ, YX, YZ, ZX, ZY}

Public Fields

boolEnableAutoPlay
boolEnableLoop
boolOpenWhenStart
boolDisplayTextMessage
stringPath
StorageTypeStorage
VideoPlayer.VideoTypeType
VideoPlayerVideoPlayer
floatVideoScaleFactorBase
ScaleModeVideoScaleMode
ScalePlaneVideoScalePlane

Public Properties

floatVolume

Public Functions

voidOpen()
voidClose()
boolPlay()
boolPause()
boolStop()
boolSeek(int position)
intCurPosition()
intDuration()
intWidth()
intHeight()

Public Events

event EventHandlerVideoErrorEvent
event EventHandlerVideoReachEndEvent
event EventHandlerVideoReadyEvent

Overwritten MonoBahaviour Functions

protected virtual voidAwake()
protected virtual voidOnDestroy()
protected virtual voidOnDisable()
protected virtual voidOnEnable()
protected virtual voidStart()
protected virtual voidUpdate()

enum ScaleMode

ConstantValueDescription
None0Do not scale.
Fill1Fill the ImageTarget, video will be scaled to the same size of Imagetarget.
Fit2Fit the ImageTarget, video will be scaled to max that can fit into the Imagetarget.
FitWidth3Fit the ImageTarget width, video width will be set to the same value of Imagetarget width and the video ratio will be kept unchanged.
FitHeight4Fit the ImageTarget height, video height will be set to the same value of Imagetarget height and the video ratio will be kept unchanged.

enum ScalePlane

ConstantValueDescription
XY1Scale on XY plane.
XZ2Scale on XZ plane.
YX4Scale on YX plane.
YZ6Scale on YZ plane.
ZX8Scale on ZX plane.
ZY9Scale on ZY plane.

bool EnableAutoPlay

Enables auto play. If enabled, when video finished open and ready, it will automatically start to play.

bool EnableLoop

Enables loop play. If enabled, when video reach end, it will play again from the start.

bool OpenWhenStart

Open Video when MonoBehaviour.Start

bool DisplayTextMessage

Display unsupport message on platforms that are not supported.

string Path

Video path. The set operation should be called before Open. See StorageType for more details.

StorageType Storage

Video storage type. The set operation should be called before Open. See StorageType for more details.

VideoPlayer.VideoType Type

Video type. The set operation should be called before Open.

VideoPlayer VideoPlayer

The VideoPlayer object. You can reach advanced controls with VideoPlayer. See VideoPlayer for more details.

float VideoScaleFactorBase

The base factor for video scale. It will be multiplied to the scaled size when scale. Normally you can set 0.1 for plane and 1 for other simple objects.

ScaleMode VideoScaleMode

The scale mode.

ScalePlane VideoScalePlane

The plane used for scale. Object size will be adjusted according to the scale mode and ImageTarget size in the plane direction.

float Volume

Current volume. Use after a successful Open.

void Open()

Opens the video. Reference VideoPlayer.Open for more deatils.

void Close()

Closes the video.

bool Play()

Starts or continues to play video.

bool Pause()

Pauses the video playback.

bool Stop()

Stops the video playback.

bool Seek(int position)

Seek to play to position. Use after a successful Open.

int CurPosition()

Returns the current position of video. Use after a successful Open.

int Duration()

Returns the video duration. Use after a successful Open.

int Width()

Returns the video size. Use after a successful Open.

int Height()

Returns the video height. Use after a successful Open.

event EventHandler VideoErrorEvent

Event for video open error and play error.

event EventHandler VideoReachEndEvent

Event when video reaches end.

event EventHandler VideoReadyEvent

Event when video finished open and ready for play. You can start to play when this event triggers.