Skip to content

Commit

Permalink
🚸 Split audio source validation (#238)
Browse files Browse the repository at this point in the history
Closes #216
  • Loading branch information
blueuwu authored Aug 25, 2023
1 parent fbb3991 commit 0869db3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/layer/audio-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,12 @@ function AudioSourceMixin<OptionsSuperclass extends BaseOptions> (superclass: Co
applyOptions(options, this)

const load = () => {
// TODO: && ?
if ((options.duration || (this.source.duration - this.sourceStartTime)) < 0) {
throw new Error('Invalid options.duration or options.sourceStartTime')
if (options.duration < 0) {
throw new Error('Invalid options.duration. It must be a non-negative value.')
}

if (this.sourceStartTime > this.source.duration) {
throw new Error('options.sourceStartTime cannot exceed options.source.duration')
}

this._unstretchedDuration = options.duration || (this.source.duration - this.sourceStartTime)
Expand Down

0 comments on commit 0869db3

Please sign in to comment.