Class VideoPlayer
- Namespace
- easyar
VideoPlayer is the video playback class. EasyAR supports normal video, transparent video, and streaming media playback. Video content is rendered to the texture passed to setRenderTexture. This class only supports OpenGLES 3.0 textures. Due to dependency on OpenGLES, all functions of this class (including destructors) must be called in a single thread containing the OpenGLES context. The current version requires both width and height to be multiples of 16. Supported video file formats: Windows: Media Foundation-compatible formats; installing additional decoders can support more formats, refer to Supported Media Formats in Media Foundation, DirectShow not supported Mac: Not supported Android: System-supported formats, refer to Supported media formats. iOS: System-supported formats, currently no effective reference documentation available.
Constructors
VideoPlayer
void easyar_VideoPlayer__ctor(easyar_VideoPlayer * * Return)
VideoPlayer()
public VideoPlayer()
constructor()
+ (easyar_VideoPlayer *) create
public convenience init()
public VideoPlayer()
Methods
isAvailable
Checks availability. Returns true only on Windows, Android, and iOS; not available on 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()
Returns
- Boolean
setVideoType
Sets the video type. If not manually set, it defaults to normal type. This method must be called before 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)
Parameters
videoTypeVideoType
Returns
- Void
setRenderTexture
Passes the texture for displaying video to the player. This method must be called before 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)
Parameters
textureTextureId
Returns
- Void
open
Opens video from path. path can be a local video file (path/to/video.mp4) or URL (http://www.../.../video.mp4). storageType indicates the path type. For detailed description, refer to StorageType. This method is asynchronous. open may take some time to complete. To know the opening result or playback status, handle callback data. The callback is invoked in the thread corresponding to callbackScheduler. You can check in the callback if opening succeeded and start playback after successful opening.
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)
Parameters
pathStringstorageTypeStorageTypecallbackSchedulerCallbackSchedulercallbackOptional<Action<VideoStatus>>
Returns
- Void
close
Closes the video.
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()
Returns
- Void
play
Starts or resumes video playback.
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()
Returns
- Boolean
stop
Stops video playback.
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()
Returns
- Void
pause
Pauses video playback.
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()
Returns
- Void
isRenderTextureAvailable
Indicates if the video texture is usable for rendering. Can check if the texture passed to the player has been touched.
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()
Returns
- Boolean
updateFrame
Updates texture data. This method must be called on the rendering thread when isRenderTextureAvailable returns 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()
Returns
- Void
duration
Returns video length. Use after successful 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()
Returns
- Int32
currentPosition
Returns the current playback position of the video. Use after successful 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()
Returns
- Int32
seek
Adjusts playback position to position. Use after successful 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)
Parameters
positionInt32
Returns
- Boolean
size
Returns video dimensions. Use after successful 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()
Returns
volume
Returns video volume. Use after successful 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()
Returns
- Single
setVolume
Sets video volume. Use after successful 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)
Parameters
volumeSingle
Returns
- Boolean