Skip to content

Commit

Permalink
Merge pull request #13 from mrf345/testing
Browse files Browse the repository at this point in the history
Fix repeat_each repeats forever and auto_start this. Bump to 0.0.19
  • Loading branch information
mrf345 committed Jun 10, 2020
2 parents 218993a + 3003982 commit 727e4fc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bin/AudioSequence.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "audio_sequence",
"version": "0.0.18",
"version": "0.0.19",
"description": "simple module to control, monitor and play multiple audio files in sequences at a time.",
"main": "lib/index.js",
"scripts": {
Expand Down
8 changes: 5 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default class AudioSequence {
this.getNext = p => this.keepWithin(p ? this.current - 1 : this.current + 1, this.playlist)
this.isMuted = () => this.hasFiles() && this.getCurrent().item.volume === 0
this.isPaused = () => this.hasFiles() && this.getCurrent().item.paused
this.isLast = () => (this.playlist.length - 1) === this.current
this.notStarted = () => !this.isPaused() && !this.isActive()
this.getPlace = ele => this.files
.map(f => f.replace(window.origin, ''))
Expand All @@ -69,7 +70,7 @@ export default class AudioSequence {
this.handleAutoPlayNotAllowed()

// auto start playing audio, or wait for DOM to load.
if (this.autoStart) this.waitForDOM(this.load)
if (this.autoStart) this.waitForDOM(this.load.bind(this))
}

handleEnding (event) {
Expand Down Expand Up @@ -100,15 +101,16 @@ export default class AudioSequence {
this.current = nextIndex
nextItem.repeats = 1
return zeroAndPlay(nextItem)
} else resolve(element)
} else return resolve(element)
}

if (this.repeatEach) {
const repeats = element.repeats || 1

if (repeats >= this.repeats && !this.repeatForever) {
element.repeats = 0
return commonNext()

return this.isLast() ? resolve(element) : commonNext()
} else {
element.repeats = repeats + 1
return zeroAndPlay(element)
Expand Down

0 comments on commit 727e4fc

Please sign in to comment.