Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

Player

Struct Player 

Source
pub struct Player { /* private fields */ }
Expand description

Plays XA-ADPCM songs. Owns the CD token: nothing else drives the controller while a player exists.

Implementations§

Source§

impl Player

Source

pub const fn new(cd: Cd) -> Self

A player with nothing playing. The SPU’s CD input must be on and have a volume (psx_spu::enable_cd_audio, psx_spu::set_cd_volume), and the drive’s own mixer must pass audio (set_volume).

Source

pub fn release(self) -> Cd

Stop and give the token back.

Source

pub fn play(&mut self, song: Song, looping: bool) -> Result<(), Error>

Start song from the top (or restart it). With looping it restarts by itself when poll sees it end. Blocks for the five drive commands, a few milliseconds on a warm drive.

Source

pub fn stop(&mut self)

Pause the drive and forget the song. Waits for the drive to settle.

Source

pub fn poll(&mut self) -> Event

Call about once per frame: notices the end of the song and loops or stops. Costs one drive command.

Source

pub fn is_playing(&self) -> bool

Whether a song is started and has not finished.

Source

pub fn is_streaming(&self) -> bool

Whether the head has been seen inside the song file since the last start, so the audio is flowing and not still seeking.

Source

pub fn song(&self) -> Option<Song>

The song being played.

Source

pub fn elapsed_millis(&self) -> u32

Time since the start of the song file at the last poll, in milliseconds (the head runs a sector or two ahead of the sound).

Source

pub fn set_volume(&mut self, left: u8, right: u8)

Set the level of the drive’s audio output (CD-DA too). 0x80 is unity, 0xFF about twice that; (left, right) feed the left and right outputs of a stereo song.

Auto Trait Implementations§

§

impl Freeze for Player

§

impl RefUnwindSafe for Player

§

impl Send for Player

§

impl Sync for Player

§

impl Unpin for Player

§

impl UnsafeUnpin for Player

§

impl UnwindSafe for Player

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.