Most visited

Recently visited

VideoTexture

public class VideoTexture
extends Texture

java.lang.Object
   ↳ com.viro.core.Texture
     ↳ com.viro.core.VideoTexture


VideoTexture plays video from local or remote sources. VideoTexture extends from Texture, so it can be used with any Material for display on any geometry. To make a video render on a Surface, for example, use:

 VideoTexture videoTexture = new VideoTexture(...);
 Material material = new Material();
 material.setDiffuseTexture(videoTexture);

 Surface surface = new Surface(10, 10);
 surface.setMaterials(Arrays.asList(material));
VideoTexture can also be rendered directly to the background of a Scene, which is useful for displaying spherical, immersive video in VR. To do so, use setBackgroundTexture(Texture).

Summary

Nested classes

interface VideoTexture.PlaybackListener

Callback interface for responding to video lifecycle and playback events. 

Public constructors

VideoTexture(ViroContext viroContext, Uri uri)

Construct a new VideoTexture that will play the video at the provided URI.

VideoTexture(ViroContext viroContext, Uri uri, VideoTexture.PlaybackListener listener)

Construct a new VideoTexture that will play the video at the provided URI.

VideoTexture(ViroContext viroContext, Uri uri, VideoTexture.PlaybackListener listener, Texture.StereoMode stereoMode)

Construct a new stereo VideoTexture that will play the video at the provided URI.

Public methods

void dispose()

Release native resources associated with this VideoTexture.

boolean getLoop()

Return true if the video is currently set to loop after finishing playback.

VideoTexture.PlaybackListener getPlaybackListener()

Get the VideoTexture.PlaybackListener used to receive callbacks for this VideoTexture.

float getVolume()

Get the volume of the video, between 0.0 and 1.0.

boolean isLoading()

Return true if the video is loading.

boolean isMuted()

Return true if the video is currently muted.

boolean isPaused()

Return true if the video is paused.

boolean isPlaying()

Return true if the video is currently playing.

void pause()

Pause the video.

void play()

Play the video.

void seekToTime(float seconds)

Seek to the given point in the video, in seconds.

void setLoop(boolean loop)

Set to true to make the video automatically loop to the beginning when playback finishes.

void setMuted(boolean muted)

Set to true to mute the video.

void setPlaybackListener(VideoTexture.PlaybackListener listener)

Set the VideoTexture.PlaybackListener, which can be used to respond to video loading and playback events.

void setVolume(float volume)

Set the volume to the given value, where 0.0 is mute and 1.0 is the maximum volume.

Public constructors

VideoTexture

VideoTexture (ViroContext viroContext, 
                Uri uri)

Construct a new VideoTexture that will play the video at the provided URI.

Parameters
viroContext ViroContext: The ViroContext is required to play videos.

uri Uri: The URI of the video. To load the video from an Android asset, use URI's of the form file:///android_asset/[asset-name].

VideoTexture

VideoTexture (ViroContext viroContext, 
                Uri uri, 
                VideoTexture.PlaybackListener listener)

Construct a new VideoTexture that will play the video at the provided URI.

Parameters
viroContext ViroContext: The ViroContext is required to play videos.

uri Uri: The URI of the video. To load the video from an Android asset, use URI's of the form file:///android_asset/[asset-name].

listener VideoTexture.PlaybackListener: VideoTexture.PlaybackListener which can be used to respond to video loading and playback events. May be null.

VideoTexture

VideoTexture (ViroContext viroContext, 
                Uri uri, 
                VideoTexture.PlaybackListener listener, 
                Texture.StereoMode stereoMode)

Construct a new stereo VideoTexture that will play the video at the provided URI. This constructor should be used when loading a stereo video. Stereo videos are designed to simulate 3D by rendering slightly different images to each eye, creating a realistic depth illusion. The StereoMode indicates how the stereo image is divided between the left eye and the right eye.

Parameters
viroContext ViroContext: The ViroContext is required to play videos.

uri Uri: The URI of the video. To load the video from an Android asset, use URI's of the form file:///android_asset/[asset-name].

listener VideoTexture.PlaybackListener: VideoTexture.PlaybackListener which can be used to respond to video loading and playback events. May be null.

stereoMode Texture.StereoMode: The Texture.StereoMode indicating which half of the video to render to the left eye, and which to render to the right eye. Null if the video is not stereo.

Public methods

dispose

void dispose ()

Release native resources associated with this VideoTexture.

getLoop

boolean getLoop ()

Return true if the video is currently set to loop after finishing playback.

Returns
boolean True if loop is enabled.

getPlaybackListener

VideoTexture.PlaybackListener getPlaybackListener ()

Get the VideoTexture.PlaybackListener used to receive callbacks for this VideoTexture.

Returns
VideoTexture.PlaybackListener The listener, or null if none is attached.

getVolume

float getVolume ()

Get the volume of the video, between 0.0 and 1.0.

Returns
float The volume.

isLoading

boolean isLoading ()

Return true if the video is loading.

Returns
boolean True if the video is loading.

isMuted

boolean isMuted ()

Return true if the video is currently muted.

Returns
boolean True if muted.

isPaused

boolean isPaused ()

Return true if the video is paused. The video can be played by invoking play().

Returns
boolean True if the video is paused.

isPlaying

boolean isPlaying ()

Return true if the video is currently playing. This returns false if the video is loading or paused.

Returns
boolean True if the video is playing.

pause

void pause ()

Pause the video.

play

void play ()

Play the video.

seekToTime

void seekToTime (float seconds)

Seek to the given point in the video, in seconds.

Parameters
seconds float: The seek position in seconds.

setLoop

void setLoop (boolean loop)

Set to true to make the video automatically loop to the beginning when playback finishes.

Parameters
loop boolean: True to loop.

setMuted

void setMuted (boolean muted)

Set to true to mute the video.

Parameters
muted boolean: True to mute.

setPlaybackListener

void setPlaybackListener (VideoTexture.PlaybackListener listener)

Set the VideoTexture.PlaybackListener, which can be used to respond to video loading and playback events.

Parameters
listener VideoTexture.PlaybackListener: The listener to use for this video.

setVolume

void setVolume (float volume)

Set the volume to the given value, where 0.0 is mute and 1.0 is the maximum volume. The default is 1.0.

Parameters
volume float: The value between 0.0 and 1.0.

Hooray!