A component that provides a 2D surface for playing video. This can be used to display virtual video screens.
Example use:
<ViroVideo
source={require('./video/myvid.mp4')}
loop={true}
position={[0,2,-5]}
scale={[2, 2, 0]}
/>
Props
Required Props
PropKey | PropType |
---|---|
source | PropTypes.oneOfType( [PropTypes.shape( {uri: PropTypes.string} ), PropTypes.number] ) The video source, a remote URL or a local file resource. MPEG videos accepted. To invoke with remote url:
To invoke with local source:
|
Optional Props
PropKey | PropType | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
animation | PropTypes.shape({ A collection of parameters that determine if this component should animate. For more information on animated components please see our Animation Guide. | ||||||||||
dragPlane | PropTypes.shape({ When a drag type of "FixedToPlane" is given, dragging is limited to a user defined plane. The dragging behavior is then configured by this property (specified by a point on the plane and its normal vector). You can also limit the maximum distance the dragged object is allowed to travel away from the camera/controller (useful for situations where the user can drag an object towards infinity). | ||||||||||
dragType | PropTypes.oneOf(["FixedDistance", "FixedToWorld"]) Determines the behavior of drag if onDrag is specified.
The default value is "FixedDistance". | ||||||||||
height | PropTypes.number The height of the video in 3D space. Default value is 1. | ||||||||||
highAccuracyEvents | PropTypes.bool True if events should use the geometry of the object to determine if the user is interacting with this object. If false, the object's axis-aligned bounding box will be used instead. Enabling this is more accurate but takes more processing power, so it is set to false by default. | ||||||||||
ignoreEventHandling | PropTypes.bool When set to true, this control will ignore events and not prevent controls behind it from receiving event callbacks. The default value is false. | ||||||||||
lightReceivingBitMask | PropTypes.number A bit mask that is bitwise and-ed (&) with each light's influenceBitMask. If the result is > 0, then the light will illuminate this object. For more information please see the Lighting and Materials Guide. | ||||||||||
loop | PropTypes.bool Set to true to loop the video. This is set to false by default. | ||||||||||
materials | PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string),PropTypes.string]) Takes array of 1 material that serves as the material of the surface that is displaying the video. | ||||||||||
muted | PropTypes.bool Set to true to mute the video. This is set to false by default. | ||||||||||
onBufferEnd | PropTypes.func Callback invoked when the underlying video component has finished buffering. | ||||||||||
onBufferStart | PropTypes.func Callback invoked when video begins buffering. Called at least once at the beginning of playback/video creation. | ||||||||||
onClick | PropTypes.func Called when an object has been clicked. Example code:
For the mapping of sources to controller inputs, see the Events section. | ||||||||||
onClickState | PropTypes.func Called for each click state an object goes through as it is clicked. Supported click states and their values are the following:
Example code:
For the mapping of sources to controller inputs, see the Events section. | ||||||||||
onCollision | React.PropTypes.func Called when this component's physics body collides with another component's physics body. Also invoked by ViroScene/ViroARScene's
| ||||||||||
onDrag | PropTypes.func Called when the view is currently being dragged. The dragToPos parameter provides the current 3D location of the dragged object. Example code:
For the mapping of sources to controller inputs, see the Events section. Unsupported VR Platforms: Cardboard iOS | ||||||||||
onError | PropTypes.func Callback invoked when the Video fails to load. The error message is contained in event.nativeEvent.error | ||||||||||
onFinish | PropTypes.func Callback that is called when the video is finished playing. This function isn't called at the end of a video if looping is enabled. | ||||||||||
onFuse | PropTypes.oneOfType
As shown above, onFuse takes one of the types - either a callback, or a dictionary with a callback and duration. It is called after the user hovers onto and remains hovered on the control for a certain duration of time, as indicated in timeToFuse that represents the duration of time in milliseconds. While hovering, the reticle will display a count down animation while fusing towards timeToFuse. Note that timeToFuse defaults to 2000ms. For example:
For the mapping of sources to controller inputs, see the Events section. | ||||||||||
onHover | PropTypes.func Called when the user hovers on or off the control. For example:
For the mapping of sources to controller inputs, see the Events section. | ||||||||||
onPinch | PropTypes.func Called when the user performs a pinch gesture on the control. When the pinch starts, the scale factor is set to 1 is relative to the points of the two touch points. For example:
pinchState can be the following values:
This event is only available in AR | ||||||||||
onRotate | PropTypes.func Called when the user performs a rotation touch gesture on the control. Rotation factor is returned in degrees. When setting rotation, the rotation should be relative to it's current rotation, not set to the absolute value of the given rotationFactor. For example:
rotationFactor can be the following values:
This event is only available in AR. | ||||||||||
onScroll | PropTypes.func Called when the user performs a scroll action, while hovering on the control. For example:
For the mapping of sources to controller inputs, see the Events section. Unsupported VR Platforms: Cardboard(Android and iOS) | ||||||||||
onSwipe | PropTypes.func Called when the user performs a swipe gesture on the physical controller, while hovering on this control. For example:
For the mapping of sources to controller inputs, see the Events section. Unsupported VR Platforms: Cardboard(Android and iOS) | ||||||||||
onTouch | PropTypes.func Called when the user performs a touch action, while hovering on the control. Provides the touch state type, and the x/y coordinate at which this touch event has occurred.
For example:
For the mapping of sources to controller inputs, see the Events section. Unsupported VR Platforms: Cardboard(Android and iOS). | ||||||||||
onTransformUpdate | PropTypes.func A function that is invoked when the component moves and provides an array of numbers representing the component's position in world coordinates. | ||||||||||
onUpdateTime | PropTypes.func Callback that is called when the current playback position has changed. For example:
| ||||||||||
opacity | PropTypes.number A number from 0 to 1 that specifies the opacity of the button. A value of 1 translates into a fully opaque button while 0 represents full transparency. | ||||||||||
paused | PropTypes.bool Set to true to pause the video. This is set to false by default. | ||||||||||
physicsBody | PropTypes.shape({..physics.api..}), Creates and binds a physics body that is configured with the provided collection of physics properties associated with this control. For more information on physics components, please see the physics.api. | ||||||||||
position | PropTypes.arrayOf(PropTypes.number) Cartesian position of the video in 3D world space, specified as [x, y, z]. | ||||||||||
rotation | PropTypes.arrayOf(PropTypes.number) The rotation of the box around it's local axis specified as Euler angles [x, y, z]. Units for each angle are specified in degrees. | ||||||||||
rotationPivot | PropTypes.arrayOf(PropTypes.number) Cartesian position in [x,y,z] about which rotation is applied relative to the component's position. | ||||||||||
scale | PropTypes.arrayOf(PropTypes.number) The scale of the box in 3D space, specified as [x,y,z]. A scale of 1 represents the current size of the box. A scale value of < 1 will make the box proportionally smaller while a value >1 will make the box proportionally bigger along the specified axis. | ||||||||||
scalePivot | PropTypes.arrayOf(PropTypes.number) Cartesian position in [x,y,z] from which scale is applied relative to the component's position. | ||||||||||
shadowCastingBitMask | PropTypes.number A bit mask that is bitwise and-ed (&) with each light's influenceBitMask. If the result is > 0, then this object will cast shadows from the light. For more information please see the Lighting and Materials Guide. | ||||||||||
stereoMode | PropTypes.oneOf(['leftRight', 'rightLeft', 'topBottom', 'bottomTop', 'none']) Specifies the alignment mode of the provided stereo video in source. The video will be rendered in the given order, the first being the left eye, the next the right eye. For example, leftRight will render the left half of the video to the left eye, and the right half of the video to the right eye. Similarly, topBottom will render the top half of the video to the left eye, and the bottom half of the video to the right eye. Defaults to none. | ||||||||||
transformBehaviors | PropTypes.arrayOf(PropTypes.string) An array of transform constraints that affect the transform of the object. For example, putting the value "billboard" will ensure the box is facing the user as the user rotates their head on any axis. This is useful for icons or text where you'd like the box to always face the user at a particular rotation. Allowed values(values are case sensitive):
| ||||||||||
viroTag | PropTypes.string A tag given to other components when their physics body collides with this component's physics body. Refer to physics for more information. | ||||||||||
visible | PropTypes.bool False if the video should be hidden. By default the video is visible and this value is true. | ||||||||||
volume | PropTypes.number A number represented volume from 0 to 1. Max volume is equal to 1. Min volume is equal to 0. This is set to 1 by default. | ||||||||||
width | PropTypes.number The width of the video in 3D space. Default value is 1. | ||||||||||
renderingOrder | PropTypes.number This determines the order in which this Node is rendered relative to other Nodes. Nodes with greater rendering orders are rendered last. The default rendering order is zero. For example, setting a Node's rendering order to -1 will cause the Node to be rendered before all Nodes with rendering orders greater than or equal to 0. |
Methods
seekToTime(timeInSeconds: number) | ||||
---|---|---|---|---|
Sets the video to the specified time in seconds.
|
async getTransformAsync() | ||||
---|---|---|---|---|
Async function that returns the component's transform (position, scale and rotation).
|
applyImpulse(force: arrayOf(number), position: arrayOf(number)) | ||||
---|---|---|---|---|
A function used with physics to apply an impulse (instantaneous) force to an object with a physics body.
|
applyTorqueImpulse(torque: arrayOf(number), position: arrayOf(number)) | ||||||
---|---|---|---|---|---|---|
A function used with physics to apply an impulse (instantaneous) torque to an object with a physics body.
|
setVelocity(velocity: arrayOf(number)) | ||||
---|---|---|---|---|
A function used with physics to set the velocity of an object with a physics body.
|
setNativeProps(nativeProps: object) | ||||
---|---|---|---|---|
A wrapper function around the native component's setNativeProps which allow users to set values on the native component without changing state/setting props and re-rendering. Refer to the React Native documentation on Direct Manipulation for more information.
For example, setting position natively would look like this:
|
Updated less than a minute ago