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