Package net.risingworld.api.assets
Klasse SoundAsset
java.lang.Object
net.risingworld.api.assets.Asset
net.risingworld.api.assets.SoundAsset
Represents a custom audio file (this could either be a sound effect or a music track).
Supported file formats: ogg, mp2, mp3, midi/mid, wav, flac
Example: Create a SoundAsset and play it for every player who joins the game
Supported file formats: ogg, mp2, mp3, midi/mid, wav, flac
-
Verschachtelte Klassen - Übersicht
Von Klasse geerbte verschachtelte Klassen/Schnittstellen net.risingworld.api.assets.Asset
Asset.Source, Asset.Type
-
Feldübersicht
Von Klasse geerbte Felder net.risingworld.api.assets.Asset
DEFAULT_EXTENSION
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungboolean
Determines if the sound is streamed or not.static SoundAsset
load
(byte[] data) static SoundAsset
loadFromAssetBundle
(AssetBundle bundle, String path) static SoundAsset
loadFromFile
(String file) Creates a new sound asset referencing a file on harddrive.static SoundAsset
loadFromFile
(String file, boolean streamed) Creates a new sound asset referencing a file on harddrive.static SoundAsset
loadFromPlugin
(Plugin plugin, String resource) Creates a new sound asset and loads the sound from the plugin jar file.static SoundAsset
loadFromURL
(String url) Loads a stream from an URL.Von Klasse geerbte Methoden net.risingworld.api.assets.Asset
dispose, equals, getChecksum, getDependency, getExtension, getHandle, getPath, getSource, getType, hashCode, isDisposed
-
Methodendetails
-
loadFromFile
Creates a new sound asset referencing a file on harddrive.- Parameter:
file
- the path to the sound file on the harddrive.- Gibt zurück:
- a new sound asset instance.
- Example: Load sound "explosion.ogg" from "assets" subfolder in plugin directory
-
loadFromFile
Creates a new sound asset referencing a file on harddrive. Optionally you can determine if the sound should be streamed or not. Usually the whole sound file is loaded into memory before playing it, but if streaming is enabled, the game reads the sound while playing. This reduces memory consumption, but increases cpu load. By default, streaming is disabled.
Important: It only makes sense to stream large sound files, e.g music etc.- Parameter:
file
- the path to the sound file on the harddrive.streamed
- true to enable streaming, false to disable it (default).- Gibt zurück:
- a new sound asset instance.
-
loadFromPlugin
Creates a new sound asset and loads the sound from the plugin jar file.- Parameter:
plugin
- a reference to the plugin. This is required to make sure the game loads the resource from the correct plugin jar.resource
- the path to the resource (inside the jar file).- Gibt zurück:
- a new sound asset instance.
- Example: Load sound "explosion.ogg" from jar file (in package rw.plugin.sounds)
-
loadFromAssetBundle
-
load
-
loadFromURL
Loads a stream from an URL. This could be a link to an online radio stream, for example.- Parameter:
url
- the URL to the stream.- Gibt zurück:
- a new sound asset instance.
-
isStreamed
public boolean isStreamed()Determines if the sound is streamed or not.- Gibt zurück:
- true if this sound will be streamed, false if not.
-