Package playn.core

Class SoundImpl<I>

java.lang.Object
playn.core.Sound
playn.core.SoundImpl<I>

public abstract class SoundImpl<I> extends Sound
An implementation detail. Not part of the public API.
  • Nested Class Summary

    Nested classes/interfaces inherited from class playn.core.Sound

    Sound.Error
  • Field Summary

    Fields inherited from class playn.core.Sound

    state
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    fail(Throwable error)
    Configures this sound with an error in lieu of its platform implementation.
    boolean
    Determine whether this audio stream is currently playing.
    boolean
    If possible, begin playback of this audio stream.
    boolean
    Prepares this sound to be played by preloading it into audio buffers.
    void
    Releases resources used by this sound.
    void
    setLooping(boolean looping)
    Set whether audio stream playback should be looped indefinitely or not.
    void
    setVolume(float volume)
     
    void
    Stop playback of the current audio stream as soon as possible, and reset the sound position to its starting position, such that a subsequent call to Sound.play() will cause the audio file to being playback from the beginning of the audio stream.
    void
    succeed(I impl)
    Configures this sound with its platform implementation.
    float
     

    Methods inherited from class playn.core.Sound

    isLoaded

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SoundImpl

      public SoundImpl(Exec exec)
  • Method Details

    • succeed

      public void succeed(I impl)
      Configures this sound with its platform implementation. This may be called from any thread.
    • fail

      public void fail(Throwable error)
      Configures this sound with an error in lieu of its platform implementation. This may be called from any thread.
    • prepare

      public boolean prepare()
      Description copied from class: Sound
      Prepares this sound to be played by preloading it into audio buffers. This expresses a desire to have subsequent calls to Sound.play() start emitting sound with the lowest possible latency.
      Overrides:
      prepare in class Sound
      Returns:
      true if preloading occurred, false if unsupported or preloading failed
    • isPlaying

      public boolean isPlaying()
      Description copied from class: Sound
      Determine whether this audio stream is currently playing.
      Overrides:
      isPlaying in class Sound
      Returns:
      true if the audio stream is currently playing
    • play

      public boolean play()
      Description copied from class: Sound
      If possible, begin playback of this audio stream. The audio system will make best efforts to playback this sound. However, lack of audio or codec support, or a (temporary) unavailability of audio channels may prevent playback. If the audio system is certain that audio playback failed, this method will return false. However, a return value of true does not guarantee that playback will in fact succeed.
      Overrides:
      play in class Sound
      Returns:
      true if it's likely that audio playback will proceed
    • stop

      public void stop()
      Description copied from class: Sound
      Stop playback of the current audio stream as soon as possible, and reset the sound position to its starting position, such that a subsequent call to Sound.play() will cause the audio file to being playback from the beginning of the audio stream.
      Overrides:
      stop in class Sound
    • setLooping

      public void setLooping(boolean looping)
      Description copied from class: Sound
      Set whether audio stream playback should be looped indefinitely or not.
      Overrides:
      setLooping in class Sound
      Parameters:
      looping - true if the audio stream should be looped indefinitely
    • volume

      public float volume()
      Overrides:
      volume in class Sound
      Returns:
      the current volume of this sound, a value between 0.0 and 1.0.
    • setVolume

      public void setVolume(float volume)
      Overrides:
      setVolume in class Sound
      Parameters:
      volume - new volume between 0.0 and 1.0
    • release

      public void release()
      Description copied from class: Sound
      Releases resources used by this sound. It will no longer be usable after release. This will also happen automatically when this sound is garbage collected, but one may need to manually release sounds sooner to avoid running out of audio resources.
      Overrides:
      release in class Sound