Most visited

Recently visited

SoundField

public class SoundField
extends Object

java.lang.Object
   ↳ com.viro.core.SoundField


SoundField emits environmental sound from every direction. It is the audio equivalent of a skybox or 360 image, providing atmospheric background noise. These sounds respond to the user's head rotation.

For an extended discussion of sound in Viro, refer to the Audio Guide.

Summary

Nested classes

interface SoundField.PlaybackListener

Callback interface for responding to SoundField events. 

Public constructors

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

Construct a new SoundField.

Public methods

void dispose()

Release native resources associated with this SoundField.

boolean getLoop()

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

SoundField.PlaybackListener getPlaybackListener()

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

float getVolume()

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

boolean isLoading()

Return true if the SoundField is loading.

boolean isMuted()

Return true if the SoundField is currently muted.

boolean isPaused()

Return true if the SoundField is paused.

boolean isPlaying()

Return true if the SoundField is currently playing.

void pause()

Pause the SoundField.

void play()

Play the SoundField.

void seekToTime(float seconds)

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

void setLoop(boolean loop)

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

void setMuted(boolean muted)

Set to true to mute the SoundField.

void setPlaybackListener(SoundField.PlaybackListener listener)

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

void setRotation(Vector rotation)

Set the rotation of this SoundField.

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

SoundField

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

Construct a new SoundField.

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

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

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

Public methods

dispose

void dispose ()

Release native resources associated with this SoundField.

getLoop

boolean getLoop ()

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

Returns
boolean True if loop is enabled.

getPlaybackListener

SoundField.PlaybackListener getPlaybackListener ()

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

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

getVolume

float getVolume ()

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

Returns
float The volume.

isLoading

boolean isLoading ()

Return true if the SoundField is loading.

Returns
boolean True if the SoundField is loading.

isMuted

boolean isMuted ()

Return true if the SoundField is currently muted.

Returns
boolean True if muted.

isPaused

boolean isPaused ()

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

Returns
boolean True if the SoundField is paused.

isPlaying

boolean isPlaying ()

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

Returns
boolean True if the SoundField is playing.

pause

void pause ()

Pause the SoundField.

play

void play ()

Play the SoundField.

seekToTime

void seekToTime (float seconds)

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

Parameters
seconds float: The seek position in seconds.

setLoop

void setLoop (boolean loop)

Set to true to make the SoundField 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 SoundField.

Parameters
muted boolean: True to mute.

setPlaybackListener

void setPlaybackListener (SoundField.PlaybackListener listener)

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

Parameters
listener SoundField.PlaybackListener: The listener to use for this SoundField.

setRotation

void setRotation (Vector rotation)

Set the rotation of this SoundField. This can be used to rotate the direction of sounds coming from the ambisonic sound field with respect to the user.

Parameters
rotation Vector: The rotation about the X, Y, and Z axes, in a Vector in radians.

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!