EllanJiang/GameFramework · warning · GameFrameworkException

Can not find sound ' '.

Error message

Can not find sound '{0}'.

What it means

PauseSound iterates every sound group asking each to pause the sound with the given serial ID; if no group reports owning that serial ID, the sound either already finished, was never started, or was played with an invalid serial ID, and this GameFrameworkException is thrown.

Solutions

  1. Track whether the sound is still playing (via PlaySound's return and stopped callbacks) before calling PauseSound.
  2. Verify the serial ID passed is the exact positive int returned by PlaySound.
  3. Wrap the call in try-catch and ignore it when the sound has already finished.
  4. Do not reuse serial IDs from a previous scene/framework restart.

Example fix

// before
int id = SoundManager.PlaySound("BGM", "Music", 0);
// ... later, sound may have ended
SoundManager.PauseSound(id);

// after
if (isSoundPlaying(id))
{
    SoundManager.PauseSound(id);
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (activeSerialIds.Contains(serialId))
{
    soundManager.PauseSound(serialId);
}

Try / catch

try
{
    soundManager.PauseSound(serialId);
}
catch (GameFrameworkException)
{
    // sound already finished; safe to ignore
}

Prevention

When it happens

Trigger: Calling PauseSound(serialId) with a serial ID that has completed playback, an ID from a previous SoundManager instance, an ID typed manually, or an ID whose sound agent was recycled by the group.

Common situations: Storing serial IDs across scene reloads (SoundManager resets); pausing a looped sound that already stopped; racing the sound's natural end after a delay before PauseSound.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15). Data as JSON: /api/errors/a74ae4ee513b46b6. Report an issue: GitHub.

Appendix: source

Thrown at GameFramework/Sound/SoundManager.cs:584

            PauseSound(serialId, Constant.DefaultFadeOutSeconds);
        }

        /// <summary>
        /// 暂停播放声音。
        /// </summary>
        /// <param name="serialId">要暂停播放声音的序列编号。</param>
        /// <param name="fadeOutSeconds">声音淡出时间,以秒为单位。</param>
        public void PauseSound(int serialId, float fadeOutSeconds)
        {
            foreach (KeyValuePair<string, SoundGroup> soundGroup in m_SoundGroups)
            {
                if (soundGroup.Value.PauseSound(serialId, fadeOutSeconds))
                {
                    return;
                }
            }

            throw new GameFrameworkException(Utility.Text.Format("Can not find sound '{0}'.", serialId));
        }

        /// <summary>
        /// 恢复播放声音。
        /// </summary>
        /// <param name="serialId">要恢复播放声音的序列编号。</param>
        public void ResumeSound(int serialId)
        {
            ResumeSound(serialId, Constant.DefaultFadeInSeconds);
        }

        /// <summary>
        /// 恢复播放声音。
        /// </summary>
        /// <param name="serialId">要恢复播放声音的序列编号。</param>
        /// <param name="fadeInSeconds">声音淡入时间,以秒为单位。</param>
        public void ResumeSound(int serialId, float fadeInSeconds)
        {

View on GitHub (pinned to d0c010b051)