sound = parseInt($(e).data('sound')) == 1,
autoplay = parseInt($(e).data('autoplay')) == 1,
nativeAutoplay = !autoplay && parseInt($(e).data('nativeautoplay')) == 1,
+ repeat = parseInt($(e).data('repeat')),
statsName = $(e).data('stats-name'),
statsType = $(e).data('stats-type'),
setup = $(e).data('setup'),
poster,
html,
player;
+
+ if (repeat === 0) {
+ loop = false;
+ }
+
+
var hidelinksonplay = $(e).data('hidelinksonplay') == undefined || $(e).data('hidelinksonplay') === '' ? [] : $(e).data('hidelinksonplay').split(',');
// console.log('Initialising video ID: ' + id, statsType, statsName);
html += 'disablePictureInPicture ';
}
- if (loop) {
+ console.log(loop,repeat);
+
+ // If repeat is set, loop is not executed natively
+ if (loop && repeat === -1) {
//html += 'onended="this.play()" ';
html += 'loop ';
}
player = videojs(id, setup);
player.ready(function () {
- //console.log(id + ' player is ready');
-
-
$this.fluidbook.stats.trackEvent(statsType, 'show', statsName);
$this.resizeControls(); // Make sure player controls are the right size
}
});
+ if (repeat >= 0 && loop) {
+ let repeatCount = repeat + 1;
+
+ player.on('ended', function () {
+ console.log('ended', repeatCount, player);
+ if (repeatCount === 0) {
+ player.pause();
+ return;
+ } else {
+ console.log(player);
+ player.currentTime(0);
+ player.play();
+ }
+ repeatCount--;
+ });
+ }
+
player.play(); // Start player to go to current position - necessary even if it will be paused immediately
if (settings.paused) {