/* eslint-disable no-console, no-param-reassign */ /** * @file HTML5 video player module. Provides methods to control the in-browser * HTML5 video player. * * The goal was to write this module so that it closely resembles the YouTube * API. The main reason for this is because initially the edX video player * supported only YouTube videos. When HTML5 support was added, for greater * compatibility, and to reduce the amount of code that needed to be modified, * it was decided to write a similar API as the one provided by YouTube. * * @external RequireJS * * @module HTML5Video */ (function(requirejs, require, define) { define( 'video/02_html5_video.js', ['underscore'], function(_) { var HTML5Video = {}; HTML5Video.Player = (function() { /* * Constructor function for HTML5 Video player. * * @param {String|Object} el A DOM element where the HTML5 player will * be inserted (as returned by jQuery(selector) function), or a * selector string which will be used to select an element. This is a * required parameter. * * @param config - An object whose properties will be used as * configuration options for the HTML5 video player. This is an * optional parameter. In the case if this parameter is missing, or * some of the config object's properties are missing, defaults will be * used. The available options (and their defaults) are as * follows: * * config = { * * videoSources: [], // An array with properties being video * // sources. The property name is the * // video format of the source. Supported * // video formats are: 'mp4', 'webm', and * // 'ogg'. * poster: Video poster URL * * browserIsSafari: Flag to tell if current browser is Safari * * events: { // Object's properties identify the * // events that the API fires, and the * // functions (event listeners) that the * // API will call when those events occur. * // If value is null, or property is not * // specified, then no callback will be * // called for that event. * * onReady: null, * onStateChange: null * } * } */ function Player(el, config) { var errorMessage, lastSource, sourceList; // Create HTML markup for individual sources of the HTML5