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)AudioloadAudio(FilePointer file)Loads an audio clip from a file.default BitmapFontloadBitmapFont(FilePointer imageFile, FilePointer fntFile)Loads a bitmap font from an image and the associated metadata in Angel Code.fntformat.default TTFontloadDefaultFont()Loads the default font, the open source font Open Sans.TTFontloadFont(java.lang.String fontFamily, FilePointer file)Loads a TrueType font from a.ttffile.ImageloadImage(FilePointer file)Loads an image from a 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(java.lang.String fontFamily, FilePointer file)
Loads a TrueType font from a.ttffile.- Parameters:
fontFamily- The logical name of the font family that is being loaded.- Throws:
MediaException- if the file does not exist, or if the font cannot be loaded on the current platform.
-
loadDefaultFont
default TTFont loadDefaultFont()
Loads the default font, the open source font Open Sans. This is included in MultimediaLib and therefore guaranteed to be always available.
-
loadBitmapFont
default BitmapFont loadBitmapFont(FilePointer imageFile, FilePointer fntFile)
Loads a bitmap font from an image and the associated metadata in Angel Code.fntformat.- Throws:
MediaException- if the font metadata cannot be parsed, or if one of the files cannot be read.
-
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)
-
-