VideoPlayer Class

Header: #include "easyar/player.hpp"
Inherits: RefBase

Description

VideoPlayer is the class for video playback.

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

Public Types

enum Status{kVideoError, kVideoReady, kVideoCompleted}
enum VideoType{kVideoTypeNormal, kVideoTypeTransparentSideBySide, kVideoTypeTransparentTopAndBottom}

Public Functions

VideoPlayer()
virtual ~VideoPlayer()
void setRenderTexture(int texture)
void setVideoType(VideoType videoType)
void open(const char* path, StorageType storageType, VideoPlayerCallBack* callback = 0)
void close()
bool play()
bool stop()
bool pause()
void updateFrame()
int duration()
int currentPosition()
bool seek(int position)
Vec2I size()
float volume()
bool setVolume(float volume)

enum VideoPlayer::Status

Constant Value Description
kVideoError -1 Status to indicate something wrong happen in video open or play.
kVideoReady 0 Status to show video finished open and is ready for play.
kVideoCompleted 1 Status to indicate video finished play and reached the end.

enum VideoPlayer::VideoType

Constant Value Description
kVideoTypeNormal 0 Normal video.
kVideoTypeTransparentSideBySide 1 Transparent video, left half is the RGB channel and right half is alpha channel.
kVideoTypeTransparentTopAndBottom 2 Transparent video, top half is the RGB channel and bottom half is alpha channel.

VideoPlayer()

Creates a VideoPlayer object.

virtual ~VideoPlayer()

Destroys the VideoPlayer object.

void setRenderTexture(int texture)

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

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.

void open(const char* path, StorageType storageType, VideoPlayerCallBack* callback = 0)

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 descriptions of StorageType.

This method is an async 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 provide a non-null callback. The callback will be called from a different thread. You can check if the open finished successfully and start play after a successful one.

void close()

Closes the video.

bool play()

Starts or continues to play video.

bool stop()

Stops the video playback.

bool pause()

Pauses the video playback.

void updateFrame()

Updates texture data. This should be called in the renderer thread.

int duration()

Returns the video duration. Use after a successful open.

int currentPosition()

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

bool seek(int position)

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

Vec2I size()

Returns the video size. Use after a successful open.

float volume()

Returns current volume. Use after a successful open.

bool setVolume(float volume)

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

results matching ""

    No results matching ""