Struct sfml::audio::SoundStreamPlayer
[−]
[src]
pub struct SoundStreamPlayer<'a, S: SoundStream + 'a> { /* fields omitted */ }
Player for custom streamed audio sources. See SoundStream.
Methods
impl<'a, S: SoundStream> SoundStreamPlayer<'a, S>[src]
fn new(sound_stream: &'a mut S) -> Self[src]
Create a new SoundStreamPlayer with the specified SoundStream.
fn play(&mut self)[src]
Start or resume playing the audio stream.
fn pause(&mut self)[src]
Pause the audio stream.
This function pauses the stream if it was playing, otherwise (stream already paused or stopped) it has no effect.
fn status(&self) -> SoundStatus[src]
Get the current status of the stream (stopped, paused, playing)
fn stop(&mut self) -> &mut S[src]
Stop playing, lending out the underlying SoundStream.
This function stops the stream if it was playing or paused, and does nothing if it was already stopped. It also resets the playing position (unlike pause()).
It lends out the underlying SoundStream, allowing it to be manipulated.
Example
let mut music_stream = MusicStream::load("cool_song.ogg"); let mut player = SoundStreamPlayer::new(&mut music_stream); player.play(); // ... // Let's say we want to change the song being played. // We can't just simply reassign `music_stream`, since it's being borrowed by `player`. // Manipulating the stream while it's being played is _unsafe_, so it's not allowed. // // Instead, let's stop the player first, reassign the stream, then restart the player. { let stream = player.stop(); *stream = MusicStream::load("another_cool_song.ogg"); } player.play();
fn playing_offset(&self) -> Time[src]
Get the current playing position, from the beginning of the stream
fn set_playing_offset(&mut self, offset: Time)[src]
Change the current playing position of the stream.
The playing position can be changed when the stream is either paused or playing. Changing the playing position when the stream is stopped has no effect, since playing the stream would reset its position.
fn channel_count(&self) -> u32[src]
Return the number of channels of the stream.
1 channel means a mono sound, 2 means stereo, etc.
fn sample_rate(&self) -> u32[src]
Get the stream sample rate of the stream.
The sample rate is the number of audio samples played per second. The higher, the better the quality.
fn is_looping(&self) -> bool[src]
Tell whether or not the stream is in loop mode.
fn set_looping(&mut self, looping: bool)[src]
Set whether or not the stream should loop after reaching the end.
If set, the stream will restart from beginning after reaching the end and so on, until it is stopped or setLoop(false) is called. The default looping state for streams is false.
Trait Implementations
impl<'a, S: Debug + SoundStream + 'a> Debug for SoundStreamPlayer<'a, S>[src]
impl<'a, S: SoundStream> SoundSource for SoundStreamPlayer<'a, S>[src]
fn set_pitch(&mut self, pitch: f32)[src]
Set the pitch of the sound. Read more
fn set_volume(&mut self, volume: f32)[src]
Set the volume of the sound. Read more
fn set_position<P: Into<Vector3f>>(&mut self, position: P)[src]
Set the 3D position of the sound in the audio scene. Read more
fn set_relative_to_listener(&mut self, relative: bool)[src]
Make the sound's position relative to the listener or absolute. Read more
fn set_min_distance(&mut self, distance: f32)[src]
Set the minimum distance of the sound. Read more
fn set_attenuation(&mut self, attenuation: f32)[src]
Set the attenuation factor of the sound. Read more
fn pitch(&self) -> f32[src]
Get the pitch of the sound.
fn volume(&self) -> f32[src]
Get the volume of the sound. Read more
fn position(&self) -> Vector3f[src]
Get the 3D position of the sound in the audio scene.
fn is_relative_to_listener(&self) -> bool[src]
Tell whether the sound's position is relative to the listener or is absolute.
fn min_distance(&self) -> f32[src]
Get the minimum distance of the sound.
fn attenuation(&self) -> f32[src]
Get the attenuation factor of the sound.