VideoPlayerBaseBehaviour Class

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

enum ScaleMode{None, Fill, Fit, FitWidth, FitHeight}
enum ScalePlane{XY, XZ, YX, YZ, ZX, ZY}
enum VideoType{Normal, TransparentSideBySide, TransparentTopAndBottom}

Public Fields

bool EnableAutoPlay
bool EnableLoop
bool OpenWhenStart
bool DisplayTextMessage
string Path
StorageType Storage
VideoType Type
float VideoScaleFactorBase
ScaleMode VideoScaleMode
ScalePlane VideoScalePlane

Public Properties

float Volume

Public Functions

void Open()
void Close()
bool Play()
bool Pause()
bool Stop()
bool Seek(int position)
int CurPosition()
int Duration()
int Width()
int Height()

Public Events

event EventHandler VideoErrorEvent
event EventHandler VideoReachEndEvent
event EventHandler VideoReadyEvent

Overwritten MonoBahaviour Functions

protected virtual void Awake()
protected virtual void OnDestroy()
protected virtual void OnDisable()
protected virtual void OnEnable()
protected virtual void Start()
protected virtual void Update()

enum ScaleMode

Constant

Value

Description

None

0

Do not scale.

Fill

1

Fill the ImageTarget, video will be scaled to the same size of Imagetarget.

Fit

2

Fit the ImageTarget, video will be scaled to max that can fit into the Imagetarget.

FitWidth

3

Fit the ImageTarget width, video width will be set to the same value of Imagetarget width and the video ratio will be kept unchanged.

FitHeight

4

Fit 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

Constant

Value

Description

XY

1

Scale on XY plane.

XZ

2

Scale on XZ plane.

YX

4

Scale on YX plane.

YZ

6

Scale on YZ plane.

ZX

8

Scale on ZX plane.

ZY

9

Scale on ZY plane.

enum VideoType

Constant

Value

Description

Normal

0

Normal video.

TransparentSideBySide

1

Transparent video, left half is the RGB channel and right half is alpha channel.

TransparentTopAndBottom

2

Transparent video, top half is the RGB channel and bottom half is alpha channel.

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.

It can be a local video file (path/to/video.mp4) or url (http://www.../.../video.mp4). storageType indicates the type of path. See StorageType for more descriptions of StorageType.

StorageType Storage

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

VideoType Type

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

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.

This method is an async method. If you want to manually control the play, call Play from VideoReadyEvent handler after Open.

void Close()

Closes the video.

bool Play()

Starts or continues to play video.

If you want to manually control the play, call Play from VideoReadyEvent handler after Open.

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 (after VideoReadyEvent has been triggered).

int CurPosition()

Returns the current position of video. Use after a successful Open (after VideoReadyEvent has been triggered).

int Duration()

Returns the video duration. Use after a successful Open (after VideoReadyEvent has been triggered).

int Width()

Returns the video size. Use after a successful Open (after VideoReadyEvent has been triggered).

int Height()

Returns the video height. Use after a successful Open (after VideoReadyEvent has been triggered).

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.