media info to play
Releases any player resources (input streams, ...).
Releases any player resources (input streams, ...). Playback is stopped.
the current player state and any future states
media info to play
media info to play
Mutes/unmutes the player.
Mutes/unmutes the player.
Starts or resumes playback, whichever makes sense.
Starts or resumes playback, whichever makes sense.
Returns a stream of the media reset to its initial read position.
Returns a stream of the media reset to its initial read position. Helper method for seeking.
The default implementation merely calls reset()
on the InputStream and returns the same instance. If
possible, override this method, close and open a new stream instead.
a stream of the media reset to its initial read position
Regardless of whether the user seeks backwards or forwards, here is what we do:
Regardless of whether the user seeks backwards or forwards, here is what we do:
Reset the stream to its initial position. Skip bytes from the beginning. (Optionally continue playback.)
The stream needs to support mark so that we can mark the initial position (constructor). Subsequent calls to reset will therefore go to the initial position. Then we can skip the sufficient amount of bytes and arrive at the correct position. Otherwise seeking would just skip bytes forward every time, relative to the current position.
This can still be spectacularly inaccurate if a VBR file is seeked but that is a secondary problem.
position to seek to
Pauses playback.
Pauses playback.
Inaccurate.
Inaccurate. VBR etc.
A stream of time update events.
A stream of time update events. Emits the current playback position, then emits at least one event per second provided that the playback position changes. If there is no progress, for example if playback is stopped, no events are emitted.
time update events
Adjusts the volume.
Adjusts the volume.
A music player. Plays one media source. To change source, for example to change track, create a new player.
The user needs to provide the media length and size to enable seek functionality. Seeking streams which cannot be reopened is only supported if InputStream.markSupported() of
media.stream
is true, and even then the support is buggy. markSupported() is true at least for java.io.BufferedInputStreams.The stream provided in
media
is not by default closed when the player is closed, but if you wish to do so, subclass this player and overrideclose()
accordingly or mix in trait SourceClosing.UriJavaSoundPlayer
FileJavaSoundPlayer