Class SoundUtil

  • All Implemented Interfaces:

    
    public class SoundUtil
    
                        

    A helper class to deal with short notification sounds.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public class SoundUtil.SoundAttributes

      A helper class containing sound attributes.

    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      SoundUtil(Context context) Create a SoundUtil helper with the given context.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      SoundUtil.SoundAttributes loadSoundFromAssets(String assetFileName) Load the sound from the given asset file name (with relative path within the assets).
      void playSound(String assetFileName) Play the sound previously loaded from the given asset file name.
      void releaseSoundPool() Release the sound pool.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SoundUtil

        SoundUtil(Context context)
        Create a SoundUtil helper with the given context.
        Parameters:
        context - the context
    • Method Detail

      • loadSoundFromAssets

         SoundUtil.SoundAttributes loadSoundFromAssets(String assetFileName)

        Load the sound from the given asset file name (with relative path within the assets). Load MUST be called before playSound is called.

        Parameters:
        assetFileName - the sound file to load (from assets, with relative path within assets)
        Returns:

        a ( for the given assetFileName

      • playSound

         void playSound(String assetFileName)

        Play the sound previously loaded from the given asset file name. loadSoundFromAssets MUST be called before this.

        Parameters:
        assetFileName - the sound file to play (same as previously used with load)
      • releaseSoundPool

         void releaseSoundPool()

        Release the sound pool. This should be called if the util is no longer used. The SoundUtil can no longer be used and the reference should be set to null.