VideoPlayer Class

This type is an EasyAR Sense API in C#: VideoPlayer . Some descriptions may not apply to Unity environment on this page.

Some parts of the Sense API may have already been wrapped into Unity components, and directly usages may not be necessary.

Description

VideoPlayer is the class for video playback.

EasyAR supports normal videos, transparent videos and streaming videos. The video content will be rendered into a texture passed into the player through setRenderTexture.

This class only supports OpenGLES 3.0 texture.

Due to the dependency to OpenGLES, every method in this class (including the destructor) has to be called in a single thread containing an OpenGLES context.

Current version requires width and height being mutiples of 16.

Supported video file formats

Windows: Media Foundation-compatible formats, more can be supported via extra codecs. Please refer to Supported Media Formats in Media Foundation . DirectShow is not supported.

Mac: Not supported.

Android: System supported formats. Please refer to Supported media formats .

iOS: System supported formats. There is no reference in effect currently.


Methods

isAvailable

C#

public static bool isAvailable()

Checks if the component is available. It returns true only on Windows, Android or iOS. It’s not available on Mac.

setVideoType

C#

public virtual void setVideoType( VideoType videoType)

Sets the video type. The type will default to normal video if not set manually. It should be called before open.

setRenderTexture

C#

public virtual void setRenderTexture( TextureId texture)

Passes the texture to display video into player. It should be set before open.

open

C#

public virtual void open(string path, StorageType storageType, CallbackScheduler callbackScheduler, Optional<Action< VideoStatus >> callback)

Opens a video from path.

path 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 description.

This method is an asynchronous method. Open may take some time to finish. If you want to know the open result or the play status while playing, you have to handle callback. The callback will be called from a different thread. You can check if the open finished successfully and start play after a successful open.

close

C#

public virtual void close()

Closes the video.

play

C#

public virtual bool play()

Starts or continues to play video.

stop

C#

public virtual void stop()

Stops the video playback.

pause

C#

public virtual void pause()

Pauses the video playback.

isRenderTextureAvailable

C#

public virtual bool isRenderTextureAvailable()

Checks whether video texture is ready for render. Use this to check if texture passed into the player has been touched.

updateFrame

C#

public virtual void updateFrame()

Updates texture data. This should be called in the renderer thread when isRenderTextureAvailable returns true.

duration

C#

public virtual int duration()

Returns the video duration. Use after a successful open.

currentPosition

C#

public virtual int currentPosition()

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

seek

C#

public virtual bool seek(int position)

Seeks to play to position . Use after a successful open.

size

C#

public virtual Vec2I size()

Returns the video size. Use after a successful open.

volume

C#

public virtual float volume()

Returns current volume. Use after a successful open.

setVolume

C#

public virtual bool setVolume(float volume)

Sets volume of the video. Use after a successful open.