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 |