Skip to content

Commit

Permalink
Now possible to make loop in select mode naomiaro#15
Browse files Browse the repository at this point in the history
  • Loading branch information
Willena committed Oct 2, 2016
1 parent 21e447e commit be778b2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
26 changes: 23 additions & 3 deletions src/Playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default class {
this.fadeType = "logarithmic";
this.masterGain = 1;
this.speed = 1;
this.loopNumber = 0;
}

initRecorder(stream) {
Expand Down Expand Up @@ -133,6 +134,10 @@ export default class {
this.setSpeed(speed);
});

ee.on('loopnumber', (number) => {
this.setLoop(number);
});

ee.on('select', (start, end, track) => {
if (this.isPlaying()) {
this.lastSeeked = start;
Expand Down Expand Up @@ -478,6 +483,11 @@ export default class {
});
}

setLoop(number) {
this.loopNumber = number
}


setSpeed(speed) {
this.speed = (speed >= 0.5 && speed <= 4) ? speed : 1;
if (this.isPlaying())
Expand Down Expand Up @@ -720,9 +730,19 @@ export default class {
);
}
else {
if ((cursorPos + elapsed) >=
(this.isSegmentSelection()) ? selection.end : this.duration) {
this.ee.emit('finished');
if ((cursorPos + elapsed) >= (this.isSegmentSelection()) ? selection.end : this.duration) {
if (this.loopNumber > 0) {
this.loopNumber--;
this.ee.emit('newloop', this.loopNumber);
this.restartPlayFrom(selection.start, selection.end)
}
else if (this.loopNumber == -1) {
this.ee.emit('newloop', this.loopNumber);
this.restartPlayFrom(selection.start, selection.end)

}
else
this.ee.emit('finished');
}

this.stopAnimation();
Expand Down
1 change: 0 additions & 1 deletion src/Playout.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ export default class {
}

setSpeed(speed) {
console.log("callaed ! " + speed);
this.speed = speed;
}

Expand Down

0 comments on commit be778b2

Please sign in to comment.