{"record":{"id":"a74ae4ee513b46b6","repo":"EllanJiang/GameFramework","slug":"can-not-find-sound-0","errorCode":null,"errorMessage":"Can not find sound '{0}'.","messagePattern":"Can not find sound '(.+?)'\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"warning","filePath":"GameFramework/Sound/SoundManager.cs","lineNumber":584,"sourceCode":"            PauseSound(serialId, Constant.DefaultFadeOutSeconds);\n        }\n\n        /// <summary>\n        /// 暂停播放声音。\n        /// </summary>\n        /// <param name=\"serialId\">要暂停播放声音的序列编号。</param>\n        /// <param name=\"fadeOutSeconds\">声音淡出时间，以秒为单位。</param>\n        public void PauseSound(int serialId, float fadeOutSeconds)\n        {\n            foreach (KeyValuePair<string, SoundGroup> soundGroup in m_SoundGroups)\n            {\n                if (soundGroup.Value.PauseSound(serialId, fadeOutSeconds))\n                {\n                    return;\n                }\n            }\n\n            throw new GameFrameworkException(Utility.Text.Format(\"Can not find sound '{0}'.\", serialId));\n        }\n\n        /// <summary>\n        /// 恢复播放声音。\n        /// </summary>\n        /// <param name=\"serialId\">要恢复播放声音的序列编号。</param>\n        public void ResumeSound(int serialId)\n        {\n            ResumeSound(serialId, Constant.DefaultFadeInSeconds);\n        }\n\n        /// <summary>\n        /// 恢复播放声音。\n        /// </summary>\n        /// <param name=\"serialId\">要恢复播放声音的序列编号。</param>\n        /// <param name=\"fadeInSeconds\">声音淡入时间，以秒为单位。</param>\n        public void ResumeSound(int serialId, float fadeInSeconds)\n        {","sourceCodeStart":566,"sourceCodeEnd":602,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Sound/SoundManager.cs#L566-L602","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Track whether the sound is still playing (via PlaySound's return and stopped callbacks) before calling PauseSound.","Verify the serial ID passed is the exact positive int returned by PlaySound.","Wrap the call in try-catch and ignore it when the sound has already finished.","Do not reuse serial IDs from a previous scene/framework restart."],"exampleFix":"// before\nint id = SoundManager.PlaySound(\"BGM\", \"Music\", 0);\n// ... later, sound may have ended\nSoundManager.PauseSound(id);\n\n// after\nif (isSoundPlaying(id))\n{\n    SoundManager.PauseSound(id);\n}","handlingStrategy":"try-catch","validationCode":"if (activeSerialIds.Contains(serialId))\n{\n    soundManager.PauseSound(serialId);\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    soundManager.PauseSound(serialId);\n}\ncatch (GameFrameworkException)\n{\n    // sound already finished; safe to ignore\n}","preventionTips":["Track playing serial IDs and remove them on the PlaySoundSuccess/stop callbacks.","Never persist serial IDs across scene loads.","Hook PlaySound's userData callback to know when a sound ends."],"tags":["sound","gameframework","serial-id","stale-reference"],"backgroundTag":"record-not-found","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}