IAudioPlayer Interface

Audio playback and volume control.

public interface IAudioPlayer : System.IDisposable

Derived
AudioService
HeadlessAudioService
IAudioService

Implements System.IDisposable

Properties
ActiveSoundTrackCount Gets the number of currently active sound-effect tracks (excludes music).
IsMusicFadingOut Gets whether music is currently fading out to silence via StopMusic(float). Returns false during a crossfade to another track.
IsMusicPaused Gets whether music is currently paused.
IsMusicPlaying Gets whether music is currently playing.
MasterVolume Gets or sets the master volume (0.0 to 1.0).
MaxSoundTracks Gets the maximum number of concurrent sound-effect tracks.
MusicDurationMs Gets the total duration of the currently loaded music in milliseconds, or -1 if no music is playing or the duration is unknown (e.g. streaming sources).
MusicPositionMs Gets the current music playback position in milliseconds, or -1 if no music is playing. Paused tracks report the position at which they were paused.
MusicVolume Gets or sets the music volume (0.0 to 1.0).
SoundVolume Gets or sets the sound effects volume (0.0 to 1.0).
Methods
CrossfadeMusic(IMusic, float, int, long, string) Crossfades from the currently playing music to music over duration seconds. If no music is playing or duration is \<= 0, behaves identically to PlayMusic(IMusic, int, long, string). Call Update(float) each frame to advance the fade.
GetBusVolume(string) Gets the current volume multiplier for the given bus, or 1.0 if the bus volume has not been explicitly set via SetBusVolume(string, float).
IsBusPaused(string) Returns whether the given bus is currently paused via PauseBus(string).
PauseAllSounds() Pauses all currently playing sound-effect tracks. Music is not affected. Paused tracks remain alive and can be resumed with ResumeAllSounds().
PauseBus(string) Pauses all tracks tagged with bus. Paused tracks remain alive and can be resumed with ResumeBus(string).
PauseMusic() Pauses the currently playing music.
PlayMusic(IMusic, int, long, string) Plays background music.
PlaySound(ISoundEffect, float, int, float, float, int, string) Plays a sound effect and returns the track handle for lifecycle tracking.
ResumeAllSounds() Resumes all paused sound-effect tracks. Music is not affected.
ResumeBus(string) Resumes all tracks tagged with bus.
ResumeMusic() Resumes paused music.
SeekMusic(double) Seeks the currently playing music to positionMs milliseconds. Does nothing if no music is playing.
SetBusVolume(string, float) Sets the volume multiplier for all tracks tagged with bus. This is an additional multiplier on top of per-track gain and SoundVolume/MusicVolume.
SetMusicPitch(float) Sets the playback speed (pitch) of the current music track. Does nothing if no music is playing.
SetMusicTrackVolume(float) Sets the per-track volume multiplier for the current music track. The final music gain is MusicVolume × volume. Does nothing during a crossfade (the crossfade drives gains directly).
StopAllSounds() Stops all currently playing sound-effect tracks. Music is not affected.
StopBus(string, float) Stops all tracks tagged with bus with optional fade-out.
StopMusic(float) Stops the currently playing music. When fadeDuration is greater than zero the music fades out over that many seconds; call Update(float) each frame to advance the fade.
Update(float) Per-frame update that processes deferred track cleanup and advances any in-progress music crossfade. Call once per frame with the frame delta time.