width = parseFloat($(e).data('width')),
height = parseFloat($(e).data('height')),
name = $(e).data('name'),
- controls = $(e).data('controls'),
- loop = $(e).data('loop'),
- sound = $(e).data('sound'),
- autoplay = $(e).data('autoplay'),
+ controls = parseInt($(e).data('controls')) == 1,
+ loop = parseInt($(e).data('loop')) == 1,
+ sound = parseInt($(e).data('sound')) == 1,
+ autoplay = parseInt($(e).data('autoplay')) == 1,
+ nativeAutoplay = !autoplay && parseInt($(e).data('nativeautoplay')) == 1,
setup = $(e).data('setup'),
linkid = $(e).data('link-id'),
url = $(e).data('url'),
poster,
html,
player;
- var hidelinksonplay = $(e).data('hidelinksonplay') === '' ? [] : $(e).data('hidelinksonplay').split(',');
+ var hidelinksonplay = $(e).data('hidelinksonplay') == undefined || $(e).data('hidelinksonplay') === '' ? [] : $(e).data('hidelinksonplay').split(',');
//console.log('Initialising video ID: ' + id);
html = '<video class="video-js vjs-fluidbook-skin"';
html += ' style="background-color:' + backgroundColor + ';" '
- if (poster && autoplay != '1') {
+ if (poster && !autoplay) {
html += 'poster="' + poster + '" ';
}
html += 'height="' + height + '" ';
}
- if (controls == '1') {
+ if (controls) {
html += 'controls ';
} else {
html += 'disablePictureInPicture ';
}
- if (loop == '1') {
+ if (loop) {
//html += 'onended="this.play()" ';
html += 'loop ';
}
+ if (nativeAutoplay) {
+ html += 'autoplay ';
+ }
- if (sound == '0') {
+ if (!sound) {
html += 'muted ';
}
$this.resizeControls(); // Make sure player controls are the right size
- if(autoplay=='1') {
+ console.log('autoplay', autoplay);
+ if (autoplay) {
var promise = player.play();
if (promise !== undefined) {
promise.then(function () {
+ console.log('autoplay ok');
// Autoplay started!
}).catch(function (error) {
+ console.log('autoplay nok');
// Autoplay was prevented.
});
}
player.one('play', function () {
//console.log('Player has started playing... ID: ' + id);
// Handle pause in here if needed.. Better than using the timeout...
-
if (settings.paused) {
- //console.log(id + ' should be paused');
setTimeout(function () {
player.pause();
}, 100);
} else {
- console.log('hide ', hidelinksonplay);
$.each(hidelinksonplay, function (k, id) {
$this.fluidbook.links.hideLinkById(id);
});