Table of Contents

Class VideoPlayer

命名空间
easyar

VideoPlayer是视频播放类。 EasyAR支持普通的视频、透明视频和流媒体播放。视频内容会被渲染到传入setRenderTexture的texture上。 该类只支持OpenGLES 3.0的texture。 由于依赖于OpenGLES,本类的所有函数(包括析构函数)都必须在单个包含OpenGLES上下文的线程中调用。 当前版本要求宽高均为16的倍数。 支持的视频文件格式 Windows: Media Foundation兼容格式,安装额外的解码器可以支持更多格式,请参考 Supported Media Formats in Media Foundation ,不支持DirectShow Mac: 不支持 Android: 系统支持的格式,请参考 Supported media formats 。 iOS: 系统支持的格式,当前没有有效的参考文档

VideoPlayer

构造函数

VideoPlayer

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

方法

isAvailable

检查是否可用。只在Windows、Android和iOS上返回true,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()

返回

类型 描述
Boolean

setVideoType

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

参数

名称 类型 描述
videoType VideoType

返回

类型 描述
Void

setRenderTexture

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

参数

名称 类型 描述
texture TextureId

返回

类型 描述
Void

open

从 path 打开视频。 path 可以是本地视频文件(path/to/video.mp4)或url(http://www.../.../video.mp4)。storageType 表示path的类型。详细描述参见 StorageType 。 这个方法是异步的方法。open可能会花一些时间才能完成。如果你希望知道视频打开的结果或播放中的状态,需要处理callback数据。callback会在callbackScheduler对应的线程中被调用。你可以在回调中检查打开是否成功结束并在成功打开之后开始播放。

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)

参数

名称 类型 描述
path String
storageType StorageType
callbackScheduler CallbackScheduler
callback Optional<Action<VideoStatus>>

返回

类型 描述
Void

close

关闭视频。

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()

返回

类型 描述
Void

play

开始或继续播放视频。

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()

返回

类型 描述
Boolean

stop

停止视频播放。

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()

返回

类型 描述
Void

pause

暂停视频播放。

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()

返回

类型 描述
Void

isRenderTextureAvailable

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

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()

返回

类型 描述
Boolean

updateFrame

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

返回

类型 描述
Void

duration

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

返回

类型 描述
Int32

currentPosition

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

返回

类型 描述
Int32

seek

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

参数

名称 类型 描述
position Int32

返回

类型 描述
Boolean

size

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

返回

类型 描述
Vec2I

volume

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

返回

类型 描述
Single

setVolume

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

参数

名称 类型 描述
volume Single

返回

类型 描述
Boolean