Class ThemeAudioPlayer
Single guarded entry point for theme UI-sound playback and clip-map construction.
A null play use case, an unset/empty service id, or a null/missing clip results in a silent
no-op instead of a crash, so themes with empty, partial, or duplicated sound slots never throw.
Inherited Members
Namespace: Serenity.AudioPlayer.Application.UseCases
Assembly: Serenity.AudioPlayer.Application.dll
Syntax
public static class ThemeAudioPlayer
Methods
BuildClipMap(params AudioPlayerClip[])
Builds a clip map keyed by GetId().
Uses indexer assignment, so a clip reused across several theme slots collapses to a single
entry instead of throwing ArgumentException the way Dictionary.Add would.
null clips and clips with an empty id are skipped.
Declaration
public static Dictionary<string, AudioPlayerClip> BuildClipMap(params AudioPlayerClip[] clips)
Parameters
| Type | Name | Description |
|---|---|---|
| AudioPlayerClip[] | clips | The clips to index. A |
Returns
| Type | Description |
|---|---|
| Dictionary<string, AudioPlayerClip> | A dedup-safe map from clip id to clip. |
TryPlay(AudioPlayerPlayClip, string, AudioPlayerClip)
Plays a clip if, and only if, every requirement is met; otherwise does nothing.
Declaration
public static bool TryPlay(AudioPlayerPlayClip play, string audioServiceId, AudioPlayerClip clip)
Parameters
| Type | Name | Description |
|---|---|---|
| AudioPlayerPlayClip | play | The play use case. A |
| string | audioServiceId | Audio service id. A |
| AudioPlayerClip | clip | The clip to play. A |
Returns
| Type | Description |
|---|---|
| bool |
|
TryPlay(AudioPlayerPlayClip, string, IReadOnlyDictionary<string, AudioPlayerClip>, string)
Plays the clip stored under sfxKey in clips, if present.
A missing key means that theme sound slot was left empty (all slots are optional): it is a
no-op, never a KeyNotFoundException.
Declaration
public static bool TryPlay(AudioPlayerPlayClip play, string audioServiceId, IReadOnlyDictionary<string, AudioPlayerClip> clips, string sfxKey)
Parameters
| Type | Name | Description |
|---|---|---|
| AudioPlayerPlayClip | play | The play use case. A |
| string | audioServiceId | Audio service id. A |
| IReadOnlyDictionary<string, AudioPlayerClip> | clips | The clip map. A |
| string | sfxKey | Key of the clip to play. A |
Returns
| Type | Description |
|---|---|
| bool |
|