1 | /**
|
2 | * videojs-flash
|
3 | * @version 2.0.1
|
4 | * @copyright 2017 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 |
|
13 | videojs = 'default' in videojs ? videojs['default'] : videojs;
|
14 |
|
15 | var version = "5.4.1";
|
16 |
|
17 | var version$1 = "2.0.1";
|
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 | */
|
35 | function 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 |
|
223 | var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
224 |
|
225 | var win;
|
226 |
|
227 | if (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 |
|
237 | var window_1 = win;
|
238 |
|
239 | var 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 |
|
255 | var 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 |
|
281 | var 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 |
|
296 | var Tech = videojs.getComponent('Tech');
|
297 | var Dom = videojs.dom;
|
298 | var Url = videojs.url;
|
299 | var createTimeRange = videojs.createTimeRange;
|
300 | var mergeOptions = videojs.mergeOptions;
|
301 |
|
302 | var 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 |
|
312 | var 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 | });
|
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 = '//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}
|
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 |
|
696 | var _readWrite = ['rtmpConnection', 'rtmpStream', 'preload', 'defaultPlaybackRate', 'playbackRate', 'autoplay', 'loop', 'controls', 'volume', 'muted', 'defaultMuted'];
|
697 | var _readOnly = ['networkState', 'readyState', 'initialTime', 'startOffsetTime', 'paused', 'ended', 'videoWidth', 'videoHeight'];
|
698 | var _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 | */
|
708 | function _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 | */
|
724 | function _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
|
731 | for (var i = 0; i < _readWrite.length; i++) {
|
732 | _createGetter(_readWrite[i]);
|
733 | _createSetter(_readWrite[i]);
|
734 | }
|
735 |
|
736 | // Create getters for read-only attributes
|
737 | for (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 if the flash tech is supported.
|
1125 | * - False otherwise.
|
1126 | */
|
1127 | Flash.isSupported = function () {
|
1128 | return Flash.version()[0] >= 10;
|
1129 | // return swfobject.hasFlashPlayerVersion('10');
|
1130 | };
|
1131 |
|
1132 | // Add Source Handler pattern functions to this tech
|
1133 | Tech.withSourceHandlers(Flash);
|
1134 |
|
1135 | /*
|
1136 | * Native source handler for flash, simply passes the source to the swf element.
|
1137 | *
|
1138 | * @property {Tech~SourceObject} source
|
1139 | * The source object
|
1140 | *
|
1141 | * @property {Flash} tech
|
1142 | * The instance of the Flash tech
|
1143 | */
|
1144 | Flash.nativeSourceHandler = {};
|
1145 |
|
1146 | /**
|
1147 | * Check if the Flash can play the given mime type.
|
1148 | *
|
1149 | * @param {string} type
|
1150 | * The mimetype to check
|
1151 | *
|
1152 | * @return {string}
|
1153 | * 'maybe', or '' (empty string)
|
1154 | */
|
1155 | Flash.nativeSourceHandler.canPlayType = function (type) {
|
1156 | if (type in Flash.formats) {
|
1157 | return 'maybe';
|
1158 | }
|
1159 |
|
1160 | return '';
|
1161 | };
|
1162 |
|
1163 | /**
|
1164 | * Check if the media element can handle a source natively.
|
1165 | *
|
1166 | * @param {Tech~SourceObject} source
|
1167 | * The source object
|
1168 | *
|
1169 | * @param {Object} [options]
|
1170 | * Options to be passed to the tech.
|
1171 | *
|
1172 | * @return {string}
|
1173 | * 'maybe', or '' (empty string).
|
1174 | */
|
1175 | Flash.nativeSourceHandler.canHandleSource = function (source, options) {
|
1176 | var type = void 0;
|
1177 |
|
1178 | /**
|
1179 | * Guess the mime type of a file if it does not have one
|
1180 | *
|
1181 | * @param {Tech~SourceObject} src
|
1182 | * The source object to guess the mime type for
|
1183 | *
|
1184 | * @return {string}
|
1185 | * The mime type that was guessed
|
1186 | */
|
1187 | function guessMimeType(src) {
|
1188 | var ext = Url.getFileExtension(src);
|
1189 |
|
1190 | if (ext) {
|
1191 | return 'video/' + ext;
|
1192 | }
|
1193 | return '';
|
1194 | }
|
1195 |
|
1196 | if (!source.type) {
|
1197 | type = guessMimeType(source.src);
|
1198 | } else {
|
1199 | // Strip code information from the type because we don't get that specific
|
1200 | type = source.type.replace(/;.*/, '').toLowerCase();
|
1201 | }
|
1202 |
|
1203 | return Flash.nativeSourceHandler.canPlayType(type);
|
1204 | };
|
1205 |
|
1206 | /**
|
1207 | * Pass the source to the swf.
|
1208 | *
|
1209 | * @param {Tech~SourceObject} source
|
1210 | * The source object
|
1211 | *
|
1212 | * @param {Flash} tech
|
1213 | * The instance of the Flash tech
|
1214 | *
|
1215 | * @param {Object} [options]
|
1216 | * The options to pass to the source
|
1217 | */
|
1218 | Flash.nativeSourceHandler.handleSource = function (source, tech, options) {
|
1219 | tech.setSrc(source.src);
|
1220 | };
|
1221 |
|
1222 | /**
|
1223 | * noop for native source handler dispose, as cleanup will happen automatically.
|
1224 | */
|
1225 | Flash.nativeSourceHandler.dispose = function () {};
|
1226 |
|
1227 | // Register the native source handler
|
1228 | Flash.registerSourceHandler(Flash.nativeSourceHandler);
|
1229 |
|
1230 | /**
|
1231 | * Flash supported mime types.
|
1232 | *
|
1233 | * @constant {Object}
|
1234 | */
|
1235 | Flash.formats = {
|
1236 | 'video/flv': 'FLV',
|
1237 | 'video/x-flv': 'FLV',
|
1238 | 'video/mp4': 'MP4',
|
1239 | 'video/m4v': 'MP4'
|
1240 | };
|
1241 |
|
1242 | /**
|
1243 | * Called when the the swf is "ready", and makes sure that the swf is really
|
1244 | * ready using {@link Flash#checkReady}
|
1245 | *
|
1246 | * @param {Object} currSwf
|
1247 | * The current swf object
|
1248 | */
|
1249 | Flash.onReady = function (currSwf) {
|
1250 | var el = Dom.$('#' + currSwf);
|
1251 | var tech = el && el.tech;
|
1252 |
|
1253 | // if there is no el then the tech has been disposed
|
1254 | // and the tech element was removed from the player div
|
1255 | if (tech && tech.el()) {
|
1256 | // check that the flash object is really ready
|
1257 | Flash.checkReady(tech);
|
1258 | }
|
1259 | };
|
1260 |
|
1261 | /**
|
1262 | * The SWF isn't always ready when it says it is. Sometimes the API functions still
|
1263 | * need to be added to the object. If it's not ready, we set a timeout to check again
|
1264 | * shortly.
|
1265 | *
|
1266 | * @param {Flash} tech
|
1267 | * The instance of the flash tech to check.
|
1268 | */
|
1269 | Flash.checkReady = function (tech) {
|
1270 | // stop worrying if the tech has been disposed
|
1271 | if (!tech.el()) {
|
1272 | return;
|
1273 | }
|
1274 |
|
1275 | // check if API property exists
|
1276 | if (tech.el().vjs_getProperty) {
|
1277 | // tell tech it's ready
|
1278 | tech.triggerReady();
|
1279 | } else {
|
1280 | // wait longer
|
1281 | this.setTimeout(function () {
|
1282 | Flash.checkReady(tech);
|
1283 | }, 50);
|
1284 | }
|
1285 | };
|
1286 |
|
1287 | /**
|
1288 | * Trigger events from the swf on the Flash Tech.
|
1289 | *
|
1290 | * @param {number} swfID
|
1291 | * The id of the swf that had the event
|
1292 | *
|
1293 | * @param {string} eventName
|
1294 | * The name of the event to trigger
|
1295 | */
|
1296 | Flash.onEvent = function (swfID, eventName) {
|
1297 | var tech = Dom.$('#' + swfID).tech;
|
1298 | var args = Array.prototype.slice.call(arguments, 2);
|
1299 |
|
1300 | // dispatch Flash events asynchronously for two reasons:
|
1301 | // - Flash swallows any exceptions generated by javascript it
|
1302 | // invokes
|
1303 | // - Flash is suspended until the javascript returns which may cause
|
1304 | // playback performance issues
|
1305 | tech.setTimeout(function () {
|
1306 | tech.trigger(eventName, args);
|
1307 | }, 1);
|
1308 | };
|
1309 |
|
1310 | /**
|
1311 | * Log errors from the swf on the Flash tech.
|
1312 | *
|
1313 | * @param {number} swfID
|
1314 | * The id of the swf that had an error.
|
1315 | *
|
1316 | * @param {string} err
|
1317 | * The error to set on the Flash Tech.
|
1318 | *
|
1319 | * @return {MediaError|undefined}
|
1320 | * - Returns a MediaError when err is 'srcnotfound'
|
1321 | * - Returns undefined otherwise.
|
1322 | */
|
1323 | Flash.onError = function (swfID, err) {
|
1324 | var tech = Dom.$('#' + swfID).tech;
|
1325 |
|
1326 | // trigger MEDIA_ERR_SRC_NOT_SUPPORTED
|
1327 | if (err === 'srcnotfound') {
|
1328 | return tech.error(4);
|
1329 | }
|
1330 |
|
1331 | // trigger a custom error
|
1332 | tech.error('FLASH: ' + err);
|
1333 | };
|
1334 |
|
1335 | /**
|
1336 | * Get the current version of Flash that is in use on the page.
|
1337 | *
|
1338 | * @return {Array}
|
1339 | * an array of versions that are available.
|
1340 | */
|
1341 | Flash.version = function () {
|
1342 | var version$$1 = '0,0,0';
|
1343 |
|
1344 | // IE
|
1345 | try {
|
1346 | version$$1 = new window_1.ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
|
1347 |
|
1348 | // other browsers
|
1349 | } catch (e) {
|
1350 | try {
|
1351 | if (navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin) {
|
1352 | version$$1 = (navigator.plugins['Shockwave Flash 2.0'] || navigator.plugins['Shockwave Flash']).description.replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
|
1353 | }
|
1354 | } catch (err) {
|
1355 | // satisfy linter
|
1356 | }
|
1357 | }
|
1358 | return version$$1.split(',');
|
1359 | };
|
1360 |
|
1361 | /**
|
1362 | * Only use for non-iframe embeds.
|
1363 | *
|
1364 | * @param {Object} swf
|
1365 | * The videojs-swf object.
|
1366 | *
|
1367 | * @param {Object} flashVars
|
1368 | * Names and values to use as flash option variables.
|
1369 | *
|
1370 | * @param {Object} params
|
1371 | * Style parameters to set on the object.
|
1372 | *
|
1373 | * @param {Object} attributes
|
1374 | * Attributes to set on the element.
|
1375 | *
|
1376 | * @return {Element}
|
1377 | * The embeded Flash DOM element.
|
1378 | */
|
1379 | Flash.embed = function (swf, flashVars, params, attributes) {
|
1380 | var code = Flash.getEmbedCode(swf, flashVars, params, attributes);
|
1381 |
|
1382 | // Get element by embedding code and retrieving created element
|
1383 | var obj = Dom.createEl('div', { innerHTML: code }).childNodes[0];
|
1384 |
|
1385 | return obj;
|
1386 | };
|
1387 |
|
1388 | /**
|
1389 | * Only use for non-iframe embeds.
|
1390 | *
|
1391 | * @param {Object} swf
|
1392 | * The videojs-swf object.
|
1393 | *
|
1394 | * @param {Object} flashVars
|
1395 | * Names and values to use as flash option variables.
|
1396 | *
|
1397 | * @param {Object} params
|
1398 | * Style parameters to set on the object.
|
1399 | *
|
1400 | * @param {Object} attributes
|
1401 | * Attributes to set on the element.
|
1402 | *
|
1403 | * @return {Element}
|
1404 | * The embeded Flash DOM element.
|
1405 | */
|
1406 | Flash.getEmbedCode = function (swf, flashVars, params, attributes) {
|
1407 | var objTag = '<object type="application/x-shockwave-flash" ';
|
1408 | var flashVarsString = '';
|
1409 | var paramsString = '';
|
1410 | var attrsString = '';
|
1411 |
|
1412 | // Convert flash vars to string
|
1413 | if (flashVars) {
|
1414 | Object.getOwnPropertyNames(flashVars).forEach(function (key) {
|
1415 | flashVarsString += key + '=' + flashVars[key] + '&';
|
1416 | });
|
1417 | }
|
1418 |
|
1419 | // Add swf, flashVars, and other default params
|
1420 | params = mergeOptions({
|
1421 | movie: swf,
|
1422 | flashvars: flashVarsString,
|
1423 | // Required to talk to swf
|
1424 | allowScriptAccess: 'always',
|
1425 | // All should be default, but having security issues.
|
1426 | allowNetworking: 'all'
|
1427 | }, params);
|
1428 |
|
1429 | // Create param tags string
|
1430 | Object.getOwnPropertyNames(params).forEach(function (key) {
|
1431 | paramsString += '<param name="' + key + '" value="' + params[key] + '" />';
|
1432 | });
|
1433 |
|
1434 | attributes = mergeOptions({
|
1435 | // Add swf to attributes (need both for IE and Others to work)
|
1436 | data: swf,
|
1437 |
|
1438 | // Default to 100% width/height
|
1439 | width: '100%',
|
1440 | height: '100%'
|
1441 |
|
1442 | }, attributes);
|
1443 |
|
1444 | // Create Attributes string
|
1445 | Object.getOwnPropertyNames(attributes).forEach(function (key) {
|
1446 | attrsString += key + '="' + attributes[key] + '" ';
|
1447 | });
|
1448 |
|
1449 | return '' + objTag + attrsString + '>' + paramsString + '</object>';
|
1450 | };
|
1451 |
|
1452 | // Run Flash through the RTMP decorator
|
1453 | FlashRtmpDecorator(Flash);
|
1454 |
|
1455 | if (Tech.getTech('Flash')) {
|
1456 | videojs.log.warn('Not using videojs-flash as it appears to already be registered');
|
1457 | videojs.log.warn('videojs-flash should only be used with video.js@6 and above');
|
1458 | } else {
|
1459 | videojs.registerTech('Flash', Flash);
|
1460 | }
|
1461 |
|
1462 | Flash.VERSION = version$1;
|
1463 |
|
1464 | return Flash;
|
1465 |
|
1466 | })));
|