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