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
impl Player
Sourcepub const fn new(cd: Cd) -> Self
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).
Sourcepub fn play(&mut self, song: Song, looping: bool) -> Result<(), Error>
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.
Sourcepub fn poll(&mut self) -> Event
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.
Sourcepub fn is_playing(&self) -> bool
pub fn is_playing(&self) -> bool
Whether a song is started and has not finished.
Sourcepub fn is_streaming(&self) -> bool
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.
Sourcepub fn elapsed_millis(&self) -> u32
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).
Sourcepub fn set_volume(&mut self, left: u8, right: u8)
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.