Scripting API

Home Scripting API Index Class Overview

com.nolimitscoaster

Class StreamedSound


public final class StreamedSound
extends Object

Compared to static sounds, streamed sounds are not loaded into memory, instead portions are loaded while played.

Also, they do not have any spatial position and are therefore not affected by doppler effects or distance attenuation.

Method Summary

double getStreamingPosition()
  Returns the current position of the stream (in seconds).
bool isPlaying()
  Checks whether the stream is playing.
static StreamedSound loadFromFile(String path)
  Load a streamed sound file using a file path
static StreamedSound loadFromResource(ResourcePath resourcePath)
  Load a streamed sound file using a resource path.
static StreamedSound loadFromResourceId(String resourceId)
  Load a streamed sound file using a resourceId.
void play()
void playLoop()
void setGain(float gain)
  Sets the sound source's gain.
void setGainFaded(float gain, float fadeTime)
  Sets the sound source's target gain. Fades over time to the target gain from the current gain.
void stop()
void stopFaded(float fadeTime)
  Fades the sound and stops playing as soon as the volume has reached 0.


Method Detail


getStreamingPosition

public double getStreamingPosition()

Returns the current position of the stream (in seconds).

Returns:
    Stream position in seconds, -1 when not playing.

Since:
    2.6.2.0


isPlaying

public bool isPlaying()

Checks whether the stream is playing.

Since:
    2.6.2.0


loadFromFile

public static StreamedSound loadFromFile(String path)

Load a streamed sound file using a file path

path is relative to the classpath. The path should be a constant string expression so that the park package tool can detect used files. If the path is not a constant string expression, the compiler will show a warning and the file will not be detected by the package tool and will therefore not automatically be added to the park package. Will return null if the file could not be loaded.


loadFromResource

public static StreamedSound loadFromResource(ResourcePath resourcePath)

Load a streamed sound file using a resource path.

The resource path can be obtained from Script.getResourcePathForId Will return null if the resource path is null or the sound file could not be loaded.


loadFromResourceId

public static StreamedSound loadFromResourceId(String resourceId)

Load a streamed sound file using a resourceId.

The resourceId has to be specified in an .nl2script file. Will return null if the resourceId is unknown or the sound file could not be loaded.

Note: Deprecated  since 2.5.7.0 Use loadFromResource instead


play

public void play()


playLoop

public void playLoop()


setGain

public void setGain(float gain)

Sets the sound source's gain.

gain: 0..1


setGainFaded

public void setGainFaded(float gain, float fadeTime)

Sets the sound source's target gain. Fades over time to the target gain from the current gain.

gain: 0..1 fadeTime in seconds, must be >= 0


stop

public void stop()


stopFaded

public void stopFaded(float fadeTime)

Fades the sound and stops playing as soon as the volume has reached 0.

fadeTime in seconds, must be >= 0