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 OpenGLES 3.0 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++
 VideoPlayer()
- Java
 public VideoPlayer()
- Kotlin
 constructor()
- Objective-C
 + (easyar_VideoPlayer *) create
- Swift
 public convenience init()
- C#
 public VideoPlayer()
isAvailable¶
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++
 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++
 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)
- C++
 void setRenderTexture(std::shared_ptr<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)
- C++
 void open(std::string path, StorageType storageType, std::shared_ptr<CallbackScheduler> callbackScheduler, std::optional<std::function<void(VideoStatus)>> 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++
 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++
 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++
 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++
 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++
 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++
 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++
 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++
 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++
 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.
volume¶
Returns current volume. Use after a successful open.
- C
 float easyar_VideoPlayer_volume(easyar_VideoPlayer * This)
- 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++
 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)