內容目录

上一个主题

Vec4I Record

下一个主题

VideoStatus Enum

VideoPlayer Class

Description

VideoPlayer是视频播放类。

EasyAR支持普通的视频、透明视频和流媒体播放。视频内容会被渲染到传入setRenderTexture的texture上。

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

设置视频类型。如果没有手动设置,将默认为普通类型。这个方法需要在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

传入用来显示视频的texture到播放器。这个方法需要在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

从 path 打开视频。

path 可以是本地视频文件(path/to/video.mp4)或url(http://www.../.../video.mp4)。storageType 表示path的类型。关于StorageType的详细描述参见 StorageType

这个方法是异步的方法。Open可能会花一些时间才能完成。如果你希望知道视频打开的结果或播放中的状态,需要处理callback数据。callback会在其它线程被调用。你可以在回调中检查打开是否成功结束并在成功打开之后开始播放。

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

关闭视频。

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

开始或继续播放视频。

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

停止视频播放。

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

暂停视频播放。

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

视频texture是否可以用于渲染。可以用于检查传入player的texture是否被碰过。

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

更新texture数据。这个方法需要在isRenderTextureAvailable返回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

返回视频长度。在成功的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

返回当前播放到的视频位置。在成功的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

将播放位置调整到 position 。在成功的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

返回视频长宽。在成功的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

返回视频音量。在成功的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

设置视频音量。在成功的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