Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

2520 righe
72 KiB

  1. /*! @vimeo/player v2.16.4 | (c) 2022 Vimeo | MIT License | https://github.com/vimeo/player.js */
  2. (function (global, factory) {
  3. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  4. typeof define === 'function' && define.amd ? define(factory) :
  5. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.Vimeo = global.Vimeo || {}, global.Vimeo.Player = factory()));
  6. }(this, (function () { 'use strict';
  7. function _classCallCheck(instance, Constructor) {
  8. if (!(instance instanceof Constructor)) {
  9. throw new TypeError("Cannot call a class as a function");
  10. }
  11. }
  12. function _defineProperties(target, props) {
  13. for (var i = 0; i < props.length; i++) {
  14. var descriptor = props[i];
  15. descriptor.enumerable = descriptor.enumerable || false;
  16. descriptor.configurable = true;
  17. if ("value" in descriptor) descriptor.writable = true;
  18. Object.defineProperty(target, descriptor.key, descriptor);
  19. }
  20. }
  21. function _createClass(Constructor, protoProps, staticProps) {
  22. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  23. if (staticProps) _defineProperties(Constructor, staticProps);
  24. return Constructor;
  25. }
  26. /**
  27. * @module lib/functions
  28. */
  29. /**
  30. * Check to see this is a node environment.
  31. * @type {Boolean}
  32. */
  33. /* global global */
  34. var isNode = typeof global !== 'undefined' && {}.toString.call(global) === '[object global]';
  35. /**
  36. * Get the name of the method for a given getter or setter.
  37. *
  38. * @param {string} prop The name of the property.
  39. * @param {string} type Either “get” or “set”.
  40. * @return {string}
  41. */
  42. function getMethodName(prop, type) {
  43. if (prop.indexOf(type.toLowerCase()) === 0) {
  44. return prop;
  45. }
  46. return "".concat(type.toLowerCase()).concat(prop.substr(0, 1).toUpperCase()).concat(prop.substr(1));
  47. }
  48. /**
  49. * Check to see if the object is a DOM Element.
  50. *
  51. * @param {*} element The object to check.
  52. * @return {boolean}
  53. */
  54. function isDomElement(element) {
  55. return Boolean(element && element.nodeType === 1 && 'nodeName' in element && element.ownerDocument && element.ownerDocument.defaultView);
  56. }
  57. /**
  58. * Check to see whether the value is a number.
  59. *
  60. * @see http://dl.dropboxusercontent.com/u/35146/js/tests/isNumber.html
  61. * @param {*} value The value to check.
  62. * @param {boolean} integer Check if the value is an integer.
  63. * @return {boolean}
  64. */
  65. function isInteger(value) {
  66. // eslint-disable-next-line eqeqeq
  67. return !isNaN(parseFloat(value)) && isFinite(value) && Math.floor(value) == value;
  68. }
  69. /**
  70. * Check to see if the URL is a Vimeo url.
  71. *
  72. * @param {string} url The url string.
  73. * @return {boolean}
  74. */
  75. function isVimeoUrl(url) {
  76. return /^(https?:)?\/\/((player|www)\.)?vimeo\.com(?=$|\/)/.test(url);
  77. }
  78. /**
  79. * Get the Vimeo URL from an element.
  80. * The element must have either a data-vimeo-id or data-vimeo-url attribute.
  81. *
  82. * @param {object} oEmbedParameters The oEmbed parameters.
  83. * @return {string}
  84. */
  85. function getVimeoUrl() {
  86. var oEmbedParameters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  87. var id = oEmbedParameters.id;
  88. var url = oEmbedParameters.url;
  89. var idOrUrl = id || url;
  90. if (!idOrUrl) {
  91. throw new Error('An id or url must be passed, either in an options object or as a data-vimeo-id or data-vimeo-url attribute.');
  92. }
  93. if (isInteger(idOrUrl)) {
  94. return "https://vimeo.com/".concat(idOrUrl);
  95. }
  96. if (isVimeoUrl(idOrUrl)) {
  97. return idOrUrl.replace('http:', 'https:');
  98. }
  99. if (id) {
  100. throw new TypeError("\u201C".concat(id, "\u201D is not a valid video id."));
  101. }
  102. throw new TypeError("\u201C".concat(idOrUrl, "\u201D is not a vimeo.com url."));
  103. }
  104. var arrayIndexOfSupport = typeof Array.prototype.indexOf !== 'undefined';
  105. var postMessageSupport = typeof window !== 'undefined' && typeof window.postMessage !== 'undefined';
  106. if (!isNode && (!arrayIndexOfSupport || !postMessageSupport)) {
  107. throw new Error('Sorry, the Vimeo Player API is not available in this browser.');
  108. }
  109. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  110. function createCommonjsModule(fn, module) {
  111. return module = { exports: {} }, fn(module, module.exports), module.exports;
  112. }
  113. /*!
  114. * weakmap-polyfill v2.0.1 - ECMAScript6 WeakMap polyfill
  115. * https://github.com/polygonplanet/weakmap-polyfill
  116. * Copyright (c) 2015-2020 Polygon Planet <polygon.planet.aqua@gmail.com>
  117. * @license MIT
  118. */
  119. (function (self) {
  120. if (self.WeakMap) {
  121. return;
  122. }
  123. var hasOwnProperty = Object.prototype.hasOwnProperty;
  124. var defineProperty = function (object, name, value) {
  125. if (Object.defineProperty) {
  126. Object.defineProperty(object, name, {
  127. configurable: true,
  128. writable: true,
  129. value: value
  130. });
  131. } else {
  132. object[name] = value;
  133. }
  134. };
  135. self.WeakMap = function () {
  136. // ECMA-262 23.3 WeakMap Objects
  137. function WeakMap() {
  138. if (this === void 0) {
  139. throw new TypeError("Constructor WeakMap requires 'new'");
  140. }
  141. defineProperty(this, '_id', genId('_WeakMap')); // ECMA-262 23.3.1.1 WeakMap([iterable])
  142. if (arguments.length > 0) {
  143. // Currently, WeakMap `iterable` argument is not supported
  144. throw new TypeError('WeakMap iterable is not supported');
  145. }
  146. } // ECMA-262 23.3.3.2 WeakMap.prototype.delete(key)
  147. defineProperty(WeakMap.prototype, 'delete', function (key) {
  148. checkInstance(this, 'delete');
  149. if (!isObject(key)) {
  150. return false;
  151. }
  152. var entry = key[this._id];
  153. if (entry && entry[0] === key) {
  154. delete key[this._id];
  155. return true;
  156. }
  157. return false;
  158. }); // ECMA-262 23.3.3.3 WeakMap.prototype.get(key)
  159. defineProperty(WeakMap.prototype, 'get', function (key) {
  160. checkInstance(this, 'get');
  161. if (!isObject(key)) {
  162. return void 0;
  163. }
  164. var entry = key[this._id];
  165. if (entry && entry[0] === key) {
  166. return entry[1];
  167. }
  168. return void 0;
  169. }); // ECMA-262 23.3.3.4 WeakMap.prototype.has(key)
  170. defineProperty(WeakMap.prototype, 'has', function (key) {
  171. checkInstance(this, 'has');
  172. if (!isObject(key)) {
  173. return false;
  174. }
  175. var entry = key[this._id];
  176. if (entry && entry[0] === key) {
  177. return true;
  178. }
  179. return false;
  180. }); // ECMA-262 23.3.3.5 WeakMap.prototype.set(key, value)
  181. defineProperty(WeakMap.prototype, 'set', function (key, value) {
  182. checkInstance(this, 'set');
  183. if (!isObject(key)) {
  184. throw new TypeError('Invalid value used as weak map key');
  185. }
  186. var entry = key[this._id];
  187. if (entry && entry[0] === key) {
  188. entry[1] = value;
  189. return this;
  190. }
  191. defineProperty(key, this._id, [key, value]);
  192. return this;
  193. });
  194. function checkInstance(x, methodName) {
  195. if (!isObject(x) || !hasOwnProperty.call(x, '_id')) {
  196. throw new TypeError(methodName + ' method called on incompatible receiver ' + typeof x);
  197. }
  198. }
  199. function genId(prefix) {
  200. return prefix + '_' + rand() + '.' + rand();
  201. }
  202. function rand() {
  203. return Math.random().toString().substring(2);
  204. }
  205. defineProperty(WeakMap, '_polyfill', true);
  206. return WeakMap;
  207. }();
  208. function isObject(x) {
  209. return Object(x) === x;
  210. }
  211. })(typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : typeof commonjsGlobal !== 'undefined' ? commonjsGlobal : commonjsGlobal);
  212. var npo_src = createCommonjsModule(function (module) {
  213. /*! Native Promise Only
  214. v0.8.1 (c) Kyle Simpson
  215. MIT License: http://getify.mit-license.org
  216. */
  217. (function UMD(name, context, definition) {
  218. // special form of UMD for polyfilling across evironments
  219. context[name] = context[name] || definition();
  220. if (module.exports) {
  221. module.exports = context[name];
  222. }
  223. })("Promise", typeof commonjsGlobal != "undefined" ? commonjsGlobal : commonjsGlobal, function DEF() {
  224. var builtInProp,
  225. cycle,
  226. scheduling_queue,
  227. ToString = Object.prototype.toString,
  228. timer = typeof setImmediate != "undefined" ? function timer(fn) {
  229. return setImmediate(fn);
  230. } : setTimeout; // dammit, IE8.
  231. try {
  232. Object.defineProperty({}, "x", {});
  233. builtInProp = function builtInProp(obj, name, val, config) {
  234. return Object.defineProperty(obj, name, {
  235. value: val,
  236. writable: true,
  237. configurable: config !== false
  238. });
  239. };
  240. } catch (err) {
  241. builtInProp = function builtInProp(obj, name, val) {
  242. obj[name] = val;
  243. return obj;
  244. };
  245. } // Note: using a queue instead of array for efficiency
  246. scheduling_queue = function Queue() {
  247. var first, last, item;
  248. function Item(fn, self) {
  249. this.fn = fn;
  250. this.self = self;
  251. this.next = void 0;
  252. }
  253. return {
  254. add: function add(fn, self) {
  255. item = new Item(fn, self);
  256. if (last) {
  257. last.next = item;
  258. } else {
  259. first = item;
  260. }
  261. last = item;
  262. item = void 0;
  263. },
  264. drain: function drain() {
  265. var f = first;
  266. first = last = cycle = void 0;
  267. while (f) {
  268. f.fn.call(f.self);
  269. f = f.next;
  270. }
  271. }
  272. };
  273. }();
  274. function schedule(fn, self) {
  275. scheduling_queue.add(fn, self);
  276. if (!cycle) {
  277. cycle = timer(scheduling_queue.drain);
  278. }
  279. } // promise duck typing
  280. function isThenable(o) {
  281. var _then,
  282. o_type = typeof o;
  283. if (o != null && (o_type == "object" || o_type == "function")) {
  284. _then = o.then;
  285. }
  286. return typeof _then == "function" ? _then : false;
  287. }
  288. function notify() {
  289. for (var i = 0; i < this.chain.length; i++) {
  290. notifyIsolated(this, this.state === 1 ? this.chain[i].success : this.chain[i].failure, this.chain[i]);
  291. }
  292. this.chain.length = 0;
  293. } // NOTE: This is a separate function to isolate
  294. // the `try..catch` so that other code can be
  295. // optimized better
  296. function notifyIsolated(self, cb, chain) {
  297. var ret, _then;
  298. try {
  299. if (cb === false) {
  300. chain.reject(self.msg);
  301. } else {
  302. if (cb === true) {
  303. ret = self.msg;
  304. } else {
  305. ret = cb.call(void 0, self.msg);
  306. }
  307. if (ret === chain.promise) {
  308. chain.reject(TypeError("Promise-chain cycle"));
  309. } else if (_then = isThenable(ret)) {
  310. _then.call(ret, chain.resolve, chain.reject);
  311. } else {
  312. chain.resolve(ret);
  313. }
  314. }
  315. } catch (err) {
  316. chain.reject(err);
  317. }
  318. }
  319. function resolve(msg) {
  320. var _then,
  321. self = this; // already triggered?
  322. if (self.triggered) {
  323. return;
  324. }
  325. self.triggered = true; // unwrap
  326. if (self.def) {
  327. self = self.def;
  328. }
  329. try {
  330. if (_then = isThenable(msg)) {
  331. schedule(function () {
  332. var def_wrapper = new MakeDefWrapper(self);
  333. try {
  334. _then.call(msg, function $resolve$() {
  335. resolve.apply(def_wrapper, arguments);
  336. }, function $reject$() {
  337. reject.apply(def_wrapper, arguments);
  338. });
  339. } catch (err) {
  340. reject.call(def_wrapper, err);
  341. }
  342. });
  343. } else {
  344. self.msg = msg;
  345. self.state = 1;
  346. if (self.chain.length > 0) {
  347. schedule(notify, self);
  348. }
  349. }
  350. } catch (err) {
  351. reject.call(new MakeDefWrapper(self), err);
  352. }
  353. }
  354. function reject(msg) {
  355. var self = this; // already triggered?
  356. if (self.triggered) {
  357. return;
  358. }
  359. self.triggered = true; // unwrap
  360. if (self.def) {
  361. self = self.def;
  362. }
  363. self.msg = msg;
  364. self.state = 2;
  365. if (self.chain.length > 0) {
  366. schedule(notify, self);
  367. }
  368. }
  369. function iteratePromises(Constructor, arr, resolver, rejecter) {
  370. for (var idx = 0; idx < arr.length; idx++) {
  371. (function IIFE(idx) {
  372. Constructor.resolve(arr[idx]).then(function $resolver$(msg) {
  373. resolver(idx, msg);
  374. }, rejecter);
  375. })(idx);
  376. }
  377. }
  378. function MakeDefWrapper(self) {
  379. this.def = self;
  380. this.triggered = false;
  381. }
  382. function MakeDef(self) {
  383. this.promise = self;
  384. this.state = 0;
  385. this.triggered = false;
  386. this.chain = [];
  387. this.msg = void 0;
  388. }
  389. function Promise(executor) {
  390. if (typeof executor != "function") {
  391. throw TypeError("Not a function");
  392. }
  393. if (this.__NPO__ !== 0) {
  394. throw TypeError("Not a promise");
  395. } // instance shadowing the inherited "brand"
  396. // to signal an already "initialized" promise
  397. this.__NPO__ = 1;
  398. var def = new MakeDef(this);
  399. this["then"] = function then(success, failure) {
  400. var o = {
  401. success: typeof success == "function" ? success : true,
  402. failure: typeof failure == "function" ? failure : false
  403. }; // Note: `then(..)` itself can be borrowed to be used against
  404. // a different promise constructor for making the chained promise,
  405. // by substituting a different `this` binding.
  406. o.promise = new this.constructor(function extractChain(resolve, reject) {
  407. if (typeof resolve != "function" || typeof reject != "function") {
  408. throw TypeError("Not a function");
  409. }
  410. o.resolve = resolve;
  411. o.reject = reject;
  412. });
  413. def.chain.push(o);
  414. if (def.state !== 0) {
  415. schedule(notify, def);
  416. }
  417. return o.promise;
  418. };
  419. this["catch"] = function $catch$(failure) {
  420. return this.then(void 0, failure);
  421. };
  422. try {
  423. executor.call(void 0, function publicResolve(msg) {
  424. resolve.call(def, msg);
  425. }, function publicReject(msg) {
  426. reject.call(def, msg);
  427. });
  428. } catch (err) {
  429. reject.call(def, err);
  430. }
  431. }
  432. var PromisePrototype = builtInProp({}, "constructor", Promise,
  433. /*configurable=*/
  434. false); // Note: Android 4 cannot use `Object.defineProperty(..)` here
  435. Promise.prototype = PromisePrototype; // built-in "brand" to signal an "uninitialized" promise
  436. builtInProp(PromisePrototype, "__NPO__", 0,
  437. /*configurable=*/
  438. false);
  439. builtInProp(Promise, "resolve", function Promise$resolve(msg) {
  440. var Constructor = this; // spec mandated checks
  441. // note: best "isPromise" check that's practical for now
  442. if (msg && typeof msg == "object" && msg.__NPO__ === 1) {
  443. return msg;
  444. }
  445. return new Constructor(function executor(resolve, reject) {
  446. if (typeof resolve != "function" || typeof reject != "function") {
  447. throw TypeError("Not a function");
  448. }
  449. resolve(msg);
  450. });
  451. });
  452. builtInProp(Promise, "reject", function Promise$reject(msg) {
  453. return new this(function executor(resolve, reject) {
  454. if (typeof resolve != "function" || typeof reject != "function") {
  455. throw TypeError("Not a function");
  456. }
  457. reject(msg);
  458. });
  459. });
  460. builtInProp(Promise, "all", function Promise$all(arr) {
  461. var Constructor = this; // spec mandated checks
  462. if (ToString.call(arr) != "[object Array]") {
  463. return Constructor.reject(TypeError("Not an array"));
  464. }
  465. if (arr.length === 0) {
  466. return Constructor.resolve([]);
  467. }
  468. return new Constructor(function executor(resolve, reject) {
  469. if (typeof resolve != "function" || typeof reject != "function") {
  470. throw TypeError("Not a function");
  471. }
  472. var len = arr.length,
  473. msgs = Array(len),
  474. count = 0;
  475. iteratePromises(Constructor, arr, function resolver(idx, msg) {
  476. msgs[idx] = msg;
  477. if (++count === len) {
  478. resolve(msgs);
  479. }
  480. }, reject);
  481. });
  482. });
  483. builtInProp(Promise, "race", function Promise$race(arr) {
  484. var Constructor = this; // spec mandated checks
  485. if (ToString.call(arr) != "[object Array]") {
  486. return Constructor.reject(TypeError("Not an array"));
  487. }
  488. return new Constructor(function executor(resolve, reject) {
  489. if (typeof resolve != "function" || typeof reject != "function") {
  490. throw TypeError("Not a function");
  491. }
  492. iteratePromises(Constructor, arr, function resolver(idx, msg) {
  493. resolve(msg);
  494. }, reject);
  495. });
  496. });
  497. return Promise;
  498. });
  499. });
  500. /**
  501. * @module lib/callbacks
  502. */
  503. var callbackMap = new WeakMap();
  504. /**
  505. * Store a callback for a method or event for a player.
  506. *
  507. * @param {Player} player The player object.
  508. * @param {string} name The method or event name.
  509. * @param {(function(this:Player, *): void|{resolve: function, reject: function})} callback
  510. * The callback to call or an object with resolve and reject functions for a promise.
  511. * @return {void}
  512. */
  513. function storeCallback(player, name, callback) {
  514. var playerCallbacks = callbackMap.get(player.element) || {};
  515. if (!(name in playerCallbacks)) {
  516. playerCallbacks[name] = [];
  517. }
  518. playerCallbacks[name].push(callback);
  519. callbackMap.set(player.element, playerCallbacks);
  520. }
  521. /**
  522. * Get the callbacks for a player and event or method.
  523. *
  524. * @param {Player} player The player object.
  525. * @param {string} name The method or event name
  526. * @return {function[]}
  527. */
  528. function getCallbacks(player, name) {
  529. var playerCallbacks = callbackMap.get(player.element) || {};
  530. return playerCallbacks[name] || [];
  531. }
  532. /**
  533. * Remove a stored callback for a method or event for a player.
  534. *
  535. * @param {Player} player The player object.
  536. * @param {string} name The method or event name
  537. * @param {function} [callback] The specific callback to remove.
  538. * @return {boolean} Was this the last callback?
  539. */
  540. function removeCallback(player, name, callback) {
  541. var playerCallbacks = callbackMap.get(player.element) || {};
  542. if (!playerCallbacks[name]) {
  543. return true;
  544. } // If no callback is passed, remove all callbacks for the event
  545. if (!callback) {
  546. playerCallbacks[name] = [];
  547. callbackMap.set(player.element, playerCallbacks);
  548. return true;
  549. }
  550. var index = playerCallbacks[name].indexOf(callback);
  551. if (index !== -1) {
  552. playerCallbacks[name].splice(index, 1);
  553. }
  554. callbackMap.set(player.element, playerCallbacks);
  555. return playerCallbacks[name] && playerCallbacks[name].length === 0;
  556. }
  557. /**
  558. * Return the first stored callback for a player and event or method.
  559. *
  560. * @param {Player} player The player object.
  561. * @param {string} name The method or event name.
  562. * @return {function} The callback, or false if there were none
  563. */
  564. function shiftCallbacks(player, name) {
  565. var playerCallbacks = getCallbacks(player, name);
  566. if (playerCallbacks.length < 1) {
  567. return false;
  568. }
  569. var callback = playerCallbacks.shift();
  570. removeCallback(player, name, callback);
  571. return callback;
  572. }
  573. /**
  574. * Move callbacks associated with an element to another element.
  575. *
  576. * @param {HTMLElement} oldElement The old element.
  577. * @param {HTMLElement} newElement The new element.
  578. * @return {void}
  579. */
  580. function swapCallbacks(oldElement, newElement) {
  581. var playerCallbacks = callbackMap.get(oldElement);
  582. callbackMap.set(newElement, playerCallbacks);
  583. callbackMap.delete(oldElement);
  584. }
  585. /**
  586. * @module lib/embed
  587. */
  588. var oEmbedParameters = ['autopause', 'autoplay', 'background', 'byline', 'color', 'controls', 'dnt', 'height', 'id', 'interactive_params', 'keyboard', 'loop', 'maxheight', 'maxwidth', 'muted', 'playsinline', 'portrait', 'responsive', 'speed', 'texttrack', 'title', 'transparent', 'url', 'width'];
  589. /**
  590. * Get the 'data-vimeo'-prefixed attributes from an element as an object.
  591. *
  592. * @param {HTMLElement} element The element.
  593. * @param {Object} [defaults={}] The default values to use.
  594. * @return {Object<string, string>}
  595. */
  596. function getOEmbedParameters(element) {
  597. var defaults = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  598. return oEmbedParameters.reduce(function (params, param) {
  599. var value = element.getAttribute("data-vimeo-".concat(param));
  600. if (value || value === '') {
  601. params[param] = value === '' ? 1 : value;
  602. }
  603. return params;
  604. }, defaults);
  605. }
  606. /**
  607. * Create an embed from oEmbed data inside an element.
  608. *
  609. * @param {object} data The oEmbed data.
  610. * @param {HTMLElement} element The element to put the iframe in.
  611. * @return {HTMLIFrameElement} The iframe embed.
  612. */
  613. function createEmbed(_ref, element) {
  614. var html = _ref.html;
  615. if (!element) {
  616. throw new TypeError('An element must be provided');
  617. }
  618. if (element.getAttribute('data-vimeo-initialized') !== null) {
  619. return element.querySelector('iframe');
  620. }
  621. var div = document.createElement('div');
  622. div.innerHTML = html;
  623. element.appendChild(div.firstChild);
  624. element.setAttribute('data-vimeo-initialized', 'true');
  625. return element.querySelector('iframe');
  626. }
  627. /**
  628. * Make an oEmbed call for the specified URL.
  629. *
  630. * @param {string} videoUrl The vimeo.com url for the video.
  631. * @param {Object} [params] Parameters to pass to oEmbed.
  632. * @param {HTMLElement} element The element.
  633. * @return {Promise}
  634. */
  635. function getOEmbedData(videoUrl) {
  636. var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  637. var element = arguments.length > 2 ? arguments[2] : undefined;
  638. return new Promise(function (resolve, reject) {
  639. if (!isVimeoUrl(videoUrl)) {
  640. throw new TypeError("\u201C".concat(videoUrl, "\u201D is not a vimeo.com url."));
  641. }
  642. var url = "https://vimeo.com/api/oembed.json?url=".concat(encodeURIComponent(videoUrl));
  643. for (var param in params) {
  644. if (params.hasOwnProperty(param)) {
  645. url += "&".concat(param, "=").concat(encodeURIComponent(params[param]));
  646. }
  647. }
  648. var xhr = 'XDomainRequest' in window ? new XDomainRequest() : new XMLHttpRequest();
  649. xhr.open('GET', url, true);
  650. xhr.onload = function () {
  651. if (xhr.status === 404) {
  652. reject(new Error("\u201C".concat(videoUrl, "\u201D was not found.")));
  653. return;
  654. }
  655. if (xhr.status === 403) {
  656. reject(new Error("\u201C".concat(videoUrl, "\u201D is not embeddable.")));
  657. return;
  658. }
  659. try {
  660. var json = JSON.parse(xhr.responseText); // Check api response for 403 on oembed
  661. if (json.domain_status_code === 403) {
  662. // We still want to create the embed to give users visual feedback
  663. createEmbed(json, element);
  664. reject(new Error("\u201C".concat(videoUrl, "\u201D is not embeddable.")));
  665. return;
  666. }
  667. resolve(json);
  668. } catch (error) {
  669. reject(error);
  670. }
  671. };
  672. xhr.onerror = function () {
  673. var status = xhr.status ? " (".concat(xhr.status, ")") : '';
  674. reject(new Error("There was an error fetching the embed code from Vimeo".concat(status, ".")));
  675. };
  676. xhr.send();
  677. });
  678. }
  679. /**
  680. * Initialize all embeds within a specific element
  681. *
  682. * @param {HTMLElement} [parent=document] The parent element.
  683. * @return {void}
  684. */
  685. function initializeEmbeds() {
  686. var parent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document;
  687. var elements = [].slice.call(parent.querySelectorAll('[data-vimeo-id], [data-vimeo-url]'));
  688. var handleError = function handleError(error) {
  689. if ('console' in window && console.error) {
  690. console.error("There was an error creating an embed: ".concat(error));
  691. }
  692. };
  693. elements.forEach(function (element) {
  694. try {
  695. // Skip any that have data-vimeo-defer
  696. if (element.getAttribute('data-vimeo-defer') !== null) {
  697. return;
  698. }
  699. var params = getOEmbedParameters(element);
  700. var url = getVimeoUrl(params);
  701. getOEmbedData(url, params, element).then(function (data) {
  702. return createEmbed(data, element);
  703. }).catch(handleError);
  704. } catch (error) {
  705. handleError(error);
  706. }
  707. });
  708. }
  709. /**
  710. * Resize embeds when messaged by the player.
  711. *
  712. * @param {HTMLElement} [parent=document] The parent element.
  713. * @return {void}
  714. */
  715. function resizeEmbeds() {
  716. var parent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document;
  717. // Prevent execution if users include the player.js script multiple times.
  718. if (window.VimeoPlayerResizeEmbeds_) {
  719. return;
  720. }
  721. window.VimeoPlayerResizeEmbeds_ = true;
  722. var onMessage = function onMessage(event) {
  723. if (!isVimeoUrl(event.origin)) {
  724. return;
  725. } // 'spacechange' is fired only on embeds with cards
  726. if (!event.data || event.data.event !== 'spacechange') {
  727. return;
  728. }
  729. var iframes = parent.querySelectorAll('iframe');
  730. for (var i = 0; i < iframes.length; i++) {
  731. if (iframes[i].contentWindow !== event.source) {
  732. continue;
  733. } // Change padding-bottom of the enclosing div to accommodate
  734. // card carousel without distorting aspect ratio
  735. var space = iframes[i].parentElement;
  736. space.style.paddingBottom = "".concat(event.data.data[0].bottom, "px");
  737. break;
  738. }
  739. };
  740. window.addEventListener('message', onMessage);
  741. }
  742. /**
  743. * @module lib/postmessage
  744. */
  745. /**
  746. * Parse a message received from postMessage.
  747. *
  748. * @param {*} data The data received from postMessage.
  749. * @return {object}
  750. */
  751. function parseMessageData(data) {
  752. if (typeof data === 'string') {
  753. try {
  754. data = JSON.parse(data);
  755. } catch (error) {
  756. // If the message cannot be parsed, throw the error as a warning
  757. console.warn(error);
  758. return {};
  759. }
  760. }
  761. return data;
  762. }
  763. /**
  764. * Post a message to the specified target.
  765. *
  766. * @param {Player} player The player object to use.
  767. * @param {string} method The API method to call.
  768. * @param {object} params The parameters to send to the player.
  769. * @return {void}
  770. */
  771. function postMessage(player, method, params) {
  772. if (!player.element.contentWindow || !player.element.contentWindow.postMessage) {
  773. return;
  774. }
  775. var message = {
  776. method: method
  777. };
  778. if (params !== undefined) {
  779. message.value = params;
  780. } // IE 8 and 9 do not support passing messages, so stringify them
  781. var ieVersion = parseFloat(navigator.userAgent.toLowerCase().replace(/^.*msie (\d+).*$/, '$1'));
  782. if (ieVersion >= 8 && ieVersion < 10) {
  783. message = JSON.stringify(message);
  784. }
  785. player.element.contentWindow.postMessage(message, player.origin);
  786. }
  787. /**
  788. * Parse the data received from a message event.
  789. *
  790. * @param {Player} player The player that received the message.
  791. * @param {(Object|string)} data The message data. Strings will be parsed into JSON.
  792. * @return {void}
  793. */
  794. function processData(player, data) {
  795. data = parseMessageData(data);
  796. var callbacks = [];
  797. var param;
  798. if (data.event) {
  799. if (data.event === 'error') {
  800. var promises = getCallbacks(player, data.data.method);
  801. promises.forEach(function (promise) {
  802. var error = new Error(data.data.message);
  803. error.name = data.data.name;
  804. promise.reject(error);
  805. removeCallback(player, data.data.method, promise);
  806. });
  807. }
  808. callbacks = getCallbacks(player, "event:".concat(data.event));
  809. param = data.data;
  810. } else if (data.method) {
  811. var callback = shiftCallbacks(player, data.method);
  812. if (callback) {
  813. callbacks.push(callback);
  814. param = data.value;
  815. }
  816. }
  817. callbacks.forEach(function (callback) {
  818. try {
  819. if (typeof callback === 'function') {
  820. callback.call(player, param);
  821. return;
  822. }
  823. callback.resolve(param);
  824. } catch (e) {// empty
  825. }
  826. });
  827. }
  828. /* MIT License
  829. Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
  830. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
  831. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  832. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  833. Terms */
  834. function initializeScreenfull() {
  835. var fn = function () {
  836. var val;
  837. var fnMap = [['requestFullscreen', 'exitFullscreen', 'fullscreenElement', 'fullscreenEnabled', 'fullscreenchange', 'fullscreenerror'], // New WebKit
  838. ['webkitRequestFullscreen', 'webkitExitFullscreen', 'webkitFullscreenElement', 'webkitFullscreenEnabled', 'webkitfullscreenchange', 'webkitfullscreenerror'], // Old WebKit
  839. ['webkitRequestFullScreen', 'webkitCancelFullScreen', 'webkitCurrentFullScreenElement', 'webkitCancelFullScreen', 'webkitfullscreenchange', 'webkitfullscreenerror'], ['mozRequestFullScreen', 'mozCancelFullScreen', 'mozFullScreenElement', 'mozFullScreenEnabled', 'mozfullscreenchange', 'mozfullscreenerror'], ['msRequestFullscreen', 'msExitFullscreen', 'msFullscreenElement', 'msFullscreenEnabled', 'MSFullscreenChange', 'MSFullscreenError']];
  840. var i = 0;
  841. var l = fnMap.length;
  842. var ret = {};
  843. for (; i < l; i++) {
  844. val = fnMap[i];
  845. if (val && val[1] in document) {
  846. for (i = 0; i < val.length; i++) {
  847. ret[fnMap[0][i]] = val[i];
  848. }
  849. return ret;
  850. }
  851. }
  852. return false;
  853. }();
  854. var eventNameMap = {
  855. fullscreenchange: fn.fullscreenchange,
  856. fullscreenerror: fn.fullscreenerror
  857. };
  858. var screenfull = {
  859. request: function request(element) {
  860. return new Promise(function (resolve, reject) {
  861. var onFullScreenEntered = function onFullScreenEntered() {
  862. screenfull.off('fullscreenchange', onFullScreenEntered);
  863. resolve();
  864. };
  865. screenfull.on('fullscreenchange', onFullScreenEntered);
  866. element = element || document.documentElement;
  867. var returnPromise = element[fn.requestFullscreen]();
  868. if (returnPromise instanceof Promise) {
  869. returnPromise.then(onFullScreenEntered).catch(reject);
  870. }
  871. });
  872. },
  873. exit: function exit() {
  874. return new Promise(function (resolve, reject) {
  875. if (!screenfull.isFullscreen) {
  876. resolve();
  877. return;
  878. }
  879. var onFullScreenExit = function onFullScreenExit() {
  880. screenfull.off('fullscreenchange', onFullScreenExit);
  881. resolve();
  882. };
  883. screenfull.on('fullscreenchange', onFullScreenExit);
  884. var returnPromise = document[fn.exitFullscreen]();
  885. if (returnPromise instanceof Promise) {
  886. returnPromise.then(onFullScreenExit).catch(reject);
  887. }
  888. });
  889. },
  890. on: function on(event, callback) {
  891. var eventName = eventNameMap[event];
  892. if (eventName) {
  893. document.addEventListener(eventName, callback);
  894. }
  895. },
  896. off: function off(event, callback) {
  897. var eventName = eventNameMap[event];
  898. if (eventName) {
  899. document.removeEventListener(eventName, callback);
  900. }
  901. }
  902. };
  903. Object.defineProperties(screenfull, {
  904. isFullscreen: {
  905. get: function get() {
  906. return Boolean(document[fn.fullscreenElement]);
  907. }
  908. },
  909. element: {
  910. enumerable: true,
  911. get: function get() {
  912. return document[fn.fullscreenElement];
  913. }
  914. },
  915. isEnabled: {
  916. enumerable: true,
  917. get: function get() {
  918. // Coerce to boolean in case of old WebKit
  919. return Boolean(document[fn.fullscreenEnabled]);
  920. }
  921. }
  922. });
  923. return screenfull;
  924. }
  925. var playerMap = new WeakMap();
  926. var readyMap = new WeakMap();
  927. var screenfull = {};
  928. var Player = /*#__PURE__*/function () {
  929. /**
  930. * Create a Player.
  931. *
  932. * @param {(HTMLIFrameElement|HTMLElement|string|jQuery)} element A reference to the Vimeo
  933. * player iframe, and id, or a jQuery object.
  934. * @param {object} [options] oEmbed parameters to use when creating an embed in the element.
  935. * @return {Player}
  936. */
  937. function Player(element) {
  938. var _this = this;
  939. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  940. _classCallCheck(this, Player);
  941. /* global jQuery */
  942. if (window.jQuery && element instanceof jQuery) {
  943. if (element.length > 1 && window.console && console.warn) {
  944. console.warn('A jQuery object with multiple elements was passed, using the first element.');
  945. }
  946. element = element[0];
  947. } // Find an element by ID
  948. if (typeof document !== 'undefined' && typeof element === 'string') {
  949. element = document.getElementById(element);
  950. } // Not an element!
  951. if (!isDomElement(element)) {
  952. throw new TypeError('You must pass either a valid element or a valid id.');
  953. } // Already initialized an embed in this div, so grab the iframe
  954. if (element.nodeName !== 'IFRAME') {
  955. var iframe = element.querySelector('iframe');
  956. if (iframe) {
  957. element = iframe;
  958. }
  959. } // iframe url is not a Vimeo url
  960. if (element.nodeName === 'IFRAME' && !isVimeoUrl(element.getAttribute('src') || '')) {
  961. throw new Error('The player element passed isn’t a Vimeo embed.');
  962. } // If there is already a player object in the map, return that
  963. if (playerMap.has(element)) {
  964. return playerMap.get(element);
  965. }
  966. this._window = element.ownerDocument.defaultView;
  967. this.element = element;
  968. this.origin = '*';
  969. var readyPromise = new npo_src(function (resolve, reject) {
  970. _this._onMessage = function (event) {
  971. if (!isVimeoUrl(event.origin) || _this.element.contentWindow !== event.source) {
  972. return;
  973. }
  974. if (_this.origin === '*') {
  975. _this.origin = event.origin;
  976. }
  977. var data = parseMessageData(event.data);
  978. var isError = data && data.event === 'error';
  979. var isReadyError = isError && data.data && data.data.method === 'ready';
  980. if (isReadyError) {
  981. var error = new Error(data.data.message);
  982. error.name = data.data.name;
  983. reject(error);
  984. return;
  985. }
  986. var isReadyEvent = data && data.event === 'ready';
  987. var isPingResponse = data && data.method === 'ping';
  988. if (isReadyEvent || isPingResponse) {
  989. _this.element.setAttribute('data-ready', 'true');
  990. resolve();
  991. return;
  992. }
  993. processData(_this, data);
  994. };
  995. _this._window.addEventListener('message', _this._onMessage);
  996. if (_this.element.nodeName !== 'IFRAME') {
  997. var params = getOEmbedParameters(element, options);
  998. var url = getVimeoUrl(params);
  999. getOEmbedData(url, params, element).then(function (data) {
  1000. var iframe = createEmbed(data, element); // Overwrite element with the new iframe,
  1001. // but store reference to the original element
  1002. _this.element = iframe;
  1003. _this._originalElement = element;
  1004. swapCallbacks(element, iframe);
  1005. playerMap.set(_this.element, _this);
  1006. return data;
  1007. }).catch(reject);
  1008. }
  1009. }); // Store a copy of this Player in the map
  1010. readyMap.set(this, readyPromise);
  1011. playerMap.set(this.element, this); // Send a ping to the iframe so the ready promise will be resolved if
  1012. // the player is already ready.
  1013. if (this.element.nodeName === 'IFRAME') {
  1014. postMessage(this, 'ping');
  1015. }
  1016. if (screenfull.isEnabled) {
  1017. var exitFullscreen = function exitFullscreen() {
  1018. return screenfull.exit();
  1019. };
  1020. this.fullscreenchangeHandler = function () {
  1021. if (screenfull.isFullscreen) {
  1022. storeCallback(_this, 'event:exitFullscreen', exitFullscreen);
  1023. } else {
  1024. removeCallback(_this, 'event:exitFullscreen', exitFullscreen);
  1025. } // eslint-disable-next-line
  1026. _this.ready().then(function () {
  1027. postMessage(_this, 'fullscreenchange', screenfull.isFullscreen);
  1028. });
  1029. };
  1030. screenfull.on('fullscreenchange', this.fullscreenchangeHandler);
  1031. }
  1032. return this;
  1033. }
  1034. /**
  1035. * Get a promise for a method.
  1036. *
  1037. * @param {string} name The API method to call.
  1038. * @param {Object} [args={}] Arguments to send via postMessage.
  1039. * @return {Promise}
  1040. */
  1041. _createClass(Player, [{
  1042. key: "callMethod",
  1043. value: function callMethod(name) {
  1044. var _this2 = this;
  1045. var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1046. return new npo_src(function (resolve, reject) {
  1047. // We are storing the resolve/reject handlers to call later, so we
  1048. // can’t return here.
  1049. // eslint-disable-next-line promise/always-return
  1050. return _this2.ready().then(function () {
  1051. storeCallback(_this2, name, {
  1052. resolve: resolve,
  1053. reject: reject
  1054. });
  1055. postMessage(_this2, name, args);
  1056. }).catch(reject);
  1057. });
  1058. }
  1059. /**
  1060. * Get a promise for the value of a player property.
  1061. *
  1062. * @param {string} name The property name
  1063. * @return {Promise}
  1064. */
  1065. }, {
  1066. key: "get",
  1067. value: function get(name) {
  1068. var _this3 = this;
  1069. return new npo_src(function (resolve, reject) {
  1070. name = getMethodName(name, 'get'); // We are storing the resolve/reject handlers to call later, so we
  1071. // can’t return here.
  1072. // eslint-disable-next-line promise/always-return
  1073. return _this3.ready().then(function () {
  1074. storeCallback(_this3, name, {
  1075. resolve: resolve,
  1076. reject: reject
  1077. });
  1078. postMessage(_this3, name);
  1079. }).catch(reject);
  1080. });
  1081. }
  1082. /**
  1083. * Get a promise for setting the value of a player property.
  1084. *
  1085. * @param {string} name The API method to call.
  1086. * @param {mixed} value The value to set.
  1087. * @return {Promise}
  1088. */
  1089. }, {
  1090. key: "set",
  1091. value: function set(name, value) {
  1092. var _this4 = this;
  1093. return new npo_src(function (resolve, reject) {
  1094. name = getMethodName(name, 'set');
  1095. if (value === undefined || value === null) {
  1096. throw new TypeError('There must be a value to set.');
  1097. } // We are storing the resolve/reject handlers to call later, so we
  1098. // can’t return here.
  1099. // eslint-disable-next-line promise/always-return
  1100. return _this4.ready().then(function () {
  1101. storeCallback(_this4, name, {
  1102. resolve: resolve,
  1103. reject: reject
  1104. });
  1105. postMessage(_this4, name, value);
  1106. }).catch(reject);
  1107. });
  1108. }
  1109. /**
  1110. * Add an event listener for the specified event. Will call the
  1111. * callback with a single parameter, `data`, that contains the data for
  1112. * that event.
  1113. *
  1114. * @param {string} eventName The name of the event.
  1115. * @param {function(*)} callback The function to call when the event fires.
  1116. * @return {void}
  1117. */
  1118. }, {
  1119. key: "on",
  1120. value: function on(eventName, callback) {
  1121. if (!eventName) {
  1122. throw new TypeError('You must pass an event name.');
  1123. }
  1124. if (!callback) {
  1125. throw new TypeError('You must pass a callback function.');
  1126. }
  1127. if (typeof callback !== 'function') {
  1128. throw new TypeError('The callback must be a function.');
  1129. }
  1130. var callbacks = getCallbacks(this, "event:".concat(eventName));
  1131. if (callbacks.length === 0) {
  1132. this.callMethod('addEventListener', eventName).catch(function () {// Ignore the error. There will be an error event fired that
  1133. // will trigger the error callback if they are listening.
  1134. });
  1135. }
  1136. storeCallback(this, "event:".concat(eventName), callback);
  1137. }
  1138. /**
  1139. * Remove an event listener for the specified event. Will remove all
  1140. * listeners for that event if a `callback` isn’t passed, or only that
  1141. * specific callback if it is passed.
  1142. *
  1143. * @param {string} eventName The name of the event.
  1144. * @param {function} [callback] The specific callback to remove.
  1145. * @return {void}
  1146. */
  1147. }, {
  1148. key: "off",
  1149. value: function off(eventName, callback) {
  1150. if (!eventName) {
  1151. throw new TypeError('You must pass an event name.');
  1152. }
  1153. if (callback && typeof callback !== 'function') {
  1154. throw new TypeError('The callback must be a function.');
  1155. }
  1156. var lastCallback = removeCallback(this, "event:".concat(eventName), callback); // If there are no callbacks left, remove the listener
  1157. if (lastCallback) {
  1158. this.callMethod('removeEventListener', eventName).catch(function (e) {// Ignore the error. There will be an error event fired that
  1159. // will trigger the error callback if they are listening.
  1160. });
  1161. }
  1162. }
  1163. /**
  1164. * A promise to load a new video.
  1165. *
  1166. * @promise LoadVideoPromise
  1167. * @fulfill {number} The video with this id or url successfully loaded.
  1168. * @reject {TypeError} The id was not a number.
  1169. */
  1170. /**
  1171. * Load a new video into this embed. The promise will be resolved if
  1172. * the video is successfully loaded, or it will be rejected if it could
  1173. * not be loaded.
  1174. *
  1175. * @param {number|string|object} options The id of the video, the url of the video, or an object with embed options.
  1176. * @return {LoadVideoPromise}
  1177. */
  1178. }, {
  1179. key: "loadVideo",
  1180. value: function loadVideo(options) {
  1181. return this.callMethod('loadVideo', options);
  1182. }
  1183. /**
  1184. * A promise to perform an action when the Player is ready.
  1185. *
  1186. * @todo document errors
  1187. * @promise LoadVideoPromise
  1188. * @fulfill {void}
  1189. */
  1190. /**
  1191. * Trigger a function when the player iframe has initialized. You do not
  1192. * need to wait for `ready` to trigger to begin adding event listeners
  1193. * or calling other methods.
  1194. *
  1195. * @return {ReadyPromise}
  1196. */
  1197. }, {
  1198. key: "ready",
  1199. value: function ready() {
  1200. var readyPromise = readyMap.get(this) || new npo_src(function (resolve, reject) {
  1201. reject(new Error('Unknown player. Probably unloaded.'));
  1202. });
  1203. return npo_src.resolve(readyPromise);
  1204. }
  1205. /**
  1206. * A promise to add a cue point to the player.
  1207. *
  1208. * @promise AddCuePointPromise
  1209. * @fulfill {string} The id of the cue point to use for removeCuePoint.
  1210. * @reject {RangeError} the time was less than 0 or greater than the
  1211. * video’s duration.
  1212. * @reject {UnsupportedError} Cue points are not supported with the current
  1213. * player or browser.
  1214. */
  1215. /**
  1216. * Add a cue point to the player.
  1217. *
  1218. * @param {number} time The time for the cue point.
  1219. * @param {object} [data] Arbitrary data to be returned with the cue point.
  1220. * @return {AddCuePointPromise}
  1221. */
  1222. }, {
  1223. key: "addCuePoint",
  1224. value: function addCuePoint(time) {
  1225. var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1226. return this.callMethod('addCuePoint', {
  1227. time: time,
  1228. data: data
  1229. });
  1230. }
  1231. /**
  1232. * A promise to remove a cue point from the player.
  1233. *
  1234. * @promise AddCuePointPromise
  1235. * @fulfill {string} The id of the cue point that was removed.
  1236. * @reject {InvalidCuePoint} The cue point with the specified id was not
  1237. * found.
  1238. * @reject {UnsupportedError} Cue points are not supported with the current
  1239. * player or browser.
  1240. */
  1241. /**
  1242. * Remove a cue point from the video.
  1243. *
  1244. * @param {string} id The id of the cue point to remove.
  1245. * @return {RemoveCuePointPromise}
  1246. */
  1247. }, {
  1248. key: "removeCuePoint",
  1249. value: function removeCuePoint(id) {
  1250. return this.callMethod('removeCuePoint', id);
  1251. }
  1252. /**
  1253. * A representation of a text track on a video.
  1254. *
  1255. * @typedef {Object} VimeoTextTrack
  1256. * @property {string} language The ISO language code.
  1257. * @property {string} kind The kind of track it is (captions or subtitles).
  1258. * @property {string} label The human‐readable label for the track.
  1259. */
  1260. /**
  1261. * A promise to enable a text track.
  1262. *
  1263. * @promise EnableTextTrackPromise
  1264. * @fulfill {VimeoTextTrack} The text track that was enabled.
  1265. * @reject {InvalidTrackLanguageError} No track was available with the
  1266. * specified language.
  1267. * @reject {InvalidTrackError} No track was available with the specified
  1268. * language and kind.
  1269. */
  1270. /**
  1271. * Enable the text track with the specified language, and optionally the
  1272. * specified kind (captions or subtitles).
  1273. *
  1274. * When set via the API, the track language will not change the viewer’s
  1275. * stored preference.
  1276. *
  1277. * @param {string} language The two‐letter language code.
  1278. * @param {string} [kind] The kind of track to enable (captions or subtitles).
  1279. * @return {EnableTextTrackPromise}
  1280. */
  1281. }, {
  1282. key: "enableTextTrack",
  1283. value: function enableTextTrack(language, kind) {
  1284. if (!language) {
  1285. throw new TypeError('You must pass a language.');
  1286. }
  1287. return this.callMethod('enableTextTrack', {
  1288. language: language,
  1289. kind: kind
  1290. });
  1291. }
  1292. /**
  1293. * A promise to disable the active text track.
  1294. *
  1295. * @promise DisableTextTrackPromise
  1296. * @fulfill {void} The track was disabled.
  1297. */
  1298. /**
  1299. * Disable the currently-active text track.
  1300. *
  1301. * @return {DisableTextTrackPromise}
  1302. */
  1303. }, {
  1304. key: "disableTextTrack",
  1305. value: function disableTextTrack() {
  1306. return this.callMethod('disableTextTrack');
  1307. }
  1308. /**
  1309. * A promise to pause the video.
  1310. *
  1311. * @promise PausePromise
  1312. * @fulfill {void} The video was paused.
  1313. */
  1314. /**
  1315. * Pause the video if it’s playing.
  1316. *
  1317. * @return {PausePromise}
  1318. */
  1319. }, {
  1320. key: "pause",
  1321. value: function pause() {
  1322. return this.callMethod('pause');
  1323. }
  1324. /**
  1325. * A promise to play the video.
  1326. *
  1327. * @promise PlayPromise
  1328. * @fulfill {void} The video was played.
  1329. */
  1330. /**
  1331. * Play the video if it’s paused. **Note:** on iOS and some other
  1332. * mobile devices, you cannot programmatically trigger play. Once the
  1333. * viewer has tapped on the play button in the player, however, you
  1334. * will be able to use this function.
  1335. *
  1336. * @return {PlayPromise}
  1337. */
  1338. }, {
  1339. key: "play",
  1340. value: function play() {
  1341. return this.callMethod('play');
  1342. }
  1343. /**
  1344. * Request that the player enters fullscreen.
  1345. * @return {Promise}
  1346. */
  1347. }, {
  1348. key: "requestFullscreen",
  1349. value: function requestFullscreen() {
  1350. if (screenfull.isEnabled) {
  1351. return screenfull.request(this.element);
  1352. }
  1353. return this.callMethod('requestFullscreen');
  1354. }
  1355. /**
  1356. * Request that the player exits fullscreen.
  1357. * @return {Promise}
  1358. */
  1359. }, {
  1360. key: "exitFullscreen",
  1361. value: function exitFullscreen() {
  1362. if (screenfull.isEnabled) {
  1363. return screenfull.exit();
  1364. }
  1365. return this.callMethod('exitFullscreen');
  1366. }
  1367. /**
  1368. * Returns true if the player is currently fullscreen.
  1369. * @return {Promise}
  1370. */
  1371. }, {
  1372. key: "getFullscreen",
  1373. value: function getFullscreen() {
  1374. if (screenfull.isEnabled) {
  1375. return npo_src.resolve(screenfull.isFullscreen);
  1376. }
  1377. return this.get('fullscreen');
  1378. }
  1379. /**
  1380. * Request that the player enters picture-in-picture.
  1381. * @return {Promise}
  1382. */
  1383. }, {
  1384. key: "requestPictureInPicture",
  1385. value: function requestPictureInPicture() {
  1386. return this.callMethod('requestPictureInPicture');
  1387. }
  1388. /**
  1389. * Request that the player exits picture-in-picture.
  1390. * @return {Promise}
  1391. */
  1392. }, {
  1393. key: "exitPictureInPicture",
  1394. value: function exitPictureInPicture() {
  1395. return this.callMethod('exitPictureInPicture');
  1396. }
  1397. /**
  1398. * Returns true if the player is currently picture-in-picture.
  1399. * @return {Promise}
  1400. */
  1401. }, {
  1402. key: "getPictureInPicture",
  1403. value: function getPictureInPicture() {
  1404. return this.get('pictureInPicture');
  1405. }
  1406. /**
  1407. * A promise to unload the video.
  1408. *
  1409. * @promise UnloadPromise
  1410. * @fulfill {void} The video was unloaded.
  1411. */
  1412. /**
  1413. * Return the player to its initial state.
  1414. *
  1415. * @return {UnloadPromise}
  1416. */
  1417. }, {
  1418. key: "unload",
  1419. value: function unload() {
  1420. return this.callMethod('unload');
  1421. }
  1422. /**
  1423. * Cleanup the player and remove it from the DOM
  1424. *
  1425. * It won't be usable and a new one should be constructed
  1426. * in order to do any operations.
  1427. *
  1428. * @return {Promise}
  1429. */
  1430. }, {
  1431. key: "destroy",
  1432. value: function destroy() {
  1433. var _this5 = this;
  1434. return new npo_src(function (resolve) {
  1435. readyMap.delete(_this5);
  1436. playerMap.delete(_this5.element);
  1437. if (_this5._originalElement) {
  1438. playerMap.delete(_this5._originalElement);
  1439. _this5._originalElement.removeAttribute('data-vimeo-initialized');
  1440. }
  1441. if (_this5.element && _this5.element.nodeName === 'IFRAME' && _this5.element.parentNode) {
  1442. // If we've added an additional wrapper div, remove that from the DOM.
  1443. // If not, just remove the iframe element.
  1444. if (_this5.element.parentNode.parentNode && _this5._originalElement && _this5._originalElement !== _this5.element.parentNode) {
  1445. _this5.element.parentNode.parentNode.removeChild(_this5.element.parentNode);
  1446. } else {
  1447. _this5.element.parentNode.removeChild(_this5.element);
  1448. }
  1449. } // If the clip is private there is a case where the element stays the
  1450. // div element. Destroy should reset the div and remove the iframe child.
  1451. if (_this5.element && _this5.element.nodeName === 'DIV' && _this5.element.parentNode) {
  1452. _this5.element.removeAttribute('data-vimeo-initialized');
  1453. var iframe = _this5.element.querySelector('iframe');
  1454. if (iframe && iframe.parentNode) {
  1455. // If we've added an additional wrapper div, remove that from the DOM.
  1456. // If not, just remove the iframe element.
  1457. if (iframe.parentNode.parentNode && _this5._originalElement && _this5._originalElement !== iframe.parentNode) {
  1458. iframe.parentNode.parentNode.removeChild(iframe.parentNode);
  1459. } else {
  1460. iframe.parentNode.removeChild(iframe);
  1461. }
  1462. }
  1463. }
  1464. _this5._window.removeEventListener('message', _this5._onMessage);
  1465. if (screenfull.isEnabled) {
  1466. screenfull.off('fullscreenchange', _this5.fullscreenchangeHandler);
  1467. }
  1468. resolve();
  1469. });
  1470. }
  1471. /**
  1472. * A promise to get the autopause behavior of the video.
  1473. *
  1474. * @promise GetAutopausePromise
  1475. * @fulfill {boolean} Whether autopause is turned on or off.
  1476. * @reject {UnsupportedError} Autopause is not supported with the current
  1477. * player or browser.
  1478. */
  1479. /**
  1480. * Get the autopause behavior for this player.
  1481. *
  1482. * @return {GetAutopausePromise}
  1483. */
  1484. }, {
  1485. key: "getAutopause",
  1486. value: function getAutopause() {
  1487. return this.get('autopause');
  1488. }
  1489. /**
  1490. * A promise to set the autopause behavior of the video.
  1491. *
  1492. * @promise SetAutopausePromise
  1493. * @fulfill {boolean} Whether autopause is turned on or off.
  1494. * @reject {UnsupportedError} Autopause is not supported with the current
  1495. * player or browser.
  1496. */
  1497. /**
  1498. * Enable or disable the autopause behavior of this player.
  1499. *
  1500. * By default, when another video is played in the same browser, this
  1501. * player will automatically pause. Unless you have a specific reason
  1502. * for doing so, we recommend that you leave autopause set to the
  1503. * default (`true`).
  1504. *
  1505. * @param {boolean} autopause
  1506. * @return {SetAutopausePromise}
  1507. */
  1508. }, {
  1509. key: "setAutopause",
  1510. value: function setAutopause(autopause) {
  1511. return this.set('autopause', autopause);
  1512. }
  1513. /**
  1514. * A promise to get the buffered property of the video.
  1515. *
  1516. * @promise GetBufferedPromise
  1517. * @fulfill {Array} Buffered Timeranges converted to an Array.
  1518. */
  1519. /**
  1520. * Get the buffered property of the video.
  1521. *
  1522. * @return {GetBufferedPromise}
  1523. */
  1524. }, {
  1525. key: "getBuffered",
  1526. value: function getBuffered() {
  1527. return this.get('buffered');
  1528. }
  1529. /**
  1530. * @typedef {Object} CameraProperties
  1531. * @prop {number} props.yaw - Number between 0 and 360.
  1532. * @prop {number} props.pitch - Number between -90 and 90.
  1533. * @prop {number} props.roll - Number between -180 and 180.
  1534. * @prop {number} props.fov - The field of view in degrees.
  1535. */
  1536. /**
  1537. * A promise to get the camera properties of the player.
  1538. *
  1539. * @promise GetCameraPromise
  1540. * @fulfill {CameraProperties} The camera properties.
  1541. */
  1542. /**
  1543. * For 360° videos get the camera properties for this player.
  1544. *
  1545. * @return {GetCameraPromise}
  1546. */
  1547. }, {
  1548. key: "getCameraProps",
  1549. value: function getCameraProps() {
  1550. return this.get('cameraProps');
  1551. }
  1552. /**
  1553. * A promise to set the camera properties of the player.
  1554. *
  1555. * @promise SetCameraPromise
  1556. * @fulfill {Object} The camera was successfully set.
  1557. * @reject {RangeError} The range was out of bounds.
  1558. */
  1559. /**
  1560. * For 360° videos set the camera properties for this player.
  1561. *
  1562. * @param {CameraProperties} camera The camera properties
  1563. * @return {SetCameraPromise}
  1564. */
  1565. }, {
  1566. key: "setCameraProps",
  1567. value: function setCameraProps(camera) {
  1568. return this.set('cameraProps', camera);
  1569. }
  1570. /**
  1571. * A representation of a chapter.
  1572. *
  1573. * @typedef {Object} VimeoChapter
  1574. * @property {number} startTime The start time of the chapter.
  1575. * @property {object} title The title of the chapter.
  1576. * @property {number} index The place in the order of Chapters. Starts at 1.
  1577. */
  1578. /**
  1579. * A promise to get chapters for the video.
  1580. *
  1581. * @promise GetChaptersPromise
  1582. * @fulfill {VimeoChapter[]} The chapters for the video.
  1583. */
  1584. /**
  1585. * Get an array of all the chapters for the video.
  1586. *
  1587. * @return {GetChaptersPromise}
  1588. */
  1589. }, {
  1590. key: "getChapters",
  1591. value: function getChapters() {
  1592. return this.get('chapters');
  1593. }
  1594. /**
  1595. * A promise to get the currently active chapter.
  1596. *
  1597. * @promise GetCurrentChaptersPromise
  1598. * @fulfill {VimeoChapter|undefined} The current chapter for the video.
  1599. */
  1600. /**
  1601. * Get the currently active chapter for the video.
  1602. *
  1603. * @return {GetCurrentChaptersPromise}
  1604. */
  1605. }, {
  1606. key: "getCurrentChapter",
  1607. value: function getCurrentChapter() {
  1608. return this.get('currentChapter');
  1609. }
  1610. /**
  1611. * A promise to get the color of the player.
  1612. *
  1613. * @promise GetColorPromise
  1614. * @fulfill {string} The hex color of the player.
  1615. */
  1616. /**
  1617. * Get the color for this player.
  1618. *
  1619. * @return {GetColorPromise}
  1620. */
  1621. }, {
  1622. key: "getColor",
  1623. value: function getColor() {
  1624. return this.get('color');
  1625. }
  1626. /**
  1627. * A promise to set the color of the player.
  1628. *
  1629. * @promise SetColorPromise
  1630. * @fulfill {string} The color was successfully set.
  1631. * @reject {TypeError} The string was not a valid hex or rgb color.
  1632. * @reject {ContrastError} The color was set, but the contrast is
  1633. * outside of the acceptable range.
  1634. * @reject {EmbedSettingsError} The owner of the player has chosen to
  1635. * use a specific color.
  1636. */
  1637. /**
  1638. * Set the color of this player to a hex or rgb string. Setting the
  1639. * color may fail if the owner of the video has set their embed
  1640. * preferences to force a specific color.
  1641. *
  1642. * @param {string} color The hex or rgb color string to set.
  1643. * @return {SetColorPromise}
  1644. */
  1645. }, {
  1646. key: "setColor",
  1647. value: function setColor(color) {
  1648. return this.set('color', color);
  1649. }
  1650. /**
  1651. * A representation of a cue point.
  1652. *
  1653. * @typedef {Object} VimeoCuePoint
  1654. * @property {number} time The time of the cue point.
  1655. * @property {object} data The data passed when adding the cue point.
  1656. * @property {string} id The unique id for use with removeCuePoint.
  1657. */
  1658. /**
  1659. * A promise to get the cue points of a video.
  1660. *
  1661. * @promise GetCuePointsPromise
  1662. * @fulfill {VimeoCuePoint[]} The cue points added to the video.
  1663. * @reject {UnsupportedError} Cue points are not supported with the current
  1664. * player or browser.
  1665. */
  1666. /**
  1667. * Get an array of the cue points added to the video.
  1668. *
  1669. * @return {GetCuePointsPromise}
  1670. */
  1671. }, {
  1672. key: "getCuePoints",
  1673. value: function getCuePoints() {
  1674. return this.get('cuePoints');
  1675. }
  1676. /**
  1677. * A promise to get the current time of the video.
  1678. *
  1679. * @promise GetCurrentTimePromise
  1680. * @fulfill {number} The current time in seconds.
  1681. */
  1682. /**
  1683. * Get the current playback position in seconds.
  1684. *
  1685. * @return {GetCurrentTimePromise}
  1686. */
  1687. }, {
  1688. key: "getCurrentTime",
  1689. value: function getCurrentTime() {
  1690. return this.get('currentTime');
  1691. }
  1692. /**
  1693. * A promise to set the current time of the video.
  1694. *
  1695. * @promise SetCurrentTimePromise
  1696. * @fulfill {number} The actual current time that was set.
  1697. * @reject {RangeError} the time was less than 0 or greater than the
  1698. * video’s duration.
  1699. */
  1700. /**
  1701. * Set the current playback position in seconds. If the player was
  1702. * paused, it will remain paused. Likewise, if the player was playing,
  1703. * it will resume playing once the video has buffered.
  1704. *
  1705. * You can provide an accurate time and the player will attempt to seek
  1706. * to as close to that time as possible. The exact time will be the
  1707. * fulfilled value of the promise.
  1708. *
  1709. * @param {number} currentTime
  1710. * @return {SetCurrentTimePromise}
  1711. */
  1712. }, {
  1713. key: "setCurrentTime",
  1714. value: function setCurrentTime(currentTime) {
  1715. return this.set('currentTime', currentTime);
  1716. }
  1717. /**
  1718. * A promise to get the duration of the video.
  1719. *
  1720. * @promise GetDurationPromise
  1721. * @fulfill {number} The duration in seconds.
  1722. */
  1723. /**
  1724. * Get the duration of the video in seconds. It will be rounded to the
  1725. * nearest second before playback begins, and to the nearest thousandth
  1726. * of a second after playback begins.
  1727. *
  1728. * @return {GetDurationPromise}
  1729. */
  1730. }, {
  1731. key: "getDuration",
  1732. value: function getDuration() {
  1733. return this.get('duration');
  1734. }
  1735. /**
  1736. * A promise to get the ended state of the video.
  1737. *
  1738. * @promise GetEndedPromise
  1739. * @fulfill {boolean} Whether or not the video has ended.
  1740. */
  1741. /**
  1742. * Get the ended state of the video. The video has ended if
  1743. * `currentTime === duration`.
  1744. *
  1745. * @return {GetEndedPromise}
  1746. */
  1747. }, {
  1748. key: "getEnded",
  1749. value: function getEnded() {
  1750. return this.get('ended');
  1751. }
  1752. /**
  1753. * A promise to get the loop state of the player.
  1754. *
  1755. * @promise GetLoopPromise
  1756. * @fulfill {boolean} Whether or not the player is set to loop.
  1757. */
  1758. /**
  1759. * Get the loop state of the player.
  1760. *
  1761. * @return {GetLoopPromise}
  1762. */
  1763. }, {
  1764. key: "getLoop",
  1765. value: function getLoop() {
  1766. return this.get('loop');
  1767. }
  1768. /**
  1769. * A promise to set the loop state of the player.
  1770. *
  1771. * @promise SetLoopPromise
  1772. * @fulfill {boolean} The loop state that was set.
  1773. */
  1774. /**
  1775. * Set the loop state of the player. When set to `true`, the player
  1776. * will start over immediately once playback ends.
  1777. *
  1778. * @param {boolean} loop
  1779. * @return {SetLoopPromise}
  1780. */
  1781. }, {
  1782. key: "setLoop",
  1783. value: function setLoop(loop) {
  1784. return this.set('loop', loop);
  1785. }
  1786. /**
  1787. * A promise to set the muted state of the player.
  1788. *
  1789. * @promise SetMutedPromise
  1790. * @fulfill {boolean} The muted state that was set.
  1791. */
  1792. /**
  1793. * Set the muted state of the player. When set to `true`, the player
  1794. * volume will be muted.
  1795. *
  1796. * @param {boolean} muted
  1797. * @return {SetMutedPromise}
  1798. */
  1799. }, {
  1800. key: "setMuted",
  1801. value: function setMuted(muted) {
  1802. return this.set('muted', muted);
  1803. }
  1804. /**
  1805. * A promise to get the muted state of the player.
  1806. *
  1807. * @promise GetMutedPromise
  1808. * @fulfill {boolean} Whether or not the player is muted.
  1809. */
  1810. /**
  1811. * Get the muted state of the player.
  1812. *
  1813. * @return {GetMutedPromise}
  1814. */
  1815. }, {
  1816. key: "getMuted",
  1817. value: function getMuted() {
  1818. return this.get('muted');
  1819. }
  1820. /**
  1821. * A promise to get the paused state of the player.
  1822. *
  1823. * @promise GetLoopPromise
  1824. * @fulfill {boolean} Whether or not the video is paused.
  1825. */
  1826. /**
  1827. * Get the paused state of the player.
  1828. *
  1829. * @return {GetLoopPromise}
  1830. */
  1831. }, {
  1832. key: "getPaused",
  1833. value: function getPaused() {
  1834. return this.get('paused');
  1835. }
  1836. /**
  1837. * A promise to get the playback rate of the player.
  1838. *
  1839. * @promise GetPlaybackRatePromise
  1840. * @fulfill {number} The playback rate of the player on a scale from 0.5 to 2.
  1841. */
  1842. /**
  1843. * Get the playback rate of the player on a scale from `0.5` to `2`.
  1844. *
  1845. * @return {GetPlaybackRatePromise}
  1846. */
  1847. }, {
  1848. key: "getPlaybackRate",
  1849. value: function getPlaybackRate() {
  1850. return this.get('playbackRate');
  1851. }
  1852. /**
  1853. * A promise to set the playbackrate of the player.
  1854. *
  1855. * @promise SetPlaybackRatePromise
  1856. * @fulfill {number} The playback rate was set.
  1857. * @reject {RangeError} The playback rate was less than 0.5 or greater than 2.
  1858. */
  1859. /**
  1860. * Set the playback rate of the player on a scale from `0.5` to `2`. When set
  1861. * via the API, the playback rate will not be synchronized to other
  1862. * players or stored as the viewer's preference.
  1863. *
  1864. * @param {number} playbackRate
  1865. * @return {SetPlaybackRatePromise}
  1866. */
  1867. }, {
  1868. key: "setPlaybackRate",
  1869. value: function setPlaybackRate(playbackRate) {
  1870. return this.set('playbackRate', playbackRate);
  1871. }
  1872. /**
  1873. * A promise to get the played property of the video.
  1874. *
  1875. * @promise GetPlayedPromise
  1876. * @fulfill {Array} Played Timeranges converted to an Array.
  1877. */
  1878. /**
  1879. * Get the played property of the video.
  1880. *
  1881. * @return {GetPlayedPromise}
  1882. */
  1883. }, {
  1884. key: "getPlayed",
  1885. value: function getPlayed() {
  1886. return this.get('played');
  1887. }
  1888. /**
  1889. * A promise to get the qualities available of the current video.
  1890. *
  1891. * @promise GetQualitiesPromise
  1892. * @fulfill {Array} The qualities of the video.
  1893. */
  1894. /**
  1895. * Get the qualities of the current video.
  1896. *
  1897. * @return {GetQualitiesPromise}
  1898. */
  1899. }, {
  1900. key: "getQualities",
  1901. value: function getQualities() {
  1902. return this.get('qualities');
  1903. }
  1904. /**
  1905. * A promise to get the current set quality of the video.
  1906. *
  1907. * @promise GetQualityPromise
  1908. * @fulfill {string} The current set quality.
  1909. */
  1910. /**
  1911. * Get the current set quality of the video.
  1912. *
  1913. * @return {GetQualityPromise}
  1914. */
  1915. }, {
  1916. key: "getQuality",
  1917. value: function getQuality() {
  1918. return this.get('quality');
  1919. }
  1920. /**
  1921. * A promise to set the video quality.
  1922. *
  1923. * @promise SetQualityPromise
  1924. * @fulfill {number} The quality was set.
  1925. * @reject {RangeError} The quality is not available.
  1926. */
  1927. /**
  1928. * Set a video quality.
  1929. *
  1930. * @param {string} quality
  1931. * @return {SetQualityPromise}
  1932. */
  1933. }, {
  1934. key: "setQuality",
  1935. value: function setQuality(quality) {
  1936. return this.set('quality', quality);
  1937. }
  1938. /**
  1939. * A promise to get the seekable property of the video.
  1940. *
  1941. * @promise GetSeekablePromise
  1942. * @fulfill {Array} Seekable Timeranges converted to an Array.
  1943. */
  1944. /**
  1945. * Get the seekable property of the video.
  1946. *
  1947. * @return {GetSeekablePromise}
  1948. */
  1949. }, {
  1950. key: "getSeekable",
  1951. value: function getSeekable() {
  1952. return this.get('seekable');
  1953. }
  1954. /**
  1955. * A promise to get the seeking property of the player.
  1956. *
  1957. * @promise GetSeekingPromise
  1958. * @fulfill {boolean} Whether or not the player is currently seeking.
  1959. */
  1960. /**
  1961. * Get if the player is currently seeking.
  1962. *
  1963. * @return {GetSeekingPromise}
  1964. */
  1965. }, {
  1966. key: "getSeeking",
  1967. value: function getSeeking() {
  1968. return this.get('seeking');
  1969. }
  1970. /**
  1971. * A promise to get the text tracks of a video.
  1972. *
  1973. * @promise GetTextTracksPromise
  1974. * @fulfill {VimeoTextTrack[]} The text tracks associated with the video.
  1975. */
  1976. /**
  1977. * Get an array of the text tracks that exist for the video.
  1978. *
  1979. * @return {GetTextTracksPromise}
  1980. */
  1981. }, {
  1982. key: "getTextTracks",
  1983. value: function getTextTracks() {
  1984. return this.get('textTracks');
  1985. }
  1986. /**
  1987. * A promise to get the embed code for the video.
  1988. *
  1989. * @promise GetVideoEmbedCodePromise
  1990. * @fulfill {string} The `<iframe>` embed code for the video.
  1991. */
  1992. /**
  1993. * Get the `<iframe>` embed code for the video.
  1994. *
  1995. * @return {GetVideoEmbedCodePromise}
  1996. */
  1997. }, {
  1998. key: "getVideoEmbedCode",
  1999. value: function getVideoEmbedCode() {
  2000. return this.get('videoEmbedCode');
  2001. }
  2002. /**
  2003. * A promise to get the id of the video.
  2004. *
  2005. * @promise GetVideoIdPromise
  2006. * @fulfill {number} The id of the video.
  2007. */
  2008. /**
  2009. * Get the id of the video.
  2010. *
  2011. * @return {GetVideoIdPromise}
  2012. */
  2013. }, {
  2014. key: "getVideoId",
  2015. value: function getVideoId() {
  2016. return this.get('videoId');
  2017. }
  2018. /**
  2019. * A promise to get the title of the video.
  2020. *
  2021. * @promise GetVideoTitlePromise
  2022. * @fulfill {number} The title of the video.
  2023. */
  2024. /**
  2025. * Get the title of the video.
  2026. *
  2027. * @return {GetVideoTitlePromise}
  2028. */
  2029. }, {
  2030. key: "getVideoTitle",
  2031. value: function getVideoTitle() {
  2032. return this.get('videoTitle');
  2033. }
  2034. /**
  2035. * A promise to get the native width of the video.
  2036. *
  2037. * @promise GetVideoWidthPromise
  2038. * @fulfill {number} The native width of the video.
  2039. */
  2040. /**
  2041. * Get the native width of the currently‐playing video. The width of
  2042. * the highest‐resolution available will be used before playback begins.
  2043. *
  2044. * @return {GetVideoWidthPromise}
  2045. */
  2046. }, {
  2047. key: "getVideoWidth",
  2048. value: function getVideoWidth() {
  2049. return this.get('videoWidth');
  2050. }
  2051. /**
  2052. * A promise to get the native height of the video.
  2053. *
  2054. * @promise GetVideoHeightPromise
  2055. * @fulfill {number} The native height of the video.
  2056. */
  2057. /**
  2058. * Get the native height of the currently‐playing video. The height of
  2059. * the highest‐resolution available will be used before playback begins.
  2060. *
  2061. * @return {GetVideoHeightPromise}
  2062. */
  2063. }, {
  2064. key: "getVideoHeight",
  2065. value: function getVideoHeight() {
  2066. return this.get('videoHeight');
  2067. }
  2068. /**
  2069. * A promise to get the vimeo.com url for the video.
  2070. *
  2071. * @promise GetVideoUrlPromise
  2072. * @fulfill {number} The vimeo.com url for the video.
  2073. * @reject {PrivacyError} The url isn’t available because of the video’s privacy setting.
  2074. */
  2075. /**
  2076. * Get the vimeo.com url for the video.
  2077. *
  2078. * @return {GetVideoUrlPromise}
  2079. */
  2080. }, {
  2081. key: "getVideoUrl",
  2082. value: function getVideoUrl() {
  2083. return this.get('videoUrl');
  2084. }
  2085. /**
  2086. * A promise to get the volume level of the player.
  2087. *
  2088. * @promise GetVolumePromise
  2089. * @fulfill {number} The volume level of the player on a scale from 0 to 1.
  2090. */
  2091. /**
  2092. * Get the current volume level of the player on a scale from `0` to `1`.
  2093. *
  2094. * Most mobile devices do not support an independent volume from the
  2095. * system volume. In those cases, this method will always return `1`.
  2096. *
  2097. * @return {GetVolumePromise}
  2098. */
  2099. }, {
  2100. key: "getVolume",
  2101. value: function getVolume() {
  2102. return this.get('volume');
  2103. }
  2104. /**
  2105. * A promise to set the volume level of the player.
  2106. *
  2107. * @promise SetVolumePromise
  2108. * @fulfill {number} The volume was set.
  2109. * @reject {RangeError} The volume was less than 0 or greater than 1.
  2110. */
  2111. /**
  2112. * Set the volume of the player on a scale from `0` to `1`. When set
  2113. * via the API, the volume level will not be synchronized to other
  2114. * players or stored as the viewer’s preference.
  2115. *
  2116. * Most mobile devices do not support setting the volume. An error will
  2117. * *not* be triggered in that situation.
  2118. *
  2119. * @param {number} volume
  2120. * @return {SetVolumePromise}
  2121. */
  2122. }, {
  2123. key: "setVolume",
  2124. value: function setVolume(volume) {
  2125. return this.set('volume', volume);
  2126. }
  2127. }]);
  2128. return Player;
  2129. }(); // Setup embed only if this is not a node environment
  2130. if (!isNode) {
  2131. screenfull = initializeScreenfull();
  2132. initializeEmbeds();
  2133. resizeEmbeds();
  2134. }
  2135. return Player;
  2136. })));
  2137. //# sourceMappingURL=player.js.map