Interface MediaLoader


public interface MediaLoader
Loads media files such as images or audio in a format that can later be used by the renderer. Using this interface to load resource files is guaranteed to work on all platforms that are supported by MultimediaLib. Using other ways of loading files, such as directly from the file system or from the classpath, may not be supported on some platforms.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    containsResourceFile(nl.colorize.util.ResourceFile file)
    Returns whether the specified resource file is available.
    nl.colorize.util.SubscribableCollection<LoadStatus>
    Returns a buffer containing the load status of all media files that have been loaded by this MediaLoader.
    Loads the application data for the application with the specified name.
    default SpriteAtlas
    loadAtlas(nl.colorize.util.ResourceFile file)
    Loads a sprite atlas based on the libGDX .atlas file format.
    loadAudio(nl.colorize.util.ResourceFile file)
    Loads an audio clip from a file.
    default FontFace
    loadDefaultFont(int size, ColorRGB color)
    Loads the default font, the open source font Open Sans.
    loadFont(nl.colorize.util.ResourceFile file, String family, int size, ColorRGB color)
    Loads a TrueType or FreeType font so the renderer can use that font for text rendering.
    loadImage(nl.colorize.util.ResourceFile file)
    Loads an image from a file.
    loadModel(nl.colorize.util.ResourceFile file)
    Loads a polygon model from the specified file.
    default Properties
    loadProperties(nl.colorize.util.ResourceFile file)
    Convenience method that loads and then parses the contents of a .properties file.
    loadText(nl.colorize.util.ResourceFile file)
    Loads a text-based resource file using UTF-8 encoding.
    default List<String>
    loadTextLines(nl.colorize.util.ResourceFile file)
    Loads a text-based resource file using UTF-8 encoding, and returns it as a list of lines.
    default nl.colorize.util.TranslationBundle
    loadTranslationBundle(nl.colorize.util.ResourceFile file)
    Convenience method that loads and then parses the contents of a .properties file and returns a TranslationBundle.
    void
    Saves the application data for the application with the specified name.
  • Method Details

    • loadImage

      Image loadImage(nl.colorize.util.ResourceFile file)
      Loads an image from a file. Images in JPEG and PNG format are supported by all renderers.
      Throws:
      MediaException - if the format is not supported by the renderer.
    • loadAtlas

      default SpriteAtlas loadAtlas(nl.colorize.util.ResourceFile file)
      Loads a sprite atlas based on the libGDX .atlas file format. This will parse the .atlas file, and will then load all images used within the sprite atlas.
      Throws:
      MediaException - if one of the images used in the sprite atlas uses a format that is not supported by the renderer,
    • loadAudio

      Audio loadAudio(nl.colorize.util.ResourceFile file)
      Loads an audio clip from a file. MP3 files are supported by all renderers.
      Throws:
      MediaException - if the format is not supported by the renderer.
    • loadFont

      FontFace loadFont(nl.colorize.util.ResourceFile file, String family, int size, ColorRGB color)
      Loads a TrueType or FreeType font so the renderer can use that font for text rendering. This will return a font for the specified style, alternative styles can be derived from the returned font.
      Throws:
      MediaException - if the format is not supported by the renderer.
    • loadDefaultFont

      default FontFace loadDefaultFont(int size, ColorRGB color)
      Loads the default font, the open source font Open Sans. This is included in MultimediaLib and therefore guaranteed to be always available.
    • loadModel

      Mesh loadModel(nl.colorize.util.ResourceFile file)
      Loads a polygon model from the specified file. Only the OBJ and GLTF format are guaranteed to be supported, though certain renderers may support additional file formats.
      Throws:
      MediaException - if the format is not supported by this renderer.
      UnsupportedOperationException - if this renderer does not support 3D graphics.
    • loadText

      String loadText(nl.colorize.util.ResourceFile file)
      Loads a text-based resource file using UTF-8 encoding.
      Throws:
      MediaException - if the file does not exist.
    • loadTextLines

      default List<String> loadTextLines(nl.colorize.util.ResourceFile file)
      Loads a text-based resource file using UTF-8 encoding, and returns it as a list of lines.
      Throws:
      MediaException - if the file does not exist.
    • loadProperties

      default Properties loadProperties(nl.colorize.util.ResourceFile file)
      Convenience method that loads and then parses the contents of a .properties file. By default, reading the file contents is delegated to loadText(ResourceFile).
    • loadTranslationBundle

      default nl.colorize.util.TranslationBundle loadTranslationBundle(nl.colorize.util.ResourceFile file)
      Convenience method that loads and then parses the contents of a .properties file and returns a TranslationBundle. By default, reading the file contents is delegated to loadText(ResourceFile).
    • containsResourceFile

      boolean containsResourceFile(nl.colorize.util.ResourceFile file)
      Returns whether the specified resource file is available.
    • loadApplicationData

      Properties loadApplicationData(String appName)
      Loads the application data for the application with the specified name. Application data is limited to key/value properties, as this type of data is supported by all platforms. Returns an empty Properties when no application data exists.
    • saveApplicationData

      void saveApplicationData(String appName, Properties data)
      Saves the application data for the application with the specified name. Application data is limited to key/value properties, as this type of data is supported by all platforms.
    • getLoadStatus

      nl.colorize.util.SubscribableCollection<LoadStatus> getLoadStatus()
      Returns a buffer containing the load status of all media files that have been loaded by this MediaLoader.