Table of Contents

Class VideoPlayer

Namespace
easyar

VideoPlayer is a video player class. EasyAR supports normal videos, transparent videos, and stream playback. Video content will be rendered to the texture passed in setRenderTexture. This class only supports textures of OpenGLES 3.0. Because it depends on OpenGLES, all functions of this class (including the destructor) must be called in a single thread containing an OpenGLES context. The current version requires both width and height to be multiples of 16. Supported video file formats Windows: Media Foundation compatible formats, installing additional decoders can support more formats, please refer to Supported Media Formats in Media Foundation , does not support DirectShow Mac: Not supported Android: Formats supported by the system, please refer to Supported media formats . iOS: Formats supported by the system, currently there is no valid reference document

VideoPlayer

Constructors

VideoPlayer

void easyar_VideoPlayer__ctor(easyar_VideoPlayer * * Return)
VideoPlayer()
public VideoPlayer()
constructor()
+ (easyar_VideoPlayer *) create
public convenience init()
public VideoPlayer()

Methods

isAvailable

Check if available. Returns true only on Windows, Android, and iOS, not available on Mac.

bool easyar_VideoPlayer_isAvailable(void)
static bool isAvailable()
public static boolean isAvailable()
companion object fun isAvailable(): Boolean
+ (bool)isAvailable
public static func isAvailable() -> Bool
public static bool isAvailable()

Returns

Boolean

setVideoType

Set the video type. If not set manually, it will default to the normal type. This method needs to be called before open.

void easyar_VideoPlayer_setVideoType(easyar_VideoPlayer * This, easyar_VideoType videoType)
void setVideoType(VideoType videoType)
public void setVideoType(int videoType)
fun setVideoType(videoType: Int): Unit
- (void)setVideoType:(easyar_VideoType)videoType
public func setVideoType(_ videoType: VideoType) -> Void
public virtual void setVideoType(VideoType videoType)

Parameters

videoType VideoType

Returns

Void

setRenderTexture

Pass the texture used to display the video to the player. This method needs to be called before open.

void easyar_VideoPlayer_setRenderTexture(easyar_VideoPlayer * This, easyar_TextureId * texture)
void setRenderTexture(std::shared_ptr<TextureId> texture)
public void setRenderTexture(@Nonnull TextureId texture)
fun setRenderTexture(texture: TextureId): Unit
- (void)setRenderTexture:(easyar_TextureId *)texture
public func setRenderTexture(_ texture: TextureId) -> Void
public virtual void setRenderTexture(TextureId texture)

Parameters

texture TextureId

Returns

Void

open

Open 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. For detailed description, see StorageType. This method is an asynchronous method. Opening may take some time to complete. If you want to know the result of video opening or the status during playback, you need to process the callback data. The callback will be called in the thread corresponding to callbackScheduler. You can check in the callback whether the opening ends successfully and start playing after successful opening.

void easyar_VideoPlayer_open(easyar_VideoPlayer * This, easyar_String * path, easyar_StorageType storageType, easyar_CallbackScheduler * callbackScheduler, easyar_OptionalOfFunctorOfVoidFromVideoStatus callback)
void open(std::string path, StorageType storageType, std::shared_ptr<CallbackScheduler> callbackScheduler, std::optional<std::function<void(VideoStatus)>> callback)
public void open(java.lang.@Nonnull String path, int storageType, @Nonnull CallbackScheduler callbackScheduler, @Nullable FunctorOfVoidFromVideoStatus callback)
fun open(path: String, storageType: Int, callbackScheduler: CallbackScheduler, callback: FunctorOfVoidFromVideoStatus?): Unit
- (void)open:(NSString *)path storageType:(easyar_StorageType)storageType callbackScheduler:(easyar_CallbackScheduler *)callbackScheduler callback:(void (^)(easyar_VideoStatus status))callback
public func `open`(_ path: String, _ storageType: StorageType, _ callbackScheduler: CallbackScheduler, _ callback: ((VideoStatus) -> Void)?) -> Void
public virtual void open(string path, StorageType storageType, CallbackScheduler callbackScheduler, Optional<Action<VideoStatus>> callback)

Parameters

path String
storageType StorageType
callbackScheduler CallbackScheduler
callback Optional<Action<VideoStatus>>

Returns

Void

close

Close the video.

void easyar_VideoPlayer_close(easyar_VideoPlayer * This)
void close()
public void close()
fun close(): Unit
- (void)close
public func close() -> Void
public virtual void close()

Returns

Void

play

Start or continue playing the video.

bool easyar_VideoPlayer_play(easyar_VideoPlayer * This)
bool play()
public boolean play()
fun play(): Boolean
- (bool)play
public func play() -> Bool
public virtual bool play()

Returns

Boolean

stop

Stop video playback.

void easyar_VideoPlayer_stop(easyar_VideoPlayer * This)
void stop()
public void stop()
fun stop(): Unit
- (void)stop
public func stop() -> Void
public virtual void stop()

Returns

Void

pause

Pause video playback.

void easyar_VideoPlayer_pause(easyar_VideoPlayer * This)
void pause()
public void pause()
fun pause(): Unit
- (void)pause
public func pause() -> Void
public virtual void pause()

Returns

Void

isRenderTextureAvailable

Whether the video texture can be used for rendering. Can be used to check whether the texture passed into the player has been touched.

bool easyar_VideoPlayer_isRenderTextureAvailable(easyar_VideoPlayer * This)
bool isRenderTextureAvailable()
public boolean isRenderTextureAvailable()
fun isRenderTextureAvailable(): Boolean
- (bool)isRenderTextureAvailable
public func isRenderTextureAvailable() -> Bool
public virtual bool isRenderTextureAvailable()

Returns

Boolean

updateFrame

Update texture data. This method needs to be called on the rendering thread when isRenderTextureAvailable returns true.

void easyar_VideoPlayer_updateFrame(easyar_VideoPlayer * This)
void updateFrame()
public void updateFrame()
fun updateFrame(): Unit
- (void)updateFrame
public func updateFrame() -> Void
public virtual void updateFrame()

Returns

Void

duration

Returns the length of the video. Use after successful open.

int easyar_VideoPlayer_duration(easyar_VideoPlayer * This)
int duration()
public int duration()
fun duration(): Int
- (int)duration
public func duration() -> Int32
public virtual int duration()

Returns

Int32

currentPosition

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

int easyar_VideoPlayer_currentPosition(easyar_VideoPlayer * This)
int currentPosition()
public int currentPosition()
fun currentPosition(): Int
- (int)currentPosition
public func currentPosition() -> Int32
public virtual int currentPosition()

Returns

Int32

seek

Adjust the playback position to position. Use after successful open.

bool easyar_VideoPlayer_seek(easyar_VideoPlayer * This, int position)
bool seek(int position)
public boolean seek(int position)
fun seek(position: Int): Boolean
- (bool)seek:(int)position
public func seek(_ position: Int32) -> Bool
public virtual bool seek(int position)

Parameters

position Int32

Returns

Boolean

size

Returns the width and height of the video. Use after successful open.

easyar_Vec2I easyar_VideoPlayer_size(easyar_VideoPlayer * This)
Vec2I size()
public @Nonnull Vec2I size()
fun size(): Vec2I
- (easyar_Vec2I *)size
public func size() -> Vec2I
public virtual Vec2I size()

Returns

Vec2I

volume

Returns the video volume. Use after successful open.

float easyar_VideoPlayer_volume(easyar_VideoPlayer * This)
float volume()
public float volume()
fun volume(): Float
- (float)volume
public func volume() -> Float
public virtual float volume()

Returns

Single

setVolume

Set the video volume. Use after successful open.

bool easyar_VideoPlayer_setVolume(easyar_VideoPlayer * This, float volume)
bool setVolume(float volume)
public boolean setVolume(float volume)
fun setVolume(volume: Float): Boolean
- (bool)setVolume:(float)volume
public func setVolume(_ volume: Float) -> Bool
public virtual bool setVolume(float volume)

Parameters

volume Single

Returns

Boolean