Audio Support
HollowCore allows you to use not only '.ogg' audio, but also '.mp3' and '.wav'. In addition, there is no need to register sounds.
Read audio files
- ogg
- mp3
- wav
val audio = OggFormat.read(stream) // stream - everything is like in Java: InputStream, data input stream.
val audio = Mp3Format.read(stream) // stream - everything is like in Java: InputStream, data input stream.
val audio = WavFormat.read(stream) // stream - everything is like in Java: InputStream, data input stream.
Sound playback
Creating a Player
- ogg
- mp3
- wav
val audio = OggFormat.read(stream) // stream - everything is like in Java: InputStream, data input stream.
val buffer = AudioBuffer(audio) // Create a buffer for your sound
val player = AudioPlayer(buffer) // Create a sound player
val audio = Mp3Format.read(stream) // stream - everything is like in Java: InputStream, data input stream.
val buffer = AudioBuffer(audio) // Create a buffer for your sound
val player = AudioPlayer(buffer) // Create a sound player
val audio = WavFormat.read(stream) // stream - everything is like in Java: InputStream, data input stream.
val buffer = AudioBuffer(audio) // Create a buffer for your sound
val player = AudioPlayer(buffer) // Create a sound player
Features for the player
Launch: 'player.play()'
Pause: 'player.pause()'
Stop: 'player.stop()'
Volume: 'player.setVolume(volume: Float)'
Pitch: 'player.setPitch(pitch: Float)'
Loop Audio: 'player.setLooping(loop: Boolean)'
Coordinates: 'player.setPosition(x: Float, y: Float, z: Float)'
Sound relative to player: 'player.setRelative(relative: Boolean)' - If 'true', the coordinates will be used not relative to the world, but relative to the player.
Variables for the player
'player.isPlaying' - Whether this sound is currently playing.
'player.isPaused' - Is this sound paused.
'player.isStopped' - Is this sound stopped now.
'player.playbackPosition' - "Current second of sound".