Skip to content

Commit

Permalink
Iss84 SHOW - Allow infinite looping of sequences
Browse files Browse the repository at this point in the history
* Add checkbox to allow for infinite looping of shows
* Add functionality to infinite loop sequences
* Fix element length bug in case sequence does not have audio file.
  • Loading branch information
Byron Ambright committed Apr 24, 2019
1 parent 0ccf913 commit 679b9f9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 16 deletions.
2 changes: 2 additions & 0 deletions app/html/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<button id='addElement'>Add element</button>
<br><br>
<button id='runShow' value='notPlaying'>Play</button>
<span>Repeat?</span>
<input type="checkbox" id="repeatPlay">

<br><br><br><br>
<button id='patchShow'>Patch Show</button>
Expand Down
47 changes: 32 additions & 15 deletions app/js/sendDMX.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,40 @@ function playElement(showElement) {
}
}

function getShowLengthTotal(total, elementLength) {
return total + elementLength;
}


async function playShow(elements) {
const i = 1;
playElement(elements[0]);
// recursively waits and plays elements of the show
function playShowInSequence(ind) {
let k = ind;
if (canPlay) {
setTimeout(() => {
if (canPlay) {
if (k < elements.length) {
playElement(elements[k]);
k += 1;
playShowInSequence(k);
const repeat = document.getElementById('repeatPlay');

function triggerShow() {
const i = 1;
playElement(elements[0]);
// recursively waits and plays elements of the show
function playShowInSequence(ind) {
let k = ind;
if (canPlay) {
setTimeout(() => {
if (canPlay) {
if (k < elements.length) {
playElement(elements[k]);
k += 1;
playShowInSequence(k);
}
}
}
}, elements[k - 1].getElementLength());
}, elements[k - 1].getElementLength());
}
}
playShowInSequence(i);
}
if (repeat.checked && canPlay) {
const elementsLength = elements.map(x => x.elementLength);
const showLength = elementsLength.reduce(getShowLengthTotal, 0);
setTimeout(() => {
playShow(elements);
}, showLength);
}
playShowInSequence(i);
triggerShow();
}
3 changes: 2 additions & 1 deletion app/js/showElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ ShowElement.prototype.setUpSequence = async function () {

// Didn't have an audio path
return new Promise((resolve, reject) => {
resolve(0);
// this is so the result is in milliseconds
resolve(sequenceJSON['Sequence Length'] / 1000);
});
};
ShowElement.prototype.getDuration = function (url) {
Expand Down

0 comments on commit 679b9f9

Please sign in to comment.