diff --git a/library.json b/library.json index a359c197..d151bc44 100644 --- a/library.json +++ b/library.json @@ -20,6 +20,9 @@ { "path": "scripts/panopto.js" }, + { + "path": "scripts/nanoo-tv.js" + }, { "path": "scripts/html5.js" }, diff --git a/scripts/nanoo-tv.js b/scripts/nanoo-tv.js new file mode 100644 index 00000000..3c376c2d --- /dev/null +++ b/scripts/nanoo-tv.js @@ -0,0 +1,449 @@ +/** @namespace H5P */ +H5P.VideoNanooTv = (function ($) { + + /** + * Nanoo.tv video player for H5P. + * + * @class + * @param {Array} sources Video files to use + * @param {Object} options Settings for the player + * @param {Object} l10n Localization strings + */ + function NanooTv(sources, options, l10n) { + var self = this; + + var playbackRate = 1; + + id = 'h5p-nanootv-' + numInstances; + numInstances++; + + var $wrapper = $('
'); + var $placeholder = $('
', { + id: id, + text: l10n.loading + }).appendTo($wrapper); + + // Initialize pressToPlay in order to hide squash overlay in case of a login redirect. + self.pressToPlay = true; + + self.post = function (params) { + self.player[0].contentWindow.postMessage(params, 'https://www.nanoo.tv'); + }; + + /** + * Create a new nanoo.tv player + * + * @private + */ + var create = function () { + if (!$placeholder.is(':visible') || self.player !== undefined) { + return; + } + + var width = $wrapper.width(); + if (width < 200) { + width = 200; + } + + // Queries the url to a player without controls. + var videoPath = getPath(sources[0].path); + + // Create iframe holding the nanoo.tv player. + self.player = $('