Interface MediaLoader

All Known Implementing Classes:
GDXMediaLoader, HeadlessMediaLoader, JFXMediaLoader, StandardMediaLoader, TeaMediaLoader

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 Details

    • loadImage

      Image loadImage(FilePointer 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(FilePointer 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(FilePointer 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(FilePointer file, String family, FontStyle style)
      Loads a TrueType or FreeType font and converts it to a format that can be used by the renderer. The loaded font will be attached to the font family name specified in the font style.
      Throws:
      MediaException - if the format is not supported by the renderer.
    • loadDefaultFont

      default FontFace loadDefaultFont(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

      PolygonModel loadModel(FilePointer file)
      Loads a polygon model from the specified file. Only the GLTF format is guaranteed to be supported, other file formats are only supported by specific renderers.
      Throws:
      MediaException - if the format is not supported by the renderer.
      UnsupportedGraphicsModeException - if the renderer does not support 3D graphics.
    • getGeometryBuilder

      GeometryBuilder getGeometryBuilder()
      Provides access to a GeometryBuilder instance that can be used to create simple 3D geometry in a programmatic way.
      Throws:
      UnsupportedGraphicsModeException - if the renderer does not support 3D graphics.
    • loadText

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

      default List<String> loadTextLines(FilePointer 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(FilePointer file)
      Convenience method that loads and then parses the contents of a .properties file. By default, reading the file contents is delegated to loadText(FilePointer).
    • loadTranslationBundle

      default nl.colorize.util.TranslationBundle loadTranslationBundle(FilePointer 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(FilePointer).
    • containsResourceFile

      boolean containsResourceFile(FilePointer 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.