Struct sfml::audio::SoundStreamPlayer[][src]

pub struct SoundStreamPlayer<'a, S: SoundStream + 'a> { /* fields omitted */ }

Player for custom streamed audio sources. See SoundStream.

Implementations

impl<'a, S: SoundStream> SoundStreamPlayer<'a, S>[src]

pub fn new(sound_stream: &'a mut S) -> Self[src]

Create a new SoundStreamPlayer with the specified SoundStream.

pub fn play(&mut self)[src]

Start or resume playing the audio stream.

pub 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.

#[must_use]pub fn status(&self) -> SoundStatus[src]

Get the current status of the stream (stopped, paused, playing)

pub 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();

#[must_use]pub fn playing_offset(&self) -> Time[src]

Get the current playing position, from the beginning of the stream

pub 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.

#[must_use]pub fn channel_count(&self) -> u32[src]

Return the number of channels of the stream.

1 channel means a mono sound, 2 means stereo, etc.

#[must_use]pub 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.

#[must_use]pub fn is_looping(&self) -> bool[src]

Tell whether or not the stream is in loop mode.

pub 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 set_looping(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> Drop for SoundStreamPlayer<'a, S>[src]

impl<'a, S: SoundStream> SoundSource for SoundStreamPlayer<'a, S>[src]

Auto Trait Implementations

impl<'a, S> RefUnwindSafe for SoundStreamPlayer<'a, S> where
    S: RefUnwindSafe

impl<'a, S> !Send for SoundStreamPlayer<'a, S>

impl<'a, S> !Sync for SoundStreamPlayer<'a, S>

impl<'a, S> Unpin for SoundStreamPlayer<'a, S>

impl<'a, S> !UnwindSafe for SoundStreamPlayer<'a, S>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.