Interface MediaLoader
-
- All Known Implementing Classes:
GDXMediaLoader,MediaCache,StandardMediaLoader,TeaMediaLoader
public interface MediaLoaderLoads 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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description booleancontainsResourceFile(FilePointer file)Returns whether the specified resource file is available.AudioloadAudio(FilePointer file)Loads an audio clip from a file.default TTFontloadDefaultFont(int size, ColorRGB color)Loads the default font, the open source font Open Sans.default TTFontloadFont(FilePointer file, java.lang.String family, int size, ColorRGB color)Loads a TrueType font from a.ttffile and converts it to a format that can be used by the renderer.TTFontloadFont(FilePointer file, java.lang.String family, int size, ColorRGB color, boolean bold)Loads a TrueType font from a.ttffile and converts it to a format that can be used by the renderer.ImageloadImage(FilePointer file)Loads an image from a file.PolygonMeshloadMesh(FilePointer file)Loads a polygon mesh from the specified file.default SpriteSheetloadSpriteSheetCSV(FilePointer imageFile, FilePointer metadataFile)Convenience method that loads a sprite sheet from its image and its metadata file in CSV format.java.lang.StringloadText(FilePointer file)Loads a text-based resource file using UTF-8 encoding.default java.util.List<java.lang.String>loadTextLines(FilePointer file)Loads a text-based resource file using UTF-8 encoding, and returns it as a list of lines.
-
-
-
Method Detail
-
loadImage
Image loadImage(FilePointer file)
Loads an image from a file. JPEG and PNG images are guaranteed to be supported, though other image formats may also be supported depending on the platform.- Throws:
MediaException- if the image format is not supported by the renderer or by the platform, or if the file does not exist.
-
loadSpriteSheetCSV
default SpriteSheet loadSpriteSheetCSV(FilePointer imageFile, FilePointer metadataFile)
Convenience method that loads a sprite sheet from its image and its metadata file in CSV format. The sprite sheet is assumed to have been created using theSpriteSheetPackerTool.Note that no convenience method for loading sprite sheets with YAML metadata is provided, as this library does not include out-of-the-box support for YAML.
- Throws:
MediaException- if the sprite sheet cannot be loaded.java.lang.IllegalArgumentException- when attempting to load non-CSV metadata.
-
loadAudio
Audio loadAudio(FilePointer file)
Loads an audio clip from a file. OGG and MP3 files are guaranteed to be supported, though other audio formats may be also be supported depending on the platform.- Throws:
MediaException- if the audio format is not supported by the renderer or by the platform, or if the file does not exist.
-
loadFont
TTFont loadFont(FilePointer file, java.lang.String family, int size, ColorRGB color, boolean bold)
Loads a TrueType font from a.ttffile and converts it to a format that can be used by the renderer.- Throws:
MediaException- if the file does not exist, or if the font cannot be loaded on the current platform.
-
loadFont
default TTFont loadFont(FilePointer file, java.lang.String family, int size, ColorRGB color)
Loads a TrueType font from a.ttffile and converts it to a format that can be used by the renderer.- Throws:
MediaException- if the file does not exist, or if the font cannot be loaded on the current platform.
-
loadDefaultFont
default TTFont 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.
-
loadMesh
PolygonMesh loadMesh(FilePointer file)
Loads a polygon mesh from the specified file. Only the FBX file format is supported by all renderer implementations.- Throws:
MediaException- if the mesh cannot be loaded.
-
loadText
java.lang.String loadText(FilePointer file)
Loads a text-based resource file using UTF-8 encoding.- Throws:
MediaException- if the file does not exist.
-
loadTextLines
default java.util.List<java.lang.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.
-
containsResourceFile
boolean containsResourceFile(FilePointer file)
Returns whether the specified resource file is available.
-
-