VideoPlayer Class¶
Description¶
VideoPlayer is the class for video playback.
EasyAR supports normal videos, transparent videos and streaming videos. The video content will be rendered into a texture passed into the player through setRenderTexture.
This class only supports OpenGLES2 texture.
Due to the dependency to OpenGLES, every method in this class (including the destructor) has to be called in a single thread containing an OpenGLES context.
Current version requires width and height being mutiples of 16.
Supported video file formats
Windows: Media Foundation-compatible formats, more can be supported via extra codecs. Please refer to Supported Media Formats in Media Foundation . DirectShow is not supported.
Mac: Not supported.
Android: System supported formats. Please refer to Supported media formats .
iOS: System supported formats. There is no reference in effect currently.
Constructor¶
- C: void easyar_VideoPlayer__ctor(easyar_VideoPlayer * * Return)¶
- C++17: VideoPlayer()¶
- Traditional C++: VideoPlayer()¶
- Java: public VideoPlayer()¶
- Kotlin: constructor()¶
- Objective-C: + (easyar_VideoPlayer *) create¶
- Swift: public convenience init()¶
- C#: public VideoPlayer()¶
isAvailable¶
(since 3.1.0)
Checks if the component is available. It returns true only on Windows, Android or iOS. It's not available on Mac.
- C: bool easyar_VideoPlayer_isAvailable(void)¶
- C++17: static bool isAvailable()¶
- Traditional C++: static bool isAvailable()¶
- Java: public static boolean isAvailable()¶
- Kotlin: companion object fun isAvailable(): Boolean¶
- Objective-C: + (bool)isAvailable¶
- Swift: public static func isAvailable() -> Bool¶
- C#: public static bool isAvailable()¶
setVideoType¶
Sets the video type. The type will default to normal video if not set manually. It should be called before open.
- C: void easyar_VideoPlayer_setVideoType(easyar_VideoPlayer * This, easyar_VideoType videoType)¶
- C++17: void setVideoType(VideoType videoType)¶
- Traditional C++: void setVideoType(VideoType videoType)¶
- Java: public void setVideoType(int videoType)¶
- Kotlin: fun setVideoType(videoType: Int): Unit¶
- Objective-C: - (void)setVideoType:(easyar_VideoType)videoType¶
- Swift: public func setVideoType(_ videoType: VideoType) -> Void¶
- C#: public virtual void setVideoType(VideoType videoType)¶
setRenderTexture¶
Passes the texture to display video into player. It should be set before open.
- C: void easyar_VideoPlayer_setRenderTexture(easyar_VideoPlayer * This, easyar_TextureId * texture)¶
- Traditional C++: void setRenderTexture(TextureId * texture)¶
- Java: public void setRenderTexture(@Nonnull TextureId texture)¶
- Kotlin: fun setRenderTexture(texture: TextureId): Unit¶
- Objective-C: - (void)setRenderTexture:(easyar_TextureId *)texture¶
- Swift: public func setRenderTexture(_ texture: TextureId) -> Void¶
- C#: public virtual void setRenderTexture(TextureId texture)¶
open¶
Opens a video from path.
path can be a local video file (path/to/video.mp4) or url (http://www.../.../video.mp4). storageType indicates the type of path. See StorageType for more description.
This method is an asynchronous method. Open may take some time to finish. If you want to know the open result or the play status while playing, you have to handle callback. The callback will be called from a different thread. You can check if the open finished successfully and start play after a successful open.
- C: void easyar_VideoPlayer_open(easyar_VideoPlayer * This, easyar_String * path, easyar_StorageType storageType, easyar_CallbackScheduler * callbackScheduler, easyar_OptionalOfFunctorOfVoidFromVideoStatus callback)¶
- Traditional C++: void open(String * path, StorageType storageType, CallbackScheduler * callbackScheduler, OptionalOfFunctorOfVoidFromVideoStatus callback)¶
- Java: public void open(java.lang.@Nonnull String path, int storageType, @Nonnull CallbackScheduler callbackScheduler, @Nullable FunctorOfVoidFromVideoStatus callback)¶
- Kotlin: fun open(path: String, storageType: Int, callbackScheduler: CallbackScheduler, callback: FunctorOfVoidFromVideoStatus?): Unit¶
- Objective-C: - (void)open:(NSString *)path storageType:(easyar_StorageType)storageType callbackScheduler:(easyar_CallbackScheduler *)callbackScheduler callback:(void (^)(easyar_VideoStatus status))callback¶
- Swift: public func `open`(_ path: String, _ storageType: StorageType, _ callbackScheduler: CallbackScheduler, _ callback: ((VideoStatus) -> Void)?) -> Void¶
- C#: public virtual void open(string path, StorageType storageType, CallbackScheduler callbackScheduler, Optional<Action<VideoStatus>> callback)¶
close¶
Closes the video.
- C: void easyar_VideoPlayer_close(easyar_VideoPlayer * This)¶
- C++17: void close()¶
- Traditional C++: void close()¶
- Java: public void close()¶
- Kotlin: fun close(): Unit¶
- Objective-C: - (void)close¶
- Swift: public func close() -> Void¶
- C#: public virtual void close()¶
play¶
Starts or continues to play video.
- C: bool easyar_VideoPlayer_play(easyar_VideoPlayer * This)¶
- C++17: bool play()¶
- Traditional C++: bool play()¶
- Java: public boolean play()¶
- Kotlin: fun play(): Boolean¶
- Objective-C: - (bool)play¶
- Swift: public func play() -> Bool¶
- C#: public virtual bool play()¶
stop¶
Stops the video playback.
- C: void easyar_VideoPlayer_stop(easyar_VideoPlayer * This)¶
- C++17: void stop()¶
- Traditional C++: void stop()¶
- Java: public void stop()¶
- Kotlin: fun stop(): Unit¶
- Objective-C: - (void)stop¶
- Swift: public func stop() -> Void¶
- C#: public virtual void stop()¶
pause¶
Pauses the video playback.
- C: void easyar_VideoPlayer_pause(easyar_VideoPlayer * This)¶
- C++17: void pause()¶
- Traditional C++: void pause()¶
- Java: public void pause()¶
- Kotlin: fun pause(): Unit¶
- Objective-C: - (void)pause¶
- Swift: public func pause() -> Void¶
- C#: public virtual void pause()¶
isRenderTextureAvailable¶
Checks whether video texture is ready for render. Use this to check if texture passed into the player has been touched.
- C: bool easyar_VideoPlayer_isRenderTextureAvailable(easyar_VideoPlayer * This)¶
- C++17: bool isRenderTextureAvailable()¶
- Traditional C++: bool isRenderTextureAvailable()¶
- Java: public boolean isRenderTextureAvailable()¶
- Kotlin: fun isRenderTextureAvailable(): Boolean¶
- Objective-C: - (bool)isRenderTextureAvailable¶
- Swift: public func isRenderTextureAvailable() -> Bool¶
- C#: public virtual bool isRenderTextureAvailable()¶
updateFrame¶
Updates texture data. This should be called in the renderer thread when isRenderTextureAvailable returns true.
- C: void easyar_VideoPlayer_updateFrame(easyar_VideoPlayer * This)¶
- C++17: void updateFrame()¶
- Traditional C++: void updateFrame()¶
- Java: public void updateFrame()¶
- Kotlin: fun updateFrame(): Unit¶
- Objective-C: - (void)updateFrame¶
- Swift: public func updateFrame() -> Void¶
- C#: public virtual void updateFrame()¶
duration¶
Returns the video duration. Use after a successful open.
- C: int easyar_VideoPlayer_duration(easyar_VideoPlayer * This)¶
- C++17: int duration()¶
- Traditional C++: int duration()¶
- Java: public int duration()¶
- Kotlin: fun duration(): Int¶
- Objective-C: - (int)duration¶
- Swift: public func duration() -> Int32¶
- C#: public virtual int duration()¶
currentPosition¶
Returns the current position of video. Use after a successful open.
- C: int easyar_VideoPlayer_currentPosition(easyar_VideoPlayer * This)¶
- C++17: int currentPosition()¶
- Traditional C++: int currentPosition()¶
- Java: public int currentPosition()¶
- Kotlin: fun currentPosition(): Int¶
- Objective-C: - (int)currentPosition¶
- Swift: public func currentPosition() -> Int32¶
- C#: public virtual int currentPosition()¶
seek¶
Seeks to play to position . Use after a successful open.
- C: bool easyar_VideoPlayer_seek(easyar_VideoPlayer * This, int position)¶
- C++17: bool seek(int position)¶
- Traditional C++: bool seek(int position)¶
- Java: public boolean seek(int position)¶
- Kotlin: fun seek(position: Int): Boolean¶
- Objective-C: - (bool)seek:(int)position¶
- Swift: public func seek(_ position: Int32) -> Bool¶
- C#: public virtual bool seek(int position)¶
size¶
Returns the video size. Use after a successful open.
- C: easyar_Vec2I easyar_VideoPlayer_size(easyar_VideoPlayer * This)¶
- C++17: Vec2I size()¶
- Traditional C++: Vec2I size()¶
- Java: public @Nonnull Vec2I size()¶
- Kotlin: fun size(): Vec2I¶
- Objective-C: - (easyar_Vec2I *)size¶
- Swift: public func size() -> Vec2I¶
- C#: public virtual Vec2I size()¶
volume¶
Returns current volume. Use after a successful open.
- C: float easyar_VideoPlayer_volume(easyar_VideoPlayer * This)¶
- C++17: float volume()¶
- Traditional C++: float volume()¶
- Java: public float volume()¶
- Kotlin: fun volume(): Float¶
- Objective-C: - (float)volume¶
- Swift: public func volume() -> Float¶
- C#: public virtual float volume()¶
setVolume¶
Sets volume of the video. Use after a successful open.
- C: bool easyar_VideoPlayer_setVolume(easyar_VideoPlayer * This, float volume)¶
- C++17: bool setVolume(float volume)¶
- Traditional C++: bool setVolume(float volume)¶
- Java: public boolean setVolume(float volume)¶
- Kotlin: fun setVolume(volume: Float): Boolean¶
- Objective-C: - (bool)setVolume:(float)volume¶
- Swift: public func setVolume(_ volume: Float) -> Bool¶
- C#: public virtual bool setVolume(float volume)¶