var onYouTubeIframeAPIReady = undefined; odoo.define('website_slides.fullscreen', function (require) { 'use strict'; var publicWidget = require('web.public.widget'); var core = require('web.core'); var config = require('web.config'); var QWeb = core.qweb; var _t = core._t; var session = require('web.session'); var Quiz = require('website_slides.quiz').Quiz; var Dialog = require('web.Dialog'); require('website_slides.course.join.widget'); /** * Helper: Get the slide dict matching the given criteria * * @private * @param {Array} slideList List of dict reprensenting a slide * @param {Object} matcher (see https://underscorejs.org/#matcher) */ var findSlide = function (slideList, matcher) { var slideMatch = _.matcher(matcher); return _.find(slideList, slideMatch); }; /** * This widget is responsible of display Youtube Player * * The widget will trigger an event `change_slide` when the video is at * its end, and `slide_completed` when the player is at 30 sec before the * end of the video (30 sec before is considered as completed). */ var VideoPlayer = publicWidget.Widget.extend({ template: 'website.slides.fullscreen.video', youtubeUrl: 'https://www.youtube.com/iframe_api', init: function (parent, slide) { this.slide = slide; return this._super.apply(this, arguments); }, start: function (){ var self = this; return Promise.all([this._super.apply(this, arguments), this._loadYoutubeAPI()]).then(function() { self._setupYoutubePlayer(); }); }, _loadYoutubeAPI: function () { var self = this; var prom = new Promise(function (resolve, reject) { if ($(document).find('script[src="' + self.youtubeUrl + '"]').length === 0) { var $youtubeElement = $('