Table Of Contents

Previous topic

Vec4I Record

Next topic

VideoStatus Enum

VideoPlayer Class

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.

Constructor

C: void easyar_VideoPlayer__ctor(easyar_VideoPlayer** Return)
C++11: VideoPlayer()
Traditional C++: VideoPlayer()
Java: public VideoPlayer()
Objective-C: + (easyar_VideoPlayer *) create
Swift (since EasyAR SDK 2.1.0): public convenience init()

setVideoType

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

C: void easyar_VideoPlayer_setVideoType(easyar_VideoPlayer* This, easyar_VideoType videoType)
C++11: void setVideoType(VideoType videoType)
Traditional C++: void setVideoType(VideoType videoType)
Java: public native void setVideoType(/* VideoType */ int videoType)
Objective-C: - (void)setVideoType:(easyar_VideoType)videoType
Swift (since EasyAR SDK 2.1.0): public func setVideoType(_ videoType: VideoType) -> Void

setRenderTexture

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

C: void easyar_VideoPlayer_setRenderTexture(easyar_VideoPlayer* This, void* texture)
C++11: void setRenderTexture(void * texture)
Traditional C++: void setRenderTexture(void* texture)
Java: public native void setRenderTexture(long texture)
Objective-C: - (void)setRenderTexture:(void *)texture
Swift (since EasyAR SDK 2.1.0): public func setRenderTexture(_ texture: OpaquePointer) -> Void

open

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

C: void easyar_VideoPlayer_open(easyar_VideoPlayer* This, easyar_String* path, easyar_StorageType storageType, easyar_FunctorOfVoidFromVideoStatus callback)
C++11: void open(std::string path, StorageType storageType, std::function<void(VideoStatus)> callback)
Traditional C++: void open(String* path, StorageType storageType, FunctorOfVoidFromVideoStatus callback)
Java: public native void open(java.lang.String path, /* StorageType */ int storageType, FunctorOfVoidFromVideoStatus callback)
Objective-C: - (void)open:(NSString *)path storageType:(easyar_StorageType)storageType callback:(void (^)(easyar_VideoStatus status))callback
Swift (since EasyAR SDK 2.1.0): public func `open`(_ path: String, _ storageType: StorageType, _ callback: @escaping (VideoStatus) -> Void) -> Void

close

Closes the video.

C: void easyar_VideoPlayer_close(easyar_VideoPlayer* This)
C++11: void close()
Traditional C++: void close()
Java: public native void close()
Objective-C: - (void)close
Swift (since EasyAR SDK 2.1.0): public func close() -> Void

play

Starts or continues to play video.

C: bool easyar_VideoPlayer_play(easyar_VideoPlayer* This)
C++11: bool play()
Traditional C++: bool play()
Java: public native boolean play()
Objective-C: - (bool)play
Swift (since EasyAR SDK 2.1.0): public func play() -> Bool

stop

Stops the video playback.

C: bool easyar_VideoPlayer_stop(easyar_VideoPlayer* This)
C++11: bool stop()
Traditional C++: bool stop()
Java: public native boolean stop()
Objective-C: - (bool)stop
Swift (since EasyAR SDK 2.1.0): public func stop() -> Bool

pause

Pauses the video playback.

C: bool easyar_VideoPlayer_pause(easyar_VideoPlayer* This)
C++11: bool pause()
Traditional C++: bool pause()
Java: public native boolean pause()
Objective-C: - (bool)pause
Swift (since EasyAR SDK 2.1.0): public func pause() -> Bool

isRenderTextureAvailable

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

C: bool easyar_VideoPlayer_isRenderTextureAvailable(easyar_VideoPlayer* This)
C++11: bool isRenderTextureAvailable()
Traditional C++: bool isRenderTextureAvailable()
Java: public native boolean isRenderTextureAvailable()
Objective-C: - (bool)isRenderTextureAvailable
Swift (since EasyAR SDK 2.1.0): public func isRenderTextureAvailable() -> Bool

updateFrame

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

C: void easyar_VideoPlayer_updateFrame(easyar_VideoPlayer* This)
C++11: void updateFrame()
Traditional C++: void updateFrame()
Java: public native void updateFrame()
Objective-C: - (void)updateFrame
Swift (since EasyAR SDK 2.1.0): public func updateFrame() -> Void

duration

Returns the video duration. Use after a successful open.

C: int easyar_VideoPlayer_duration(easyar_VideoPlayer* This)
C++11: int duration()
Traditional C++: int duration()
Java: public native int duration()
Objective-C: - (int)duration
Swift (since EasyAR SDK 2.1.0): public func duration() -> Int32

currentPosition

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

C: int easyar_VideoPlayer_currentPosition(easyar_VideoPlayer* This)
C++11: int currentPosition()
Traditional C++: int currentPosition()
Java: public native int currentPosition()
Objective-C: - (int)currentPosition
Swift (since EasyAR SDK 2.1.0): public func currentPosition() -> Int32

seek

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

C: bool easyar_VideoPlayer_seek(easyar_VideoPlayer* This, int position)
C++11: bool seek(int position)
Traditional C++: bool seek(int position)
Java: public native boolean seek(int position)
Objective-C: - (bool)seek:(int)position
Swift (since EasyAR SDK 2.1.0): public func seek(_ position: Int32) -> Bool

size

Returns the video size. Use after a successful open.

C: easyar_Vec2I easyar_VideoPlayer_size(easyar_VideoPlayer* This)
C++11: Vec2I size()
Traditional C++: Vec2I size()
Java: public native Vec2I size()
Objective-C: - (easyar_Vec2I *)size
Swift (since EasyAR SDK 2.1.0): public func size() -> Vec2I

volume

Returns current volume. Use after a successful open.

C: float easyar_VideoPlayer_volume(easyar_VideoPlayer* This)
C++11: float volume()
Traditional C++: float volume()
Java: public native float volume()
Objective-C: - (float)volume
Swift (since EasyAR SDK 2.1.0): public func volume() -> Float

setVolume

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

C: bool easyar_VideoPlayer_setVolume(easyar_VideoPlayer* This, float volume)
C++11: bool setVolume(float volume)
Traditional C++: bool setVolume(float volume)
Java: public native boolean setVolume(float volume)
Objective-C: - (bool)setVolume:(float)volume
Swift (since EasyAR SDK 2.1.0): public func setVolume(_ volume: Float) -> Bool