3 exports.__esModule = true;
5 var _tech = require('./tech');
7 var _tech2 = _interopRequireDefault(_tech);
9 var _dom = require('../utils/dom.js');
11 var Dom = _interopRequireWildcard(_dom);
13 var _url = require('../utils/url.js');
15 var Url = _interopRequireWildcard(_url);
17 var _timeRanges = require('../utils/time-ranges.js');
19 var _flashRtmp = require('./flash-rtmp');
21 var _flashRtmp2 = _interopRequireDefault(_flashRtmp);
23 var _component = require('../component');
25 var _component2 = _interopRequireDefault(_component);
27 var _window = require('global/window');
29 var _window2 = _interopRequireDefault(_window);
31 var _obj = require('../utils/obj');
33 function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
35 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
37 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
39 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
41 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
43 * VideoJS-SWF - Custom Flash Player with HTML5-ish API
44 * https://github.com/zencoder/video-js-swf
45 * Not using setupTriggers. Using global onEvent func to distribute events
48 var navigator = _window2['default'].navigator;
51 * Flash Media Controller - Wrapper for Flash Media API
53 * @mixes FlashRtmpDecorator
54 * @mixes Tech~SouceHandlerAdditions
58 var Flash = function (_Tech) {
59 _inherits(Flash, _Tech);
62 * Create an instance of this Tech.
64 * @param {Object} [options]
65 * The key/value store of player options.
67 * @param {Component~ReadyCallback} ready
68 * Callback function to call when the `Flash` Tech is ready.
70 function Flash(options, ready) {
71 _classCallCheck(this, Flash);
73 // Set the source when ready
74 var _this = _possibleConstructorReturn(this, _Tech.call(this, options, ready));
77 _this.ready(function () {
78 this.setSource(options.source);
82 // Having issues with Flash reloading on certain page actions (hide/resize/fullscreen) in certain browsers
83 // This allows resetting the playhead when we catch the reload
84 if (options.startTime) {
85 _this.ready(function () {
88 this.currentTime(options.startTime);
92 // Add global window functions that the swf expects
93 // A 4.x workflow we weren't able to solve for in 5.0
94 // because of the need to hard code these functions
95 // into the swf for security reasons
96 _window2['default'].videojs = _window2['default'].videojs || {};
97 _window2['default'].videojs.Flash = _window2['default'].videojs.Flash || {};
98 _window2['default'].videojs.Flash.onReady = Flash.onReady;
99 _window2['default'].videojs.Flash.onEvent = Flash.onEvent;
100 _window2['default'].videojs.Flash.onError = Flash.onError;
102 _this.on('seeked', function () {
103 this.lastSeekTarget_ = undefined;
110 * Create the `Flash` Tech's DOM element.
113 * The element that gets created.
117 Flash.prototype.createEl = function createEl() {
118 var options = this.options_;
120 // If video.js is hosted locally you should also set the location
121 // for the hosted swf, which should be relative to the page (not video.js)
122 // Otherwise this adds a CDN url.
123 // The CDN also auto-adds a swf URL for that specific version.
127 options.swf = '//vjs.zencdn.net/swf/' + ver + '/video-js.swf';
130 // Generate ID for swf object
131 var objId = options.techId;
133 // Merge default flashvars with ones passed in to init
134 var flashVars = (0, _obj.assign)({
136 // SWF Callback Functions
137 readyFunction: 'videojs.Flash.onReady',
138 eventProxyFunction: 'videojs.Flash.onEvent',
139 errorEventProxyFunction: 'videojs.Flash.onError',
142 autoplay: options.autoplay,
143 preload: options.preload,
147 }, options.flashVars);
149 // Merge default parames with ones passed in
150 var params = (0, _obj.assign)({
151 // Opaque is needed to overlay controls, but can affect playback performance
153 // Using bgcolor prevents a white flash when the object is loading
157 // Merge default attributes with ones passed in
158 var attributes = (0, _obj.assign)({
159 // Both ID and Name needed or swf to identify itself
163 }, options.attributes);
165 this.el_ = Flash.embed(options.swf, flashVars, params, attributes);
166 this.el_.tech = this;
172 * Called by {@link Player#play} to play using the `Flash` `Tech`.
176 Flash.prototype.play = function play() {
178 this.setCurrentTime(0);
184 * Called by {@link Player#pause} to pause using the `Flash` `Tech`.
188 Flash.prototype.pause = function pause() {
189 this.el_.vjs_pause();
193 * A getter/setter for the `Flash` Tech's source object.
194 * > Note: Please use {@link Flash#setSource}
196 * @param {Tech~SourceObject} [src]
197 * The source object you want to set on the `Flash` techs.
199 * @return {Tech~SourceObject|undefined}
200 * - The current source object when a source is not passed in.
201 * - undefined when setting
203 * @deprecated Since version 5.
207 Flash.prototype.src = function src(_src) {
208 if (_src === undefined) {
209 return this.currentSrc();
212 // Setting src through `src` not `setSrc` will be deprecated
213 return this.setSrc(_src);
217 * A getter/setter for the `Flash` Tech's source object.
219 * @param {Tech~SourceObject} [src]
220 * The source object you want to set on the `Flash` techs.
222 * @return {Tech~SourceObject|undefined}
223 * - The current source object when a source is not passed in.
224 * - undefined when setting
228 Flash.prototype.setSrc = function setSrc(src) {
231 // Make sure source URL is absolute.
232 src = Url.getAbsoluteURL(src);
233 this.el_.vjs_src(src);
235 // Currently the SWF doesn't autoplay if you load a source later.
236 // e.g. Load player w/ no source, wait 2s, set src.
237 if (this.autoplay()) {
238 this.setTimeout(function () {
239 return _this2.play();
245 * Indicates whether the media is currently seeking to a new position or not.
248 * - True if seeking to a new position
253 Flash.prototype.seeking = function seeking() {
254 return this.lastSeekTarget_ !== undefined;
258 * Returns the current time in seconds that the media is at in playback.
260 * @param {number} time
261 * Current playtime of the media in seconds.
265 Flash.prototype.setCurrentTime = function setCurrentTime(time) {
266 var seekable = this.seekable();
268 if (seekable.length) {
269 // clamp to the current seekable range
270 time = time > seekable.start(0) ? time : seekable.start(0);
271 time = time < seekable.end(seekable.length - 1) ? time : seekable.end(seekable.length - 1);
273 this.lastSeekTarget_ = time;
274 this.trigger('seeking');
275 this.el_.vjs_setProperty('currentTime', time);
276 _Tech.prototype.setCurrentTime.call(this);
281 * Get the current playback time in seconds
284 * The current time of playback in seconds.
288 Flash.prototype.currentTime = function currentTime() {
289 // when seeking make the reported time keep up with the requested time
290 // by reading the time we're seeking to
291 if (this.seeking()) {
292 return this.lastSeekTarget_ || 0;
294 return this.el_.vjs_getProperty('currentTime');
298 * Get the current source
301 * @return {Tech~SourceObject}
306 Flash.prototype.currentSrc = function currentSrc() {
307 if (this.currentSource_) {
308 return this.currentSource_.src;
310 return this.el_.vjs_getProperty('currentSrc');
314 * Get the total duration of the current media.
317 8 The total duration of the current media.
321 Flash.prototype.duration = function duration() {
322 if (this.readyState() === 0) {
325 var duration = this.el_.vjs_getProperty('duration');
327 return duration >= 0 ? duration : Infinity;
331 * Load media into Tech.
335 Flash.prototype.load = function load() {
340 * Get the poster image that was set on the tech.
344 Flash.prototype.poster = function poster() {
345 this.el_.vjs_getProperty('poster');
349 * Poster images are not handled by the Flash tech so make this is a no-op.
353 Flash.prototype.setPoster = function setPoster() {};
356 * Determine the time ranges that can be seeked to in the media.
358 * @return {TimeRange}
359 * Returns the time ranges that can be seeked to.
363 Flash.prototype.seekable = function seekable() {
364 var duration = this.duration();
366 if (duration === 0) {
367 return (0, _timeRanges.createTimeRange)();
369 return (0, _timeRanges.createTimeRange)(0, duration);
373 * Get and create a `TimeRange` object for buffering.
375 * @return {TimeRange}
376 * The time range object that was created.
380 Flash.prototype.buffered = function buffered() {
381 var ranges = this.el_.vjs_getProperty('buffered');
383 if (ranges.length === 0) {
384 return (0, _timeRanges.createTimeRange)();
386 return (0, _timeRanges.createTimeRange)(ranges[0][0], ranges[0][1]);
390 * Get fullscreen support -
392 * Flash does not allow fullscreen through javascript
393 * so this always returns false.
396 * The Flash tech does not support fullscreen, so it will always return false.
400 Flash.prototype.supportsFullScreen = function supportsFullScreen() {
401 // Flash does not allow fullscreen through javascript
406 * Flash does not allow fullscreen through javascript
407 * so this always returns false.
410 * The Flash tech does not support fullscreen, so it will always return false.
414 Flash.prototype.enterFullScreen = function enterFullScreen() {
419 }(_tech2['default']);
421 // Create setters and getters for attributes
424 var _api = Flash.prototype;
425 var _readWrite = 'rtmpConnection,rtmpStream,preload,defaultPlaybackRate,playbackRate,autoplay,loop,mediaGroup,controller,controls,volume,muted,defaultMuted'.split(',');
426 var _readOnly = 'networkState,readyState,initialTime,startOffsetTime,paused,ended,videoWidth,videoHeight'.split(',');
428 function _createSetter(attr) {
429 var attrUpper = attr.charAt(0).toUpperCase() + attr.slice(1);
431 _api['set' + attrUpper] = function (val) {
432 return this.el_.vjs_setProperty(attr, val);
436 function _createGetter(attr) {
437 _api[attr] = function () {
438 return this.el_.vjs_getProperty(attr);
442 // Create getter and setters for all read/write attributes
443 for (var i = 0; i < _readWrite.length; i++) {
444 _createGetter(_readWrite[i]);
445 _createSetter(_readWrite[i]);
448 // Create getters for read-only attributes
449 for (var _i = 0; _i < _readOnly.length; _i++) {
450 _createGetter(_readOnly[_i]);
453 /** ------------------------------ Getters ------------------------------ **/
455 * Get the value of `rtmpConnection` from the swf.
457 * @method Flash#rtmpConnection
459 * The current value of `rtmpConnection` on the swf.
463 * Get the value of `rtmpStream` from the swf.
465 * @method Flash#rtmpStream
467 * The current value of `rtmpStream` on the swf.
471 * Get the value of `preload` from the swf. `preload` indicates
472 * what should download before the media is interacted with. It can have the following
474 * - none: nothing should be downloaded
475 * - metadata: poster and the first few frames of the media may be downloaded to get
476 * media dimensions and other metadata
477 * - auto: allow the media and metadata for the media to be downloaded before
480 * @method Flash#preload
482 * The value of `preload` from the swf. Will be 'none', 'metadata',
487 * Get the value of `defaultPlaybackRate` from the swf.
489 * @method Flash#defaultPlaybackRate
491 * The current value of `defaultPlaybackRate` on the swf.
495 * Get the value of `playbackRate` from the swf. `playbackRate` indicates
496 * the rate at which the media is currently playing back. Examples:
497 * - if playbackRate is set to 2, media will play twice as fast.
498 * - if playbackRate is set to 0.5, media will play half as fast.
500 * @method Flash#playbackRate
502 * The value of `playbackRate` from the swf. A number indicating
503 * the current playback speed of the media, where 1 is normal speed.
507 * Get the value of `autoplay` from the swf. `autoplay` indicates
508 * that the media should start to play as soon as the page is ready.
510 * @method Flash#autoplay
512 * - The value of `autoplay` from the swf.
513 * - True indicates that the media ashould start as soon as the page loads.
514 * - False indicates that the media should not start as soon as the page loads.
518 * Get the value of `loop` from the swf. `loop` indicates
519 * that the media should return to the start of the media and continue playing once
520 * it reaches the end.
524 * - The value of `loop` from the swf.
525 * - True indicates that playback should seek back to start once
526 * the end of a media is reached.
527 * - False indicates that playback should not loop back to the start when the
528 * end of the media is reached.
532 * Get the value of `mediaGroup` from the swf.
534 * @method Flash#mediaGroup
536 * The current value of `mediaGroup` on the swf.
540 * Get the value of `controller` from the swf.
542 * @method Flash#controller
544 * The current value of `controller` on the swf.
548 * Get the value of `controls` from the swf. `controls` indicates
549 * whether the native flash controls should be shown or hidden.
551 * @method Flash#controls
553 * - The value of `controls` from the swf.
554 * - True indicates that native controls should be showing.
555 * - False indicates that native controls should be hidden.
559 * Get the value of the `volume` from the swf. `volume` indicates the current
560 * audio level as a percentage in decimal form. This means that 1 is 100%, 0.5 is 50%, and
563 * @method Flash#volume
565 * The volume percent as a decimal. Value will be between 0-1.
569 * Get the value of the `muted` from the swf. `muted` indicates the current
570 * audio level should be silent.
572 * @method Flash#muted
574 * - True if the audio should be set to silent
579 * Get the value of `defaultMuted` from the swf. `defaultMuted` indicates
580 * whether the media should start muted or not. Only changes the default state of the
581 * media. `muted` and `defaultMuted` can have different values. `muted` indicates the
584 * @method Flash#defaultMuted
586 * - The value of `defaultMuted` from the swf.
587 * - True indicates that the media should start muted.
588 * - False indicates that the media should not start muted.
592 * Get the value of `networkState` from the swf. `networkState` indicates
593 * the current network state. It returns an enumeration from the following list:
596 * - 2: NETWORK_LOADING
597 * - 3: NETWORK_NO_SOURCE
599 * @method Flash#networkState
601 * The value of `networkState` from the swf. This will be a number
602 * from the list in the description.
606 * Get the value of `readyState` from the swf. `readyState` indicates
607 * the current state of the media element. It returns an enumeration from the
611 * - 2: HAVE_CURRENT_DATA
612 * - 3: HAVE_FUTURE_DATA
613 * - 4: HAVE_ENOUGH_DATA
615 * @method Flash#readyState
617 * The value of `readyState` from the swf. This will be a number
618 * from the list in the description.
622 * Get the value of `readyState` from the swf. `readyState` indicates
623 * the current state of the media element. It returns an enumeration from the
627 * - 2: HAVE_CURRENT_DATA
628 * - 3: HAVE_FUTURE_DATA
629 * - 4: HAVE_ENOUGH_DATA
631 * @method Flash#readyState
633 * The value of `readyState` from the swf. This will be a number
634 * from the list in the description.
638 * Get the value of `initialTime` from the swf.
640 * @method Flash#initialTime
642 * The `initialTime` proprety on the swf.
646 * Get the value of `startOffsetTime` from the swf.
648 * @method Flash#startOffsetTime
650 * The `startOffsetTime` proprety on the swf.
654 * Get the value of `paused` from the swf. `paused` indicates whether the swf
655 * is current paused or not.
657 * @method Flash#paused
659 * The value of `paused` from the swf.
663 * Get the value of `ended` from the swf. `ended` indicates whether
664 * the media has reached the end or not.
666 * @method Flash#ended
668 * - True indicates that the media has ended.
669 * - False indicates that the media has not ended.
671 * @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-media-ended}
675 * Get the value of `videoWidth` from the swf. `videoWidth` indicates
676 * the current width of the media in css pixels.
678 * @method Flash#videoWidth
680 * The value of `videoWidth` from the swf. This will be a number
685 * Get the value of `videoHeight` from the swf. `videoHeigth` indicates
686 * the current height of the media in css pixels.
688 * @method Flassh.prototype.videoHeight
690 * The value of `videoHeight` from the swf. This will be a number
693 /** ------------------------------ Setters ------------------------------ **/
696 * Set the value of `rtmpConnection` on the swf.
698 * @method Flash#setRtmpConnection
699 * @param {string} rtmpConnection
700 * New value to set the `rtmpConnection` property to.
704 * Set the value of `rtmpStream` on the swf.
706 * @method Flash#setRtmpStream
707 * @param {string} rtmpStream
708 * New value to set the `rtmpStream` property to.
712 * Set the value of `preload` on the swf. `preload` indicates
713 * what should download before the media is interacted with. It can have the following
715 * - none: nothing should be downloaded
716 * - metadata: poster and the first few frames of the media may be downloaded to get
717 * media dimensions and other metadata
718 * - auto: allow the media and metadata for the media to be downloaded before
721 * @method Flash#setPreload
722 * @param {string} preload
723 * The value of `preload` to set on the swf. Should be 'none', 'metadata',
728 * Set the value of `defaultPlaybackRate` on the swf.
730 * @method Flash#setDefaultPlaybackRate
731 * @param {number} defaultPlaybackRate
732 * New value to set the `defaultPlaybackRate` property to.
736 * Set the value of `playbackRate` on the swf. `playbackRate` indicates
737 * the rate at which the media is currently playing back. Examples:
738 * - if playbackRate is set to 2, media will play twice as fast.
739 * - if playbackRate is set to 0.5, media will play half as fast.
741 * @method Flash#setPlaybackRate
742 * @param {number} playbackRate
743 * New value of `playbackRate` on the swf. A number indicating
744 * the current playback speed of the media, where 1 is normal speed.
748 * Set the value of `autoplay` on the swf. `autoplay` indicates
749 * that the media should start to play as soon as the page is ready.
751 * @method Flash#setAutoplay
752 * @param {boolean} autoplay
753 * - The value of `autoplay` from the swf.
754 * - True indicates that the media ashould start as soon as the page loads.
755 * - False indicates that the media should not start as soon as the page loads.
759 * Set the value of `loop` on the swf. `loop` indicates
760 * that the media should return to the start of the media and continue playing once
761 * it reaches the end.
763 * @method Flash#setLoop
764 * @param {boolean} loop
765 * - True indicates that playback should seek back to start once
766 * the end of a media is reached.
767 * - False indicates that playback should not loop back to the start when the
768 * end of the media is reached.
772 * Set the value of `mediaGroup` on the swf.
774 * @method Flash#setMediaGroup
775 * @param {string} mediaGroup
776 * New value of `mediaGroup` to set on the swf.
780 * Set the value of `controller` on the swf.
782 * @method Flash#setController
783 * @param {string} controller
784 * New value the current value of `controller` on the swf.
788 * Get the value of `controls` from the swf. `controls` indicates
789 * whether the native flash controls should be shown or hidden.
791 * @method Flash#controls
793 * - The value of `controls` from the swf.
794 * - True indicates that native controls should be showing.
795 * - False indicates that native controls should be hidden.
799 * Set the value of the `volume` on the swf. `volume` indicates the current
800 * audio level as a percentage in decimal form. This means that 1 is 100%, 0.5 is 50%, and
803 * @method Flash#setVolume
804 * @param {number} percentAsDecimal
805 * The volume percent as a decimal. Value will be between 0-1.
809 * Set the value of the `muted` on the swf. `muted` indicates that the current
810 * audio level should be silent.
812 * @method Flash#setMuted
813 * @param {boolean} muted
814 * - True if the audio should be set to silent
819 * Set the value of `defaultMuted` on the swf. `defaultMuted` indicates
820 * whether the media should start muted or not. Only changes the default state of the
821 * media. `muted` and `defaultMuted` can have different values. `muted` indicates the
824 * @method Flash#setDefaultMuted
825 * @param {boolean} defaultMuted
826 * - True indicates that the media should start muted.
827 * - False indicates that the media should not start muted.
830 /* Flash Support Testing -------------------------------------------------------- */
833 * Check if the Flash tech is currently supported.
836 * - True if the flash tech is supported.
839 Flash.isSupported = function () {
840 return Flash.version()[0] >= 10;
841 // return swfobject.hasFlashPlayerVersion('10');
844 // Add Source Handler pattern functions to this tech
845 _tech2['default'].withSourceHandlers(Flash);
848 * Native source handler for flash, simply passes the source to the swf element.
850 * @property {Tech~SourceObject} source
853 * @property {Flash} tech
854 * The instance of the Flash tech
856 Flash.nativeSourceHandler = {};
859 * Check if the Flash can play the given mime type.
861 * @param {string} type
862 * The mimetype to check
865 * 'maybe', or '' (empty string)
867 Flash.nativeSourceHandler.canPlayType = function (type) {
868 if (type in Flash.formats) {
876 * Check if the media element can handle a source natively.
878 * @param {Tech~SourceObject} source
881 * @param {Object} [options]
882 * Options to be passed to the tech.
885 * 'maybe', or '' (empty string).
887 Flash.nativeSourceHandler.canHandleSource = function (source, options) {
890 function guessMimeType(src) {
891 var ext = Url.getFileExtension(src);
894 return 'video/' + ext;
900 type = guessMimeType(source.src);
902 // Strip code information from the type because we don't get that specific
903 type = source.type.replace(/;.*/, '').toLowerCase();
906 return Flash.nativeSourceHandler.canPlayType(type);
910 * Pass the source to the swf.
912 * @param {Tech~SourceObject} source
915 * @param {Flash} tech
916 * The instance of the Flash tech
918 * @param {Object} [options]
919 * The options to pass to the source
921 Flash.nativeSourceHandler.handleSource = function (source, tech, options) {
922 tech.setSrc(source.src);
926 * noop for native source handler dispose, as cleanup will happen automatically.
928 Flash.nativeSourceHandler.dispose = function () {};
930 // Register the native source handler
931 Flash.registerSourceHandler(Flash.nativeSourceHandler);
934 * Flash supported mime types.
940 'video/x-flv': 'FLV',
946 * Called when the the swf is "ready", and makes sure that the swf is really
947 * ready using {@link Flash#checkReady}
949 Flash.onReady = function (currSwf) {
950 var el = Dom.getEl(currSwf);
951 var tech = el && el.tech;
953 // if there is no el then the tech has been disposed
954 // and the tech element was removed from the player div
955 if (tech && tech.el()) {
956 // check that the flash object is really ready
957 Flash.checkReady(tech);
962 * The SWF isn't always ready when it says it is. Sometimes the API functions still
963 * need to be added to the object. If it's not ready, we set a timeout to check again
966 * @param {Flash} tech
967 * The instance of the flash tech to check.
969 Flash.checkReady = function (tech) {
970 // stop worrying if the tech has been disposed
975 // check if API property exists
976 if (tech.el().vjs_getProperty) {
977 // tell tech it's ready
981 this.setTimeout(function () {
982 Flash.checkReady(tech);
988 * Trigger events from the swf on the Flash Tech.
990 * @param {number} swfID
991 * The id of the swf that had the event
993 * @param {string} eventName
994 * The name of the event to trigger
996 Flash.onEvent = function (swfID, eventName) {
997 var tech = Dom.getEl(swfID).tech;
998 var args = Array.prototype.slice.call(arguments, 2);
1000 // dispatch Flash events asynchronously for two reasons:
1001 // - Flash swallows any exceptions generated by javascript it
1003 // - Flash is suspended until the javascript returns which may cause
1004 // playback performance issues
1005 tech.setTimeout(function () {
1006 tech.trigger(eventName, args);
1011 * Log errors from the swf on the Flash tech.
1013 * @param {number} swfID
1014 * The id of the swf that had an error.
1016 * @param {string} The error string
1017 * The error to set on the Flash Tech.
1019 * @return {MediaError|undefined}
1020 * - Returns a MediaError when err is 'srcnotfound'
1021 * - Returns undefined otherwise.
1023 Flash.onError = function (swfID, err) {
1024 var tech = Dom.getEl(swfID).tech;
1026 // trigger MEDIA_ERR_SRC_NOT_SUPPORTED
1027 if (err === 'srcnotfound') {
1028 return tech.error(4);
1031 // trigger a custom error
1032 tech.error('FLASH: ' + err);
1036 * Get the current version of Flash that is in use on the page.
1039 * an array of versions that are available.
1041 Flash.version = function () {
1042 var version = '0,0,0';
1046 version = new _window2['default'].ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
1051 if (navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin) {
1052 version = (navigator.plugins['Shockwave Flash 2.0'] || navigator.plugins['Shockwave Flash']).description.replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
1058 return version.split(',');
1062 * Only use for non-iframe embeds.
1064 * @param {Object} swf
1065 * The videojs-swf object.
1067 * @param {Object} flashVars
1068 * Names and values to use as flash option variables.
1070 * @param {Object} params
1071 * Style parameters to set on the object.
1073 * @param {Object} attributes
1074 * Attributes to set on the element.
1077 * The embeded Flash DOM element.
1079 Flash.embed = function (swf, flashVars, params, attributes) {
1080 var code = Flash.getEmbedCode(swf, flashVars, params, attributes);
1082 // Get element by embedding code and retrieving created element
1083 var obj = Dom.createEl('div', { innerHTML: code }).childNodes[0];
1089 * Only use for non-iframe embeds.
1091 * @param {Object} swf
1092 * The videojs-swf object.
1094 * @param {Object} flashVars
1095 * Names and values to use as flash option variables.
1097 * @param {Object} params
1098 * Style parameters to set on the object.
1100 * @param {Object} attributes
1101 * Attributes to set on the element.
1104 * The embeded Flash DOM element.
1106 Flash.getEmbedCode = function (swf, flashVars, params, attributes) {
1107 var objTag = '<object type="application/x-shockwave-flash" ';
1108 var flashVarsString = '';
1109 var paramsString = '';
1110 var attrsString = '';
1112 // Convert flash vars to string
1114 Object.getOwnPropertyNames(flashVars).forEach(function (key) {
1115 flashVarsString += key + '=' + flashVars[key] + '&';
1119 // Add swf, flashVars, and other default params
1120 params = (0, _obj.assign)({
1122 flashvars: flashVarsString,
1123 // Required to talk to swf
1124 allowScriptAccess: 'always',
1125 // All should be default, but having security issues.
1126 allowNetworking: 'all'
1129 // Create param tags string
1130 Object.getOwnPropertyNames(params).forEach(function (key) {
1131 paramsString += '<param name="' + key + '" value="' + params[key] + '" />';
1134 attributes = (0, _obj.assign)({
1135 // Add swf to attributes (need both for IE and Others to work)
1138 // Default to 100% width/height
1144 // Create Attributes string
1145 Object.getOwnPropertyNames(attributes).forEach(function (key) {
1146 attrsString += key + '="' + attributes[key] + '" ';
1149 return '' + objTag + attrsString + '>' + paramsString + '</object>';
1152 // Run Flash through the RTMP decorator
1153 (0, _flashRtmp2['default'])(Flash);
1155 _component2['default'].registerComponent('Flash', Flash);
1156 _tech2['default'].registerTech('Flash', Flash);
1157 exports['default'] = Flash;