Class SoundPlayer
Assembly: PopcorningGuineaPig.Engine.dll
Syntax
public class SoundPlayer : ISoundPlayer, IDisposable
Constructors
|
Edit this page
View Source
SoundPlayer(float)
Declaration
public SoundPlayer(float volume = 100)
Parameters
| Type |
Name |
Description |
| float |
volume |
|
|
Edit this page
View Source
SoundPlayer(string, float)
Declaration
public SoundPlayer(string playlist, float volume = 100)
Parameters
Fields
|
Edit this page
View Source
currentlyPlayingMusic
Declaration
protected FileSource? currentlyPlayingMusic
Field Value
| Type |
Description |
| FileSource |
|
|
Edit this page
View Source
embeddedResourceAssembly
Declaration
protected Assembly? embeddedResourceAssembly
Field Value
|
Edit this page
View Source
gameMusic
Declaration
protected List<string> gameMusic
Field Value
|
Edit this page
View Source
gameMusicCancellationTokenSource
Declaration
protected CancellationTokenSource? gameMusicCancellationTokenSource
Field Value
|
Edit this page
View Source
musicTracks
Declaration
protected Dictionary<string, FileSource> musicTracks
Field Value
|
Edit this page
View Source
playlist
Declaration
protected string playlist
Field Value
|
Edit this page
View Source
sfxGain
Declaration
Field Value
|
Edit this page
View Source
soundEffects
Declaration
protected Dictionary<string, IAudioSource> soundEffects
Field Value
|
Edit this page
View Source
volume
Declaration
Field Value
Methods
|
Edit this page
View Source
ApplyMix(float, float, float)
Master × music / master × sfx, each 0..1. Updates the playing music
stream immediately. One-shots pick up the sfx gain on the next PlaySound.
Declaration
public virtual void ApplyMix(float master, float sound, float music)
Parameters
|
Edit this page
View Source
ClearEmbeddedResourceAssembly()
Clears the embedded resource assembly so audio paths resolve via VFS/file system again.
Declaration
public void ClearEmbeddedResourceAssembly()
|
Edit this page
View Source
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
|
Edit this page
View Source
GetSoundSource(string)
Gets the source for a loaded sound effect, or null if not loaded.
Useful for controlling volume on a playing sound (e.g., fade-out).
Declaration
public IAudioSource? GetSoundSource(string soundPath)
Parameters
| Type |
Name |
Description |
| string |
soundPath |
|
Returns
| Type |
Description |
| IAudioSource |
|
|
Edit this page
View Source
LoadMusicIfNeeded(string)
Declaration
protected void LoadMusicIfNeeded(string musicPath)
Parameters
| Type |
Name |
Description |
| string |
musicPath |
|
|
Edit this page
View Source
LoadPlaylists()
Declaration
protected virtual void LoadPlaylists()
|
Edit this page
View Source
LoadSoundIfNeeded(string)
Declaration
protected void LoadSoundIfNeeded(string soundPath)
Parameters
| Type |
Name |
Description |
| string |
soundPath |
|
|
Edit this page
View Source
PlayGameBackgroundMusic(CancellationToken)
Declaration
protected Task PlayGameBackgroundMusic(CancellationToken cancellationToken)
Parameters
Returns
|
Edit this page
View Source
PlayMusic(string)
Plays a music track and tracks it as current.
Declaration
protected void PlayMusic(string musicPath)
Parameters
| Type |
Name |
Description |
| string |
musicPath |
|
|
Edit this page
View Source
PlaySound(string, float)
Declaration
public Task PlaySound(string soundPath, float volume = 1)
Parameters
Returns
|
Edit this page
View Source
ReleaseSound(string)
Take one sound effect out of the mixer. The decoded clip stays cached, so the
next play does not decode it again. Scenes call this when a looping bed ends.
Declaration
public void ReleaseSound(string soundPath)
Parameters
| Type |
Name |
Description |
| string |
soundPath |
|
|
Edit this page
View Source
ResolveAudioPath(string)
Resolves an audio path. If embedded resource assembly is set, extracts the resource to a temp file.
Otherwise, returns the path as-is for file-based loading.
Declaration
protected string ResolveAudioPath(string audioPath)
Parameters
| Type |
Name |
Description |
| string |
audioPath |
|
Returns
|
Edit this page
View Source
SetEmbeddedResourceAssembly(Assembly)
Sets the assembly to use for loading embedded audio resources.
When set, sound/music paths will be treated as embedded resource names and extracted to temp files.
Declaration
public void SetEmbeddedResourceAssembly(Assembly assembly)
Parameters
| Type |
Name |
Description |
| Assembly |
assembly |
The assembly containing embedded audio resources
|
|
Edit this page
View Source
StartGameBackgroundMusic()
Declaration
public Task StartGameBackgroundMusic()
Returns
|
Edit this page
View Source
StopCurrentMusic()
Stops the currently playing music.
Declaration
protected void StopCurrentMusic()
|
Edit this page
View Source
StopGameBackgroundMusic()
Declaration
public Task StopGameBackgroundMusic()
Returns
|
Edit this page
View Source
Update()
OwnAudioSharp manages its own audio thread — no frame-coupled updates needed.
Method retained for ISoundPlayer interface compatibility.
Declaration
public virtual void Update()
|
Edit this page
View Source
UpdateSettings(string, float)
Declaration
public Task UpdateSettings(string playlist, float volume = 100)
Parameters
Returns
Implements