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