vendor: 9,305 bytes, lines 1-359
1/** 2 * videojs-flash 3 * @version 2.1.2 4 * @copyright 2018 Brightcove, Inc. 5 * @license Apache-2.0 6 */ 7(function (global, factory) { 8 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('video.js')) : 9 typeof define === 'function' && define.amd ? define(['video.js'], factory) : 10 (global.videojsFlash = factory(global.videojs)); 11}(this, (function (videojs) { 'use strict'; 12 13videojs = videojs && videojs.hasOwnProperty('default') ? videojs['default'] : videojs; 14 15var version = "5.4.2"; 16 17var version$1 = "2.1.2"; 18 19/** 20 * @file flash-rtmp.js 21 * @module flash-rtmp 22 */ 23 24/** 25 * Add RTMP properties to the {@link Flash} Tech. 26 * 27 * @param {Flash} Flash 28 * The flash tech class. 29 * 30 * @mixin FlashRtmpDecorator 31 * 32 * @return {Flash} 33 * The flash tech with RTMP properties added. 34 */ 35function FlashRtmpDecorator(Flash) { 36 Flash.streamingFormats = { 37 'rtmp/mp4': 'MP4', 38 'rtmp/flv': 'FLV' 39 }; 40 41 /** 42 * Join connection and stream with an ampersand. 43 * 44 * @param {string} connection 45 * The connection string. 46 * 47 * @param {string} stream 48 * The stream string. 49 * 50 * @return {string} 51 * The connection and stream joined with an `&` character 52 */ 53 Flash.streamFromParts = function (connection, stream) { 54 return connection + '&' + stream; 55 }; 56 57 /** 58 * The flash parts object that contains connection and stream info. 59 * 60 * @typedef {Object} Flash~PartsObject 61 * 62 * @property {string} connection 63 * The connection string of a source, defaults to an empty string. 64 * 65 * @property {string} stream 66 * The stream string of the source, defaults to an empty string. 67 */ 68 69 /** 70 * Convert a source url into a stream and connection parts. 71 * 72 * @param {string} src 73 * the source url 74 * 75 * @return {Flash~PartsObject} 76 * The parts object that contains a connection and a stream 77 */ 78 Flash.streamToParts = function (src) { 79 var parts = { 80 connection: '', 81 stream: '' 82 }; 83 84 if (!src) { 85 return parts; 86 } 87 88 // Look for the normal URL separator we expect, '&'. 89 // If found, we split the URL into two pieces around the 90 // first '&'. 91 var connEnd = src.search(/&(?![\w-]+=)/); 92 var streamBegin = void 0; 93 94 if (connEnd !== -1) { 95 streamBegin = connEnd + 1; 96 } else { 97 // If there's not a '&', we use the last '/' as the delimiter. 98 connEnd = streamBegin = src.lastIndexOf('/') + 1; 99 if (connEnd === 0) { 100 // really, there's not a '/'? 101 connEnd = streamBegin = src.length; 102 } 103 } 104 105 parts.connection = src.substring(0, connEnd); 106 parts.stream = src.substring(streamBegin, src.length); 107 108 return parts; 109 }; 110 111 /** 112 * Check if the source type is a streaming type. 113 * 114 * @param {string} srcType 115 * The mime type to check. 116 * 117 * @return {boolean} 118 * - True if the source type is a streaming type. 119 * - False if the source type is not a streaming type. 120 */ 121 Flash.isStreamingType = function (srcType) { 122 return srcType in Flash.streamingFormats; 123 }; 124 125 // RTMP has four variations, any string starting 126 // with one of these protocols should be valid 127 128 /** 129 * Regular expression used to check if the source is an rtmp source. 130 * 131 * @property {RegExp} Flash.RTMP_RE 132 */ 133 Flash.RTMP_RE = /^rtmp[set]?:\/\//i; 134 135 /** 136 * Check if the source itself is a streaming type. 137 * 138 * @param {string} src 139 * The url to the source. 140 * 141 * @return {boolean} 142 * - True if the source url indicates that the source is streaming. 143 * - False if the shource url indicates that the source url is not streaming. 144 */ 145 Flash.isStreamingSrc = function (src) { 146 return Flash.RTMP_RE.test(src); 147 }; 148 149 /** 150 * A source handler for RTMP urls 151 * @type {Object} 152 */ 153 Flash.rtmpSourceHandler = {}; 154 155 /** 156 * Check if Flash can play the given mime type. 157 * 158 * @param {string} type 159 * The mime type to check 160 * 161 * @return {string} 162 * 'maybe', or '' (empty string) 163 */ 164 Flash.rtmpSourceHandler.canPlayType = function (type) { 165 if (Flash.isStreamingType(type)) { 166 return 'maybe'; 167 } 168 169 return ''; 170 }; 171 172 /** 173 * Check if Flash can handle the source natively 174 * 175 * @param {Object} source 176 * The source object 177 * 178 * @param {Object} [options] 179 * The options passed to the tech 180 * 181 * @return {string} 182 * 'maybe', or '' (empty string) 183 */ 184 Flash.rtmpSourceHandler.canHandleSource = function (source, options) { 185 var can = Flash.rtmpSourceHandler.canPlayType(source.type); 186 187 if (can) { 188 return can; 189 } 190 191 if (Flash.isStreamingSrc(source.src)) { 192 return 'maybe'; 193 } 194 195 return ''; 196 }; 197 198 /** 199 * Pass the source to the flash object. 200 * 201 * @param {Object} source 202 * The source object 203 * 204 * @param {Flash} tech 205 * The instance of the Flash tech 206 * 207 * @param {Object} [options] 208 * The options to pass to the source 209 */ 210 Flash.rtmpSourceHandler.handleSource = function (source, tech, options) { 211 var srcParts = Flash.streamToParts(source.src); 212 213 tech.setRtmpConnection(srcParts.connection); 214 tech.setRtmpStream(srcParts.stream); 215 }; 216 217 // Register the native source handler 218 Flash.registerSourceHandler(Flash.rtmpSourceHandler); 219 220 return Flash; 221} 222 223var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; 224 225var win; 226 227if (typeof window !== "undefined") { 228 win = window; 229} else if (typeof commonjsGlobal !== "undefined") { 230 win = commonjsGlobal; 231} else if (typeof self !== "undefined"){ 232 win = self; 233} else { 234 win = {}; 235} 236 237var window_1 = win; 238 239var classCallCheck = function (instance, Constructor) { 240 if (!(instance instanceof Constructor)) { 241 throw new TypeError("Cannot call a class as a function"); 242 } 243}; 244 245 246 247 248 249 250 251 252 253 254 255var inherits = function (subClass, superClass) { 256 if (typeof superClass !== "function" && superClass !== null) { 257 throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); 258 } 259 260 subClass.prototype = Object.create(superClass && superClass.prototype, { 261 constructor: { 262 value: subClass, 263 enumerable: false, 264 writable: true, 265 configurable: true 266 } 267 }); 268 if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; 269}; 270 271 272 273 274 275 276 277 278 279 280 281var possibleConstructorReturn = function (self, call) { 282 if (!self) { 283 throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); 284 } 285 286 return call && (typeof call === "object" || typeof call === "function") ? call : self; 287}; 288 289/** 290 * @file flash.js 291 * VideoJS-SWF - Custom Flash Player with HTML5-ish API 292 * https://github.com/zencoder/video-js-swf 293 * Not using setupTriggers. Using global onEvent func to distribute events 294 */ 295 296var Tech = videojs.getComponent('Tech'); 297var Dom = videojs.dom; 298var Url = videojs.url; 299var createTimeRange = videojs.createTimeRange; 300var mergeOptions = videojs.mergeOptions; 301 302var navigator = window_1 && window_1.navigator || {}; 303 304/** 305 * Flash Media Controller - Wrapper for Flash Media API 306 * 307 * @mixes FlashRtmpDecorator 308 * @mixes Tech~SouceHandlerAdditions 309 * @extends Tech 310 */ 311 312var Flash = function (_Tech) { 313 inherits(Flash, _Tech); 314 315 /** 316 * Create an instance of this Tech. 317 * 318 * @param {Object} [options] 319 * The key/value store of player options. 320 * 321 * @param {Component~ReadyCallback} ready 322 * Callback function to call when the `Flash` Tech is ready. 323 */ 324 function Flash(options, ready) { 325 classCallCheck(this, Flash); 326 327 // Set the source when ready 328 var _this = possibleConstructorReturn(this, _Tech.call(this, options, ready)); 329 330 if (options.source) { 331 _this.ready(function () { 332 this.setSource(options.source); 333 }, true); 334 } 335 336 // Having issues with Flash reloading on certain page actions 337 // (hide/resize/fullscreen) in certain browsers 338 // This allows resetting the playhead when we catch the reload 339 if (options.startTime) { 340 _this.ready(function () { 341 this.load(); 342 this.play(); 343 this.currentTime(options.startTime); 344 }, true); 345 } 346 347 // Add global window functions that the swf expects 348 // A 4.x workflow we weren't able to solve for in 5.0 349 // because of the need to hard code these functions 350 // into the swf for security reasons 351 window_1.videojs = window_1.videojs || {}; 352 window_1.videojs.Flash = window_1.videojs.Flash || {}; 353 window_1.videojs.Flash.onReady = Flash.onReady; 354 window_1.videojs.Flash.onEvent = Flash.onEvent; 355 window_1.videojs.Flash.onError = Flash.onError; 356 357 _this.on('seeked', function () { 358 this.lastSeekTarget_ = undefined; 359 });
vendor: 7,193 bytes, lines 360-644
360 361 return _this; 362 } 363 364 /** 365 * Create the `Flash` Tech's DOM element. 366 * 367 * @return {Element} 368 * The element that gets created. 369 */ 370 371 372 Flash.prototype.createEl = function createEl() { 373 var options = this.options_; 374 375 // If video.js is hosted locally you should also set the location 376 // for the hosted swf, which should be relative to the page (not video.js) 377 // Otherwise this adds a CDN url. 378 // The CDN also auto-adds a swf URL for that specific version. 379 if (!options.swf) { 380 options.swf = 'https://vjs.zencdn.net/swf/' + version + '/video-js.swf'; 381 } 382 383 // Generate ID for swf object 384 var objId = options.techId; 385 386 // Merge default flashvars with ones passed in to init 387 var flashVars = mergeOptions({ 388 389 // SWF Callback Functions 390 readyFunction: 'videojs.Flash.onReady', 391 eventProxyFunction: 'videojs.Flash.onEvent', 392 errorEventProxyFunction: 'videojs.Flash.onError', 393 394 // Player Settings 395 autoplay: options.autoplay, 396 preload: options.preload, 397 loop: options.loop, 398 muted: options.muted 399 400 }, options.flashVars); 401 402 // Merge default parames with ones passed in 403 var params = mergeOptions({ 404 // Opaque is needed to overlay controls, but can affect playback performance 405 wmode: 'opaque', 406 // Using bgcolor prevents a white flash when the object is loading 407 bgcolor: '#000000' 408 }, options.params); 409 410 // Merge default attributes with ones passed in 411 var attributes = mergeOptions({ 412 // Both ID and Name needed or swf to identify itself 413 id: objId, 414 name: objId, 415 'class': 'vjs-tech' 416 }, options.attributes); 417 418 this.el_ = Flash.embed(options.swf, flashVars, params, attributes); 419 this.el_.tech = this; 420 421 return this.el_; 422 }; 423 424 /** 425 * Called by {@link Player#play} to play using the `Flash` `Tech`. 426 */ 427 428 429 Flash.prototype.play = function play() { 430 if (this.ended()) { 431 this.setCurrentTime(0); 432 } 433 this.el_.vjs_play(); 434 }; 435 436 /** 437 * Called by {@link Player#pause} to pause using the `Flash` `Tech`. 438 */ 439 440 441 Flash.prototype.pause = function pause() { 442 this.el_.vjs_pause(); 443 }; 444 445 /** 446 * A getter/setter for the `Flash` Tech's source object. 447 * > Note: Please use {@link Flash#setSource} 448 * 449 * @param {Tech~SourceObject} [src] 450 * The source object you want to set on the `Flash` techs. 451 * 452 * @return {Tech~SourceObject|undefined} 453 * - The current source object when a source is not passed in. 454 * - undefined when setting 455 * 456 * @deprecated Since version 5. 457 */ 458 459 460 Flash.prototype.src = function src(_src) { 461 if (_src === undefined) { 462 return this.currentSrc(); 463 } 464 465 // Setting src through `src` not `setSrc` will be deprecated 466 return this.setSrc(_src); 467 }; 468 469 /** 470 * A getter/setter for the `Flash` Tech's source object. 471 * 472 * @param {Tech~SourceObject} [src] 473 * The source object you want to set on the `Flash` techs. 474 */ 475 476 477 Flash.prototype.setSrc = function setSrc(src) { 478 var _this2 = this; 479 480 // Make sure source URL is absolute. 481 src = Url.getAbsoluteURL(src); 482 this.el_.vjs_src(src); 483 484 // Currently the SWF doesn't autoplay if you load a source later. 485 // e.g. Load player w/ no source, wait 2s, set src. 486 if (this.autoplay()) { 487 this.setTimeout(function () { 488 return _this2.play(); 489 }, 0); 490 } 491 }; 492 493 /** 494 * Indicates whether the media is currently seeking to a new position or not. 495 * 496 * @return {boolean} 497 * - True if seeking to a new position 498 * - False otherwise 499 */ 500 501 502 Flash.prototype.seeking = function seeking() { 503 return this.lastSeekTarget_ !== undefined; 504 }; 505 506 /** 507 * Returns the current time in seconds that the media is at in playback. 508 * 509 * @param {number} time 510 * Current playtime of the media in seconds. 511 */ 512 513 514 Flash.prototype.setCurrentTime = function setCurrentTime(time) { 515 var seekable = this.seekable(); 516 517 if (seekable.length) { 518 // clamp to the current seekable range 519 time = time > seekable.start(0) ? time : seekable.start(0); 520 time = time < seekable.end(seekable.length - 1) ? time : seekable.end(seekable.length - 1); 521 522 this.lastSeekTarget_ = time; 523 this.trigger('seeking'); 524 this.el_.vjs_setProperty('currentTime', time); 525 _Tech.prototype.setCurrentTime.call(this); 526 } 527 }; 528 529 /** 530 * Get the current playback time in seconds 531 * 532 * @return {number} 533 * The current time of playback in seconds. 534 */ 535 536 537 Flash.prototype.currentTime = function currentTime() { 538 // when seeking make the reported time keep up with the requested time 539 // by reading the time we're seeking to 540 if (this.seeking()) { 541 return this.lastSeekTarget_ || 0; 542 } 543 return this.el_.vjs_getProperty('currentTime'); 544 }; 545 546 /** 547 * Get the current source 548 * 549 * @method currentSrc 550 * @return {Tech~SourceObject} 551 * The current source 552 */ 553 554 555 Flash.prototype.currentSrc = function currentSrc() { 556 if (this.currentSource_) { 557 return this.currentSource_.src; 558 } 559 return this.el_.vjs_getProperty('currentSrc'); 560 }; 561 562 /** 563 * Get the total duration of the current media. 564 * 565 * @return {number} 566 8 The total duration of the current media. 567 */ 568 569 570 Flash.prototype.duration = function duration() { 571 if (this.readyState() === 0) { 572 return NaN; 573 } 574 var duration = this.el_.vjs_getProperty('duration'); 575 576 return duration >= 0 ? duration : Infinity; 577 }; 578 579 /** 580 * Load media into Tech. 581 */ 582 583 584 Flash.prototype.load = function load() { 585 this.el_.vjs_load(); 586 }; 587 588 /** 589 * Get the poster image that was set on the tech. 590 */ 591 592 593 Flash.prototype.poster = function poster() { 594 this.el_.vjs_getProperty('poster'); 595 }; 596 597 /** 598 * Poster images are not handled by the Flash tech so make this is a no-op. 599 */ 600 601 602 Flash.prototype.setPoster = function setPoster() {}; 603 604 /** 605 * Determine the time ranges that can be seeked to in the media. 606 * 607 * @return {TimeRange} 608 * Returns the time ranges that can be seeked to. 609 */ 610 611 612 Flash.prototype.seekable = function seekable() { 613 var duration = this.duration(); 614 615 if (duration === 0) { 616 return createTimeRange(); 617 } 618 return createTimeRange(0, duration); 619 }; 620 621 /** 622 * Get and create a `TimeRange` object for buffering. 623 * 624 * @return {TimeRange} 625 * The time range object that was created. 626 */ 627 628 629 Flash.prototype.buffered = function buffered() { 630 var ranges = this.el_.vjs_getProperty('buffered'); 631 632 if (ranges.length === 0) { 633 return createTimeRange(); 634 } 635 return createTimeRange(ranges[0][0], ranges[0][1]); 636 }; 637 638 /** 639 * Get fullscreen support - 640 * 641 * Flash does not allow fullscreen through javascript 642 * so this always returns false. 643 * 644 * @return {boolean}
vendor: 4,139 bytes, lines 645-783
645 * The Flash tech does not support fullscreen, so it will always return false. 646 */ 647 648 649 Flash.prototype.supportsFullScreen = function supportsFullScreen() { 650 // Flash does not allow fullscreen through javascript 651 return false; 652 }; 653 654 /** 655 * Flash does not allow fullscreen through javascript 656 * so this always returns false. 657 * 658 * @return {boolean} 659 * The Flash tech does not support fullscreen, so it will always return false. 660 */ 661 662 663 Flash.prototype.enterFullScreen = function enterFullScreen() { 664 return false; 665 }; 666 667 /** 668 * Gets available media playback quality metrics as specified by the W3C's Media 669 * Playback Quality API. 670 * 671 * @see [Spec]{@link https://wicg.github.io/media-playback-quality} 672 * 673 * @return {Object} 674 * An object with supported media playback quality metrics 675 */ 676 677 678 Flash.prototype.getVideoPlaybackQuality = function getVideoPlaybackQuality() { 679 var videoPlaybackQuality = this.el_.vjs_getProperty('getVideoPlaybackQuality'); 680 681 if (window_1.performance && typeof window_1.performance.now === 'function') { 682 videoPlaybackQuality.creationTime = window_1.performance.now(); 683 } else if (window_1.performance && window_1.performance.timing && typeof window_1.performance.timing.navigationStart === 'number') { 684 videoPlaybackQuality.creationTime = window_1.Date.now() - window_1.performance.timing.navigationStart; 685 } 686 687 return videoPlaybackQuality; 688 }; 689 690 return Flash; 691}(Tech); 692 693// Create setters and getters for attributes 694 695 696var _readWrite = ['rtmpConnection', 'rtmpStream', 'preload', 'defaultPlaybackRate', 'playbackRate', 'autoplay', 'loop', 'controls', 'volume', 'muted', 'defaultMuted']; 697var _readOnly = ['networkState', 'readyState', 'initialTime', 'startOffsetTime', 'paused', 'ended', 'videoWidth', 'videoHeight']; 698var _api = Flash.prototype; 699 700/** 701 * Create setters for the swf on the element 702 * 703 * @param {string} attr 704 * The name of the parameter 705 * 706 * @private 707 */ 708function _createSetter(attr) { 709 var attrUpper = attr.charAt(0).toUpperCase() + attr.slice(1); 710 711 _api['set' + attrUpper] = function (val) { 712 return this.el_.vjs_setProperty(attr, val); 713 }; 714} 715 716/** 717 * Create petters for the swf on the element 718 * 719 * @param {string} attr 720 * The name of the parameter 721 * 722 * @private 723 */ 724function _createGetter(attr) { 725 _api[attr] = function () { 726 return this.el_.vjs_getProperty(attr); 727 }; 728} 729 730// Create getter and setters for all read/write attributes 731for (var i = 0; i < _readWrite.length; i++) { 732 _createGetter(_readWrite[i]); 733 _createSetter(_readWrite[i]); 734} 735 736// Create getters for read-only attributes 737for (var _i = 0; _i < _readOnly.length; _i++) { 738 _createGetter(_readOnly[_i]); 739} 740 741/** ------------------------------ Getters ------------------------------ **/ 742/** 743 * Get the value of `rtmpConnection` from the swf. 744 * 745 * @method Flash#rtmpConnection 746 * @return {string} 747 * The current value of `rtmpConnection` on the swf. 748 */ 749 750/** 751 * Get the value of `rtmpStream` from the swf. 752 * 753 * @method Flash#rtmpStream 754 * @return {string} 755 * The current value of `rtmpStream` on the swf. 756 */ 757 758/** 759 * Get the value of `preload` from the swf. `preload` indicates 760 * what should download before the media is interacted with. It can have the following 761 * values: 762 * - none: nothing should be downloaded 763 * - metadata: poster and the first few frames of the media may be downloaded to get 764 * media dimensions and other metadata 765 * - auto: allow the media and metadata for the media to be downloaded before 766 * interaction 767 * 768 * @method Flash#preload 769 * @return {string} 770 * The value of `preload` from the swf. Will be 'none', 'metadata', 771 * or 'auto'. 772 */ 773 774/** 775 * Get the value of `defaultPlaybackRate` from the swf. 776 * 777 * @method Flash#defaultPlaybackRate 778 * @return {number} 779 * The current value of `defaultPlaybackRate` on the swf. 780 */ 781 782/** 783 * Get the value of `playbackRate` from the swf. `playbackRate` indicates
784 * the rate at which the media is currently playing back. Examples: 785 * - if playbackRate is set to 2, media will play twice as fast. 786 * - if playbackRate is set to 0.5, media will play half as fast. 787 * 788 * @method Flash#playbackRate 789 * @return {number} 790 * The value of `playbackRate` from the swf. A number indicating 791 * the current playback speed of the media, where 1 is normal speed. 792 */ 793 794/** 795 * Get the value of `autoplay` from the swf. `autoplay` indicates 796 * that the media should start to play as soon as the page is ready. 797 * 798 * @method Flash#autoplay 799 * @return {boolean} 800 * - The value of `autoplay` from the swf. 801 * - True indicates that the media ashould start as soon as the page loads. 802 * - False indicates that the media should not start as soon as the page loads. 803 */ 804 805/** 806 * Get the value of `loop` from the swf. `loop` indicates 807 * that the media should return to the start of the media and continue playing once 808 * it reaches the end. 809 * 810 * @method Flash#loop 811 * @return {boolean} 812 * - The value of `loop` from the swf. 813 * - True indicates that playback should seek back to start once 814 * the end of a media is reached. 815 * - False indicates that playback should not loop back to the start when the 816 * end of the media is reached. 817 */ 818 819/** 820 * Get the value of `mediaGroup` from the swf. 821 * 822 * @method Flash#mediaGroup 823 * @return {string} 824 * The current value of `mediaGroup` on the swf. 825 */ 826 827/** 828 * Get the value of `controller` from the swf. 829 * 830 * @method Flash#controller 831 * @return {string} 832 * The current value of `controller` on the swf. 833 */ 834 835/** 836 * Get the value of `controls` from the swf. `controls` indicates 837 * whether the native flash controls should be shown or hidden. 838 * 839 * @method Flash#controls 840 * @return {boolean} 841 * - The value of `controls` from the swf. 842 * - True indicates that native controls should be showing. 843 * - False indicates that native controls should be hidden. 844 */ 845 846/** 847 * Get the value of the `volume` from the swf. `volume` indicates the current 848 * audio level as a percentage in decimal form. This means that 1 is 100%, 0.5 is 50%, and 849 * so on. 850 * 851 * @method Flash#volume 852 * @return {number} 853 * The volume percent as a decimal. Value will be between 0-1. 854 */ 855 856/** 857 * Get the value of the `muted` from the swf. `muted` indicates the current 858 * audio level should be silent. 859 * 860 * @method Flash#muted 861 * @return {boolean} 862 * - True if the audio should be set to silent 863 * - False otherwise 864 */ 865 866/** 867 * Get the value of `defaultMuted` from the swf. `defaultMuted` indicates 868 * whether the media should start muted or not. Only changes the default state of the 869 * media. `muted` and `defaultMuted` can have different values. `muted` indicates the 870 * current state. 871 * 872 * @method Flash#defaultMuted 873 * @return {boolean} 874 * - The value of `defaultMuted` from the swf. 875 * - True indicates that the media should start muted. 876 * - False indicates that the media should not start muted. 877 */ 878 879/** 880 * Get the value of `networkState` from the swf. `networkState` indicates 881 * the current network state. It returns an enumeration from the following list: 882 * - 0: NETWORK_EMPTY 883 * - 1: NEWORK_IDLE 884 * - 2: NETWORK_LOADING 885 * - 3: NETWORK_NO_SOURCE 886 * 887 * @method Flash#networkState 888 * @return {number} 889 * The value of `networkState` from the swf. This will be a number 890 * from the list in the description. 891 */ 892 893/** 894 * Get the value of `readyState` from the swf. `readyState` indicates 895 * the current state of the media element. It returns an enumeration from the 896 * following list: 897 * - 0: HAVE_NOTHING 898 * - 1: HAVE_METADATA 899 * - 2: HAVE_CURRENT_DATA 900 * - 3: HAVE_FUTURE_DATA 901 * - 4: HAVE_ENOUGH_DATA 902 * 903 * @method Flash#readyState 904 * @return {number} 905 * The value of `readyState` from the swf. This will be a number 906 * from the list in the description. 907 */ 908 909/** 910 * Get the value of `readyState` from the swf. `readyState` indicates 911 * the current state of the media element. It returns an enumeration from the 912 * following list: 913 * - 0: HAVE_NOTHING 914 * - 1: HAVE_METADATA 915 * - 2: HAVE_CURRENT_DATA 916 * - 3: HAVE_FUTURE_DATA 917 * - 4: HAVE_ENOUGH_DATA 918 * 919 * @method Flash#readyState 920 * @return {number} 921 * The value of `readyState` from the swf. This will be a number 922 * from the list in the description. 923 */ 924 925/** 926 * Get the value of `initialTime` from the swf. 927 * 928 * @method Flash#initialTime 929 * @return {number} 930 * The `initialTime` proprety on the swf. 931 */ 932 933/** 934 * Get the value of `startOffsetTime` from the swf. 935 * 936 * @method Flash#startOffsetTime 937 * @return {number} 938 * The `startOffsetTime` proprety on the swf. 939 */ 940 941/** 942 * Get the value of `paused` from the swf. `paused` indicates whether the swf 943 * is current paused or not. 944 * 945 * @method Flash#paused 946 * @return {boolean} 947 * The value of `paused` from the swf. 948 */ 949 950/** 951 * Get the value of `ended` from the swf. `ended` indicates whether 952 * the media has reached the end or not. 953 * 954 * @method Flash#ended 955 * @return {boolean} 956 * - True indicates that the media has ended. 957 * - False indicates that the media has not ended. 958 * 959 * @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-media-ended} 960 */ 961 962/** 963 * Get the value of `videoWidth` from the swf. `videoWidth` indicates 964 * the current width of the media in css pixels. 965 * 966 * @method Flash#videoWidth 967 * @return {number} 968 * The value of `videoWidth` from the swf. This will be a number 969 * in css pixels. 970 */ 971 972/** 973 * Get the value of `videoHeight` from the swf. `videoHeigth` indicates 974 * the current height of the media in css pixels. 975 * 976 * @method Flassh.prototype.videoHeight 977 * @return {number} 978 * The value of `videoHeight` from the swf. This will be a number 979 * in css pixels. 980 */ 981/** ------------------------------ Setters ------------------------------ **/ 982 983/** 984 * Set the value of `rtmpConnection` on the swf. 985 * 986 * @method Flash#setRtmpConnection 987 * @param {string} rtmpConnection 988 * New value to set the `rtmpConnection` property to. 989 */ 990 991/** 992 * Set the value of `rtmpStream` on the swf. 993 * 994 * @method Flash#setRtmpStream 995 * @param {string} rtmpStream 996 * New value to set the `rtmpStream` property to. 997 */ 998 999/** 1000 * Set the value of `preload` on the swf. `preload` indicates 1001 * what should download before the media is interacted with. It can have the following 1002 * values: 1003 * - none: nothing should be downloaded 1004 * - metadata: poster and the first few frames of the media may be downloaded to get 1005 * media dimensions and other metadata 1006 * - auto: allow the media and metadata for the media to be downloaded before 1007 * interaction 1008 * 1009 * @method Flash#setPreload 1010 * @param {string} preload 1011 * The value of `preload` to set on the swf. Should be 'none', 'metadata', 1012 * or 'auto'. 1013 */ 1014 1015/** 1016 * Set the value of `defaultPlaybackRate` on the swf. 1017 * 1018 * @method Flash#setDefaultPlaybackRate 1019 * @param {number} defaultPlaybackRate 1020 * New value to set the `defaultPlaybackRate` property to. 1021 */ 1022 1023/** 1024 * Set the value of `playbackRate` on the swf. `playbackRate` indicates
1025 * the rate at which the media is currently playing back. Examples: 1026 * - if playbackRate is set to 2, media will play twice as fast. 1027 * - if playbackRate is set to 0.5, media will play half as fast. 1028 * 1029 * @method Flash#setPlaybackRate 1030 * @param {number} playbackRate 1031 * New value of `playbackRate` on the swf. A number indicating 1032 * the current playback speed of the media, where 1 is normal speed. 1033 */ 1034 1035/** 1036 * Set the value of `autoplay` on the swf. `autoplay` indicates 1037 * that the media should start to play as soon as the page is ready. 1038 * 1039 * @method Flash#setAutoplay 1040 * @param {boolean} autoplay 1041 * - The value of `autoplay` from the swf. 1042 * - True indicates that the media ashould start as soon as the page loads. 1043 * - False indicates that the media should not start as soon as the page loads. 1044 */ 1045 1046/** 1047 * Set the value of `loop` on the swf. `loop` indicates 1048 * that the media should return to the start of the media and continue playing once 1049 * it reaches the end. 1050 * 1051 * @method Flash#setLoop 1052 * @param {boolean} loop 1053 * - True indicates that playback should seek back to start once 1054 * the end of a media is reached. 1055 * - False indicates that playback should not loop back to the start when the 1056 * end of the media is reached. 1057 */ 1058 1059/** 1060 * Set the value of `mediaGroup` on the swf. 1061 * 1062 * @method Flash#setMediaGroup 1063 * @param {string} mediaGroup 1064 * New value of `mediaGroup` to set on the swf. 1065 */ 1066 1067/** 1068 * Set the value of `controller` on the swf. 1069 * 1070 * @method Flash#setController 1071 * @param {string} controller 1072 * New value the current value of `controller` on the swf. 1073 */ 1074 1075/** 1076 * Get the value of `controls` from the swf. `controls` indicates 1077 * whether the native flash controls should be shown or hidden. 1078 * 1079 * @method Flash#controls 1080 * @return {boolean} 1081 * - The value of `controls` from the swf. 1082 * - True indicates that native controls should be showing. 1083 * - False indicates that native controls should be hidden. 1084 */ 1085 1086/** 1087 * Set the value of the `volume` on the swf. `volume` indicates the current 1088 * audio level as a percentage in decimal form. This means that 1 is 100%, 0.5 is 50%, and 1089 * so on. 1090 * 1091 * @method Flash#setVolume 1092 * @param {number} percentAsDecimal 1093 * The volume percent as a decimal. Value will be between 0-1. 1094 */ 1095 1096/** 1097 * Set the value of the `muted` on the swf. `muted` indicates that the current 1098 * audio level should be silent. 1099 * 1100 * @method Flash#setMuted 1101 * @param {boolean} muted 1102 * - True if the audio should be set to silent 1103 * - False otherwise 1104 */ 1105 1106/** 1107 * Set the value of `defaultMuted` on the swf. `defaultMuted` indicates 1108 * whether the media should start muted or not. Only changes the default state of the 1109 * media. `muted` and `defaultMuted` can have different values. `muted` indicates the 1110 * current state. 1111 * 1112 * @method Flash#setDefaultMuted 1113 * @param {boolean} defaultMuted 1114 * - True indicates that the media should start muted. 1115 * - False indicates that the media should not start muted. 1116 */ 1117 1118/* Flash Support Testing -------------------------------------------------------- */ 1119 1120/** 1121 * Check if the Flash tech is currently supported. 1122 * 1123 * @return {boolean} 1124 * - True for Chrome and Safari Desktop and if flash tech is supported 1125 * - False otherwise 1126 */ 1127Flash.isSupported = function () { 1128 // for Chrome Desktop and Safari Desktop 1129 if (videojs.browser.IS_CHROME && !videojs.browser.IS_ANDROID || videojs.browser.IS_SAFARI && !videojs.browser.IS_IOS) { 1130 return true; 1131 } 1132 // for other browsers 1133 return Flash.version()[0] >= 10; 1134}; 1135 1136// Add Source Handler pattern functions to this tech 1137Tech.withSourceHandlers(Flash); 1138 1139/* 1140 * Native source handler for flash, simply passes the source to the swf element. 1141 * 1142 * @property {Tech~SourceObject} source 1143 * The source object 1144 * 1145 * @property {Flash} tech 1146 * The instance of the Flash tech 1147 */ 1148Flash.nativeSourceHandler = {}; 1149 1150/** 1151 * Check if the Flash can play the given mime type. 1152 * 1153 * @param {string} type 1154 * The mimetype to check 1155 * 1156 * @return {string} 1157 * 'maybe', or '' (empty string) 1158 */ 1159Flash.nativeSourceHandler.canPlayType = function (type) { 1160 if (type in Flash.formats) { 1161 return 'maybe'; 1162 } 1163 1164 return ''; 1165}; 1166 1167/** 1168 * Check if the media element can handle a source natively. 1169 * 1170 * @param {Tech~SourceObject} source 1171 * The source object 1172 * 1173 * @param {Object} [options] 1174 * Options to be passed to the tech. 1175 * 1176 * @return {string} 1177 * 'maybe', or '' (empty string). 1178 */ 1179Flash.nativeSourceHandler.canHandleSource = function (source, options) { 1180 var type = void 0; 1181 1182 /** 1183 * Guess the mime type of a file if it does not have one 1184 * 1185 * @param {Tech~SourceObject} src 1186 * The source object to guess the mime type for 1187 * 1188 * @return {string} 1189 * The mime type that was guessed 1190 */ 1191 function guessMimeType(src) { 1192 var ext = Url.getFileExtension(src); 1193 1194 if (ext) { 1195 return 'video/' + ext; 1196 } 1197 return ''; 1198 } 1199 1200 if (!source.type) { 1201 type = guessMimeType(source.src); 1202 } else { 1203 // Strip code information from the type because we don't get that specific 1204 type = source.type.replace(/;.*/, '').toLowerCase(); 1205 } 1206 1207 return Flash.nativeSourceHandler.canPlayType(type); 1208};
vendor: 4,181 bytes, lines 1209-1368
1209 1210/** 1211 * Pass the source to the swf. 1212 * 1213 * @param {Tech~SourceObject} source 1214 * The source object 1215 * 1216 * @param {Flash} tech 1217 * The instance of the Flash tech 1218 * 1219 * @param {Object} [options] 1220 * The options to pass to the source 1221 */ 1222Flash.nativeSourceHandler.handleSource = function (source, tech, options) { 1223 tech.setSrc(source.src); 1224}; 1225 1226/** 1227 * noop for native source handler dispose, as cleanup will happen automatically. 1228 */ 1229Flash.nativeSourceHandler.dispose = function () {}; 1230 1231// Register the native source handler 1232Flash.registerSourceHandler(Flash.nativeSourceHandler); 1233 1234/** 1235 * Flash supported mime types. 1236 * 1237 * @constant {Object} 1238 */ 1239Flash.formats = { 1240 'video/flv': 'FLV', 1241 'video/x-flv': 'FLV', 1242 'video/mp4': 'MP4', 1243 'video/m4v': 'MP4' 1244}; 1245 1246/** 1247 * Called when the the swf is "ready", and makes sure that the swf is really 1248 * ready using {@link Flash#checkReady} 1249 * 1250 * @param {Object} currSwf 1251 * The current swf object 1252 */ 1253Flash.onReady = function (currSwf) { 1254 var el = Dom.$('#' + currSwf); 1255 var tech = el && el.tech; 1256 1257 // if there is no el then the tech has been disposed 1258 // and the tech element was removed from the player div 1259 if (tech && tech.el()) { 1260 // check that the flash object is really ready 1261 Flash.checkReady(tech); 1262 } 1263}; 1264 1265/** 1266 * The SWF isn't always ready when it says it is. Sometimes the API functions still 1267 * need to be added to the object. If it's not ready, we set a timeout to check again 1268 * shortly. 1269 * 1270 * @param {Flash} tech 1271 * The instance of the flash tech to check. 1272 */ 1273Flash.checkReady = function (tech) { 1274 // stop worrying if the tech has been disposed 1275 if (!tech.el()) { 1276 return; 1277 } 1278 1279 // check if API property exists 1280 if (tech.el().vjs_getProperty) { 1281 // tell tech it's ready 1282 tech.triggerReady(); 1283 } else { 1284 // wait longer 1285 this.setTimeout(function () { 1286 Flash.checkReady(tech); 1287 }, 50); 1288 } 1289}; 1290 1291/** 1292 * Trigger events from the swf on the Flash Tech. 1293 * 1294 * @param {number} swfID 1295 * The id of the swf that had the event 1296 * 1297 * @param {string} eventName 1298 * The name of the event to trigger 1299 */ 1300Flash.onEvent = function (swfID, eventName) { 1301 var tech = Dom.$('#' + swfID).tech; 1302 var args = Array.prototype.slice.call(arguments, 2); 1303 1304 // dispatch Flash events asynchronously for two reasons: 1305 // - Flash swallows any exceptions generated by javascript it 1306 // invokes 1307 // - Flash is suspended until the javascript returns which may cause 1308 // playback performance issues 1309 tech.setTimeout(function () { 1310 tech.trigger(eventName, args); 1311 }, 1); 1312}; 1313 1314/** 1315 * Log errors from the swf on the Flash tech. 1316 * 1317 * @param {number} swfID 1318 * The id of the swf that had an error. 1319 * 1320 * @param {string} err 1321 * The error to set on the Flash Tech. 1322 * 1323 * @return {MediaError|undefined} 1324 * - Returns a MediaError when err is 'srcnotfound' 1325 * - Returns undefined otherwise. 1326 */ 1327Flash.onError = function (swfID, err) { 1328 var tech = Dom.$('#' + swfID).tech; 1329 1330 // trigger MEDIA_ERR_SRC_NOT_SUPPORTED 1331 if (err === 'srcnotfound') { 1332 return tech.error(4); 1333 } 1334 1335 // trigger a custom error 1336 if (typeof err === 'string') { 1337 tech.error('FLASH: ' + err); 1338 } else { 1339 err.origin = 'flash'; 1340 tech.error(err); 1341 } 1342}; 1343 1344/** 1345 * Get the current version of Flash that is in use on the page. 1346 * 1347 * @return {Array} 1348 * an array of versions that are available. 1349 */ 1350Flash.version = function () { 1351 var version$$1 = '0,0,0'; 1352 1353 // IE 1354 try { 1355 version$$1 = new window_1.ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1]; 1356 1357 // other browsers 1358 } catch (e) { 1359 try { 1360 if (navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin) { 1361 version$$1 = (navigator.plugins['Shockwave Flash 2.0'] || navigator.plugins['Shockwave Flash']).description.replace(/\D+/g, ',').match(/^,?(.+),?$/)[1]; 1362 } 1363 } catch (err) { 1364 // satisfy linter 1365 } 1366 } 1367 return version$$1.split(','); 1368};
vendor: 2,909 bytes, lines 1369-1475
1369 1370/** 1371 * Only use for non-iframe embeds. 1372 * 1373 * @param {Object} swf 1374 * The videojs-swf object. 1375 * 1376 * @param {Object} flashVars 1377 * Names and values to use as flash option variables. 1378 * 1379 * @param {Object} params 1380 * Style parameters to set on the object. 1381 * 1382 * @param {Object} attributes 1383 * Attributes to set on the element. 1384 * 1385 * @return {Element} 1386 * The embeded Flash DOM element. 1387 */ 1388Flash.embed = function (swf, flashVars, params, attributes) { 1389 var code = Flash.getEmbedCode(swf, flashVars, params, attributes); 1390 1391 // Get element by embedding code and retrieving created element 1392 var obj = Dom.createEl('div', { innerHTML: code }).childNodes[0]; 1393 1394 return obj; 1395}; 1396 1397/** 1398 * Only use for non-iframe embeds. 1399 * 1400 * @param {Object} swf 1401 * The videojs-swf object. 1402 * 1403 * @param {Object} flashVars 1404 * Names and values to use as flash option variables. 1405 * 1406 * @param {Object} params 1407 * Style parameters to set on the object. 1408 * 1409 * @param {Object} attributes 1410 * Attributes to set on the element. 1411 * 1412 * @return {Element} 1413 * The embeded Flash DOM element. 1414 */ 1415Flash.getEmbedCode = function (swf, flashVars, params, attributes) { 1416 var objTag = '<object type="application/x-shockwave-flash" '; 1417 var flashVarsString = ''; 1418 var paramsString = ''; 1419 var attrsString = ''; 1420 1421 // Convert flash vars to string 1422 if (flashVars) { 1423 Object.getOwnPropertyNames(flashVars).forEach(function (key) { 1424 flashVarsString += key + '=' + flashVars[key] + '&'; 1425 }); 1426 } 1427 1428 // Add swf, flashVars, and other default params 1429 params = mergeOptions({ 1430 movie: swf, 1431 flashvars: flashVarsString, 1432 // Required to talk to swf 1433 allowScriptAccess: 'always', 1434 // All should be default, but having security issues. 1435 allowNetworking: 'all' 1436 }, params); 1437 1438 // Create param tags string 1439 Object.getOwnPropertyNames(params).forEach(function (key) { 1440 paramsString += '<param name="' + key + '" value="' + params[key] + '" />'; 1441 }); 1442 1443 attributes = mergeOptions({ 1444 // Add swf to attributes (need both for IE and Others to work) 1445 data: swf, 1446 1447 // Default to 100% width/height 1448 width: '100%', 1449 height: '100%' 1450 1451 }, attributes); 1452 1453 // Create Attributes string 1454 Object.getOwnPropertyNames(attributes).forEach(function (key) { 1455 attrsString += key + '="' + attributes[key] + '" '; 1456 }); 1457 1458 return '' + objTag + attrsString + '>' + paramsString + '</object>'; 1459}; 1460 1461// Run Flash through the RTMP decorator 1462FlashRtmpDecorator(Flash); 1463 1464if (Tech.getTech('Flash')) { 1465 videojs.log.warn('Not using videojs-flash as it appears to already be registered'); 1466 videojs.log.warn('videojs-flash should only be used with video.js@6 and above'); 1467} else { 1468 videojs.registerTech('Flash', Flash); 1469} 1470 1471Flash.VERSION = version$1; 1472 1473return Flash; 1474 1475})));
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.