Class VideoPlayer
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.
VideoPlayer
Constructors
VideoPlayer
void easyar_VideoPlayer__ctor(easyar_VideoPlayer * * Return)
+ (easyar_VideoPlayer *) create
public convenience init()
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
public static func isAvailable() -> Bool
public static bool isAvailable()
Returns
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
Returns
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
Returns
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
Returns
close
void easyar_VideoPlayer_close(easyar_VideoPlayer * This)
public func close() -> Void
public virtual void close()
Returns
play
Starts or resumes video playback.
bool easyar_VideoPlayer_play(easyar_VideoPlayer * This)
public func play() -> Bool
public virtual bool play()
Returns
stop
void easyar_VideoPlayer_stop(easyar_VideoPlayer * This)
public func stop() -> Void
public virtual void stop()
Returns
pause
void easyar_VideoPlayer_pause(easyar_VideoPlayer * This)
public func pause() -> Void
public virtual void pause()
Returns
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
updateFrame
Updates texture data. This method must be called on the rendering thread when isRenderTextureAvailable returns true.
void easyar_VideoPlayer_updateFrame(easyar_VideoPlayer * This)
public void updateFrame()
public func updateFrame() -> Void
public virtual void updateFrame()
Returns
duration
Returns video length. Use after successful open.
int easyar_VideoPlayer_duration(easyar_VideoPlayer * This)
public func duration() -> Int32
public virtual int duration()
Returns
currentPosition
Returns the current playback position of the video. Use after successful open.
int easyar_VideoPlayer_currentPosition(easyar_VideoPlayer * This)
public int currentPosition()
fun currentPosition(): Int
public func currentPosition() -> Int32
public virtual int currentPosition()
Returns
seek
Adjusts playback position to position. Use after successful open.
bool easyar_VideoPlayer_seek(easyar_VideoPlayer * This, 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
| Name |
Type |
Description |
| position |
Int32 |
|
Returns
size
Returns video dimensions. Use after successful open.
easyar_Vec2I easyar_VideoPlayer_size(easyar_VideoPlayer * This)
public @Nonnull 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)
public func volume() -> Float
public virtual float volume()
Returns
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
| Name |
Type |
Description |
| volume |
Single |
|
Returns