diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e898dbdc..727900e65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -138,6 +138,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed +- Fixed issue where `ex.Sound.getTotalPlaybackDuration()` would crash if not loaded, now logs friendly warning - Fixed issue where an empty constructor on `new ex.Label()` would crash - Fixed issue where pointer events did not work properly when using [[ScreenElement]]s - Fixed issue where debug draw was not accurate when using *AndFill suffixed [[DisplayMode]]s diff --git a/src/engine/Resources/Sound/Sound.ts b/src/engine/Resources/Sound/Sound.ts index 8e23fdbe0..ec9ff00e1 100644 --- a/src/engine/Resources/Sound/Sound.ts +++ b/src/engine/Resources/Sound/Sound.ts @@ -309,6 +309,11 @@ export class Sound implements Audio, Loadable { } public getTotalPlaybackDuration() { + if (!this.isLoaded()) { + this.logger.warnOnce(`Sound from ${this.path} is not loaded, cannot return total playback duration.` + + `Did you forget to add Sound to a loader? https://excaliburjs.com/docs/loaders/`); + return 0; + } return this.data.duration; }