public class Music extends SoundStream
openFromFile(java.nio.file.Path)
or
openFromStream(java.io.InputStream)
methods.
The supported audio file formats are:
ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, w64, mat4,
mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64
SoundStream.Chunk
SoundSource.Status
Constructor and Description |
---|
Music()
Constructs a music.
|
Modifier and Type | Method and Description |
---|---|
Time |
getDuration()
Gets the total duration of the music.
|
protected void |
initialize(int channelCount,
int sampleRate)
Defines the audio stream parameters.
|
protected long |
nativeCreate()
Deprecated.
|
protected void |
nativeDelete()
Deprecated.
|
protected void |
nativeSetExPtr()
Deprecated.
|
protected SoundStream.Chunk |
onGetData()
Requests a new chunk of audio data.
|
protected void |
onSeek(Time time)
Re-positions the stream's current playing offset.
|
void |
openFromFile(Path path)
Attempts to open the music from a file.
|
void |
openFromStream(InputStream in)
Attempts to open the music from an
InputStream . |
getChannelCount, getPlayingOffset, getSampleRate, getStatus, isLoop, pause, play, setLoop, setPlayingOffset, stop
getAttenuation, getMinDistance, getPitch, getPosition, getVolume, isRelativeToListener, setAttenuation, setMinDistance, setPitch, setPosition, setPosition, setRelativeToListener, setVolume
finalize
@Deprecated protected long nativeCreate()
SFMLNativeObject
nativeCreate
in class SoundStream
@Deprecated protected void nativeSetExPtr()
SFMLNativeObject
nativeSetExPtr
in class SoundStream
@Deprecated protected void nativeDelete()
SFMLNativeObject
nativeDelete
in class SoundStream
public void openFromStream(InputStream in) throws IOException
InputStream
.in
- the input stream to stream from.IOException
- in case an I/O error occurs.public void openFromFile(Path path) throws IOException
path
- the file to stream from.IOException
- in case an I/O error occurs.public Time getDuration()
protected final void initialize(int channelCount, int sampleRate)
SoundStream
initialize
in class SoundStream
channelCount
- the amount of audio channels (e.g. 1 for mono, 2 for stereo).sampleRate
- the sample rate in samples per second.protected final SoundStream.Chunk onGetData()
SoundStream
onGetData
in class SoundStream
SoundStream.isLoop()
returns true
.
To stop playback immediately, null
may be returned.SoundStream.Chunk
protected final void onSeek(Time time)
SoundStream
SoundStream.setPlayingOffset(org.jsfml.system.Time)
.
Note that this method will be called within a separate playback thread.onSeek
in class SoundStream
time
- the time offset to jump to.