ViroSpatialSound

A component that represents a sound in 3D space. Must be a single-channel sound (mono) and can be placed within a ViroNode or ViroAnimatedComponent which changes its position relative to the user. Refer to Sound under Develop for more information.

Example use:
<ViroSpatialSound
    source={require("./sound/mysound.wav")}
    position={[0, 0, -3]}
    onFinish={this.onFinishSound}
/>

Props

source (* required)

TypeDescription
ImageSourcePropTypeThe source of a spatial sound. Must be a single-channel audio file.

loop

TypeDescription
booleanSet to true to loop the spatial sound. This is set to false by default.

maxDistance

TypeDescription
numberA distance after which the audio can not be heard.

minDistance

TypeDescription
numberA distance after which the audio will begin to attenuate until maxDistance where the sound is completely gone.

muted

TypeDescription
booleanSet to true to mute the spatial sound. This is set to false by default.

onError

TypeDescription
FunctionCallback invoked when the 360 Image fails to load. The error message is contained in event.nativeEvent.error

onFinish

TypeDescription
FunctionCallback that is called when the spatial sound is finished playing. This function isn't called at the end of a spatial sound if looping is enabled.

paused

TypeDescription
booleanSet to true to pause the spatial sound. This is set to false by default.

rolloffModel

TypeDescription
"None" | "Linear" | "Logarithmic"The rolloff model which determines how the sound volume will fall off between minDistance and maxDistance. Accepts the following values:

None
Linear
* Logarithmic

volume

TypeDescription
numberA 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.

position

TypeDescription
[number, number, number]Cartesian position of the sound in 3D world space, specified as [x, y, z].

Method

seekToTime(timeInSeconds)

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

Parameters

timeInSeconds - The seek position in seconds.