diff --git a/Gruntfile.js b/Gruntfile.js
index 5b81dc7..518a9ac 100644
a
|
b
|
module.exports = function(grunt) { |
177 | 177 | grunt.registerTask('default', ['concat', 'removelogging', 'uglify', 'cssmin', 'copy', |
178 | 178 | 'shell:buildFlash', 'replace:cdnBuild', 'shell:buildFlashCDN', 'clean:temp']); |
179 | 179 | |
| 180 | grunt.registerTask('noflash', ['concat', 'removelogging', 'uglify', 'cssmin', 'copy', 'clean:temp']); |
180 | 181 | }; |
| 182 | No newline at end of file |
diff --git a/src/js/me-shim.js b/src/js/me-shim.js
index ba3ee16..46b08f3 100644
a
|
b
|
mejs.MediaPluginBridge = { |
31 | 31 | pluginMediaElement.pluginApi = pluginMediaElement.pluginElement.Content.MediaElementJS; |
32 | 32 | break; |
33 | 33 | } |
34 | | |
| 34 | |
35 | 35 | if (pluginMediaElement.pluginApi != null && pluginMediaElement.success) { |
36 | 36 | pluginMediaElement.success(pluginMediaElement, htmlMediaElement); |
37 | 37 | } |
… |
… |
mejs.MediaPluginBridge = { |
51 | 51 | if(!pluginMediaElement){ |
52 | 52 | return; |
53 | 53 | } |
54 | | |
| 54 | |
55 | 55 | // fake event object to mimic real HTML media event. |
56 | 56 | e = { |
57 | 57 | type: eventName, |
… |
… |
mejs.MediaElementDefaults = { |
123 | 123 | // overrides <video height> |
124 | 124 | pluginHeight: -1, |
125 | 125 | // additional plugin variables in 'key=value' form |
126 | | pluginVars: [], |
| 126 | pluginVars: [], |
127 | 127 | // rate in milliseconds for Flash and Silverlight to fire the timeupdate event |
128 | 128 | // larger number is less accurate, but less strain on plugin->JavaScript bridge |
129 | 129 | timerRate: 250, |
… |
… |
mejs.HtmlMediaElementShim = { |
164 | 164 | } |
165 | 165 | |
166 | 166 | // clean up attributes |
167 | | src = (typeof src == 'undefined' || src === null || src == '') ? null : src; |
| 167 | src = (typeof src == 'undefined' || src === null || src == '') ? null : src; |
168 | 168 | poster = (typeof poster == 'undefined' || poster === null) ? '' : poster; |
169 | 169 | preload = (typeof preload == 'undefined' || preload === null || preload === 'false') ? 'none' : preload; |
170 | 170 | autoplay = !(typeof autoplay == 'undefined' || autoplay === null || autoplay === 'false'); |
… |
… |
mejs.HtmlMediaElementShim = { |
182 | 182 | htmlMediaElement.play(); |
183 | 183 | }, false); |
184 | 184 | } |
185 | | |
| 185 | |
186 | 186 | // add methods to native HTMLMediaElement |
187 | 187 | return this.updateNative(playback, options, autoplay, preload); |
188 | 188 | } else if (playback.method !== '') { |
189 | 189 | // create plugin to mimic HTMLMediaElement |
190 | | |
| 190 | |
191 | 191 | return this.createPlugin( playback, options, poster, autoplay, preload, controls); |
192 | 192 | } else { |
193 | 193 | // boo, no HTML5, no Flash, no Silverlight. |
194 | 194 | this.createErrorMessage( playback, options, poster ); |
195 | | |
| 195 | |
196 | 196 | return this; |
197 | 197 | } |
198 | 198 | }, |
199 | | |
| 199 | |
200 | 200 | determinePlayback: function(htmlMediaElement, options, supportsMediaTag, isMediaTag, src) { |
201 | 201 | var |
202 | 202 | mediaFiles = [], |
… |
… |
mejs.HtmlMediaElementShim = { |
212 | 212 | pluginInfo, |
213 | 213 | dummy, |
214 | 214 | media; |
215 | | |
| 215 | |
216 | 216 | // STEP 1: Get URL and type from <video src> or <source src> |
217 | 217 | |
218 | 218 | // supplied type overrides <video type> and <source type> |
219 | 219 | if (typeof options.type != 'undefined' && options.type !== '') { |
220 | | |
| 220 | |
221 | 221 | // accept either string or array of types |
222 | 222 | if (typeof options.type == 'string') { |
223 | 223 | mediaFiles.push({type:options.type, url:src}); |
224 | 224 | } else { |
225 | | |
| 225 | |
226 | 226 | for (i=0; i<options.type.length; i++) { |
227 | 227 | mediaFiles.push({type:options.type[i], url:src}); |
228 | 228 | } |
… |
… |
mejs.HtmlMediaElementShim = { |
249 | 249 | } |
250 | 250 | } |
251 | 251 | } |
252 | | |
| 252 | |
253 | 253 | // in the case of dynamicly created players |
254 | 254 | // check for audio types |
255 | 255 | if (!isMediaTag && mediaFiles.length > 0 && mediaFiles[0].url !== null && this.getTypeFromFile(mediaFiles[0].url).indexOf('audio') > -1) { |
256 | 256 | result.isVideo = false; |
257 | 257 | } |
258 | | |
| 258 | |
259 | 259 | |
260 | 260 | // STEP 2: Test for playback method |
261 | | |
| 261 | |
262 | 262 | // special case for Android which sadly doesn't implement the canPlayType function (always returns '') |
263 | 263 | if (mejs.MediaFeatures.isBustedAndroid) { |
264 | 264 | htmlMediaElement.canPlayType = function(type) { |
265 | 265 | return (type.match(/video\/(mp4|m4v)/gi) !== null) ? 'maybe' : ''; |
266 | 266 | }; |
267 | | } |
268 | | |
269 | | // special case for Chromium to specify natively supported video codecs (i.e. WebM and Theora) |
270 | | if (mejs.MediaFeatures.isChromium) { |
271 | | htmlMediaElement.canPlayType = function(type) { |
272 | | return (type.match(/video\/(webm|ogv|ogg)/gi) !== null) ? 'maybe' : ''; |
273 | | }; |
274 | 267 | } |
275 | 268 | |
| 269 | // special case for Chromium to specify natively supported video codecs (i.e. WebM and Theora) |
| 270 | //if (mejs.MediaFeatures.isChromium) { |
| 271 | // htmlMediaElement.canPlayType = function(type) { |
| 272 | // return (type.match(/video\/(webm|ogv|ogg)/gi) !== null) ? 'maybe' : ''; |
| 273 | // }; |
| 274 | //} |
| 275 | |
276 | 276 | // test for native playback first |
277 | 277 | if (supportsMediaTag && (options.mode === 'auto' || options.mode === 'auto_plugin' || options.mode === 'native') && !(mejs.MediaFeatures.isBustedNativeHTTPS && options.httpsBasicAuthSite === true)) { |
278 | | |
| 278 | |
279 | 279 | if (!isMediaTag) { |
280 | 280 | |
281 | | // create a real HTML5 Media Element |
282 | | dummy = document.createElement( result.isVideo ? 'video' : 'audio'); |
| 281 | // create a real HTML5 Media Element |
| 282 | dummy = document.createElement( result.isVideo ? 'video' : 'audio'); |
283 | 283 | htmlMediaElement.parentNode.insertBefore(dummy, htmlMediaElement); |
284 | 284 | htmlMediaElement.style.display = 'none'; |
285 | | |
| 285 | |
286 | 286 | // use this one from now on |
287 | 287 | result.htmlMediaElement = htmlMediaElement = dummy; |
288 | 288 | } |
289 | | |
| 289 | |
290 | 290 | for (i=0; i<mediaFiles.length; i++) { |
291 | 291 | // normal check |
292 | 292 | if (mediaFiles[i].type == "video/m3u8" || htmlMediaElement.canPlayType(mediaFiles[i].type).replace(/no/, '') !== '' |
… |
… |
mejs.HtmlMediaElementShim = { |
298 | 298 | result.url = mediaFiles[i].url; |
299 | 299 | break; |
300 | 300 | } |
301 | | } |
302 | | |
| 301 | } |
| 302 | |
303 | 303 | if (result.method === 'native') { |
304 | 304 | if (result.url !== null) { |
305 | 305 | htmlMediaElement.src = result.url; |
306 | 306 | } |
307 | | |
| 307 | |
308 | 308 | // if `auto_plugin` mode, then cache the native result but try plugins. |
309 | 309 | if (options.mode !== 'auto_plugin') { |
310 | 310 | return result; |
… |
… |
mejs.HtmlMediaElementShim = { |
321 | 321 | for (j=0; j<options.plugins.length; j++) { |
322 | 322 | |
323 | 323 | pluginName = options.plugins[j]; |
324 | | |
| 324 | |
325 | 325 | // test version of plugin (for future features) |
326 | | pluginVersions = mejs.plugins[pluginName]; |
327 | | |
| 326 | pluginVersions = mejs.plugins[pluginName]; |
| 327 | |
328 | 328 | for (k=0; k<pluginVersions.length; k++) { |
329 | 329 | pluginInfo = pluginVersions[k]; |
330 | | |
| 330 | |
331 | 331 | // test if user has the correct plugin version |
332 | | |
| 332 | |
333 | 333 | // for youtube/vimeo |
334 | | if (pluginInfo.version == null || |
335 | | |
| 334 | if (pluginInfo.version == null || |
| 335 | |
336 | 336 | mejs.PluginDetector.hasPluginVersion(pluginName, pluginInfo.version)) { |
337 | 337 | |
338 | 338 | // test for plugin playback types |
… |
… |
mejs.HtmlMediaElementShim = { |
349 | 349 | } |
350 | 350 | } |
351 | 351 | } |
352 | | |
| 352 | |
353 | 353 | // at this point, being in 'auto_plugin' mode implies that we tried plugins but failed. |
354 | 354 | // if we have native support then return that. |
355 | 355 | if (options.mode === 'auto_plugin' && result.method === 'native') { |
… |
… |
mejs.HtmlMediaElementShim = { |
368 | 368 | var ext; |
369 | 369 | |
370 | 370 | // if no type is supplied, fake it with the extension |
371 | | if (url && !type) { |
| 371 | if (url && !type) { |
372 | 372 | return this.getTypeFromFile(url); |
373 | 373 | } else { |
374 | 374 | // only return the mime part of the type in case the attribute contains the codec |
375 | 375 | // see http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#the-source-element |
376 | 376 | // `video/mp4; codecs="avc1.42E01E, mp4a.40.2"` becomes `video/mp4` |
377 | | |
| 377 | |
378 | 378 | if (type && ~type.indexOf(';')) { |
379 | | return type.substr(0, type.indexOf(';')); |
| 379 | return type.substr(0, type.indexOf(';')); |
380 | 380 | } else { |
381 | 381 | return type; |
382 | 382 | } |
383 | 383 | } |
384 | 384 | }, |
385 | | |
| 385 | |
386 | 386 | getTypeFromFile: function(url) { |
387 | 387 | url = url.split('?')[0]; |
388 | 388 | var ext = url.substring(url.lastIndexOf('.') + 1).toLowerCase(); |
389 | 389 | return (/(mp4|m4v|ogg|ogv|m3u8|webm|webmv|flv|wmv|mpeg|mov)/gi.test(ext) ? 'video' : 'audio') + '/' + this.getTypeFromExtension(ext); |
390 | 390 | }, |
391 | | |
| 391 | |
392 | 392 | getTypeFromExtension: function(ext) { |
393 | | |
| 393 | |
394 | 394 | switch (ext) { |
395 | 395 | case 'mp4': |
396 | 396 | case 'm4v': |
… |
… |
mejs.HtmlMediaElementShim = { |
398 | 398 | return 'mp4'; |
399 | 399 | case 'webm': |
400 | 400 | case 'webma': |
401 | | case 'webmv': |
| 401 | case 'webmv': |
402 | 402 | return 'webm'; |
403 | 403 | case 'ogg': |
404 | 404 | case 'oga': |
405 | | case 'ogv': |
| 405 | case 'ogv': |
406 | 406 | return 'ogg'; |
407 | 407 | default: |
408 | 408 | return ext; |
… |
… |
mejs.HtmlMediaElementShim = { |
410 | 410 | }, |
411 | 411 | |
412 | 412 | createErrorMessage: function(playback, options, poster) { |
413 | | var |
| 413 | var |
414 | 414 | htmlMediaElement = playback.htmlMediaElement, |
415 | 415 | errorContainer = document.createElement('div'); |
416 | | |
| 416 | |
417 | 417 | errorContainer.className = 'me-cannotplay'; |
418 | 418 | |
419 | 419 | try { |
… |
… |
mejs.HtmlMediaElementShim = { |
436 | 436 | }, |
437 | 437 | |
438 | 438 | createPlugin:function(playback, options, poster, autoplay, preload, controls) { |
439 | | var |
| 439 | var |
440 | 440 | htmlMediaElement = playback.htmlMediaElement, |
441 | 441 | width = 1, |
442 | 442 | height = 1, |
… |
… |
mejs.HtmlMediaElementShim = { |
471 | 471 | if (playback.isVideo) { |
472 | 472 | width = (options.pluginWidth > 0) ? options.pluginWidth : (options.videoWidth > 0) ? options.videoWidth : (htmlMediaElement.getAttribute('width') !== null) ? htmlMediaElement.getAttribute('width') : options.defaultVideoWidth; |
473 | 473 | height = (options.pluginHeight > 0) ? options.pluginHeight : (options.videoHeight > 0) ? options.videoHeight : (htmlMediaElement.getAttribute('height') !== null) ? htmlMediaElement.getAttribute('height') : options.defaultVideoHeight; |
474 | | |
| 474 | |
475 | 475 | // in case of '%' make sure it's encoded |
476 | 476 | width = mejs.Utility.encodeUrl(width); |
477 | 477 | height = mejs.Utility.encodeUrl(height); |
478 | | |
| 478 | |
479 | 479 | } else { |
480 | 480 | if (options.enablePluginDebug) { |
481 | 481 | width = 320; |
… |
… |
mejs.HtmlMediaElementShim = { |
490 | 490 | // add container (must be added to DOM before inserting HTML for IE) |
491 | 491 | container.className = 'me-plugin'; |
492 | 492 | container.id = pluginid + '_container'; |
493 | | |
| 493 | |
494 | 494 | if (playback.isVideo) { |
495 | 495 | htmlMediaElement.parentNode.insertBefore(container, htmlMediaElement); |
496 | 496 | } else { |
… |
… |
mejs.HtmlMediaElementShim = { |
533 | 533 | } |
534 | 534 | if (options.pluginVars) { |
535 | 535 | initVars = initVars.concat(options.pluginVars); |
536 | | } |
| 536 | } |
537 | 537 | |
538 | 538 | switch (playback.method) { |
539 | 539 | case 'silverlight': |
… |
… |
mejs.HtmlMediaElementShim = { |
563 | 563 | '<param name="wmode" value="transparent" />' + |
564 | 564 | '<param name="allowScriptAccess" value="always" />' + |
565 | 565 | '<param name="allowFullScreen" value="true" />' + |
566 | | '<param name="scale" value="default" />' + |
| 566 | '<param name="scale" value="default" />' + |
567 | 567 | '</object>'; |
568 | 568 | |
569 | 569 | } else { |
… |
… |
mejs.HtmlMediaElementShim = { |
582 | 582 | 'flashvars="' + initVars.join('&') + '" ' + |
583 | 583 | 'width="' + width + '" ' + |
584 | 584 | 'height="' + height + '" ' + |
585 | | 'scale="default"' + |
| 585 | 'scale="default"' + |
586 | 586 | 'class="mejs-shim"></embed>'; |
587 | 587 | } |
588 | 588 | break; |
589 | | |
| 589 | |
590 | 590 | case 'youtube': |
591 | | |
592 | | |
| 591 | |
| 592 | |
593 | 593 | var videoId; |
594 | 594 | // youtu.be url from share button |
595 | 595 | if (playback.url.lastIndexOf("youtu.be") != -1) { |
… |
… |
mejs.HtmlMediaElementShim = { |
608 | 608 | pluginId: pluginid, |
609 | 609 | videoId: videoId, |
610 | 610 | height: height, |
611 | | width: width |
612 | | }; |
613 | | |
| 611 | width: width |
| 612 | }; |
| 613 | |
614 | 614 | if (mejs.PluginDetector.hasPluginVersion('flash', [10,0,0]) ) { |
615 | 615 | mejs.YouTubeApi.createFlash(youtubeSettings); |
616 | 616 | } else { |
617 | | mejs.YouTubeApi.enqueueIframe(youtubeSettings); |
| 617 | mejs.YouTubeApi.enqueueIframe(youtubeSettings); |
618 | 618 | } |
619 | | |
| 619 | |
620 | 620 | break; |
621 | | |
| 621 | |
622 | 622 | // DEMO Code. Does NOT work. |
623 | 623 | case 'vimeo': |
624 | 624 | var player_id = pluginid + "_player"; |
625 | 625 | pluginMediaElement.vimeoid = playback.url.substr(playback.url.lastIndexOf('/')+1); |
626 | | |
| 626 | |
627 | 627 | container.innerHTML ='<iframe src="//player.vimeo.com/video/' + pluginMediaElement.vimeoid + '?api=1&portrait=0&byline=0&title=0&player_id=' + player_id + '" width="' + width +'" height="' + height +'" frameborder="0" class="mejs-shim" id="' + player_id + '" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>'; |
628 | 628 | if (typeof($f) == 'function') { // froogaloop available |
629 | 629 | var player = $f(container.childNodes[0]); |
630 | | |
| 630 | |
631 | 631 | player.addEvent('ready', function() { |
632 | | |
| 632 | |
633 | 633 | player.playVideo = function() { |
634 | 634 | player.api( 'play' ); |
635 | | } |
| 635 | } |
636 | 636 | player.stopVideo = function() { |
637 | 637 | player.api( 'unload' ); |
638 | | } |
| 638 | } |
639 | 639 | player.pauseVideo = function() { |
640 | 640 | player.api( 'pause' ); |
641 | | } |
| 641 | } |
642 | 642 | player.seekTo = function( seconds ) { |
643 | 643 | player.api( 'seekTo', seconds ); |
644 | 644 | } |
… |
… |
mejs.HtmlMediaElementShim = { |
653 | 653 | player.api( 'setVolume', player.lastVolume ); |
654 | 654 | delete player.lastVolume; |
655 | 655 | } |
656 | | } |
| 656 | } |
657 | 657 | |
658 | 658 | function createEvent(player, pluginMediaElement, eventName, e) { |
659 | 659 | var obj = { |
… |
… |
mejs.HtmlMediaElementShim = { |
694 | 694 | else { |
695 | 695 | console.warn("You need to include froogaloop for vimeo to work"); |
696 | 696 | } |
697 | | break; |
| 697 | break; |
698 | 698 | } |
699 | 699 | // hide original element |
700 | 700 | htmlMediaElement.style.display = 'none'; |
… |
… |
mejs.HtmlMediaElementShim = { |
702 | 702 | htmlMediaElement.removeAttribute('autoplay'); |
703 | 703 | |
704 | 704 | // FYI: options.success will be fired by the MediaPluginBridge |
705 | | |
| 705 | |
706 | 706 | return pluginMediaElement; |
707 | 707 | }, |
708 | 708 | |
709 | 709 | updateNative: function(playback, options, autoplay, preload) { |
710 | | |
| 710 | |
711 | 711 | var htmlMediaElement = playback.htmlMediaElement, |
712 | 712 | m; |
713 | | |
714 | | |
| 713 | |
| 714 | |
715 | 715 | // add methods to video object to bring it into parity with Flash Object |
716 | 716 | for (m in mejs.HtmlMediaElement) { |
717 | 717 | htmlMediaElement[m] = mejs.HtmlMediaElement[m]; |
… |
… |
mejs.HtmlMediaElementShim = { |
720 | 720 | /* |
721 | 721 | Chrome now supports preload="none" |
722 | 722 | if (mejs.MediaFeatures.isChrome) { |
723 | | |
| 723 | |
724 | 724 | // special case to enforce preload attribute (Chrome doesn't respect this) |
725 | 725 | if (preload === 'none' && !autoplay) { |
726 | | |
| 726 | |
727 | 727 | // forces the browser to stop loading (note: fails in IE9) |
728 | 728 | htmlMediaElement.src = ''; |
729 | 729 | htmlMediaElement.load(); |
… |
… |
mejs.HtmlMediaElementShim = { |
747 | 747 | |
748 | 748 | // fire success code |
749 | 749 | options.success(htmlMediaElement, htmlMediaElement); |
750 | | |
| 750 | |
751 | 751 | return htmlMediaElement; |
752 | 752 | } |
753 | 753 | }; |
… |
… |
mejs.YouTubeApi = { |
773 | 773 | }, |
774 | 774 | iframeQueue: [], |
775 | 775 | enqueueIframe: function(yt) { |
776 | | |
| 776 | |
777 | 777 | if (this.isLoaded) { |
778 | 778 | this.createIframe(yt); |
779 | 779 | } else { |
… |
… |
mejs.YouTubeApi = { |
782 | 782 | } |
783 | 783 | }, |
784 | 784 | createIframe: function(settings) { |
785 | | |
| 785 | |
786 | 786 | var |
787 | | pluginMediaElement = settings.pluginMediaElement, |
| 787 | pluginMediaElement = settings.pluginMediaElement, |
788 | 788 | player = new YT.Player(settings.containerId, { |
789 | 789 | height: settings.height, |
790 | 790 | width: settings.width, |
… |
… |
mejs.YouTubeApi = { |
792 | 792 | playerVars: {controls:0}, |
793 | 793 | events: { |
794 | 794 | 'onReady': function() { |
795 | | |
| 795 | |
796 | 796 | // hook up iframe object to MEjs |
797 | 797 | settings.pluginMediaElement.pluginApi = player; |
798 | | |
| 798 | |
799 | 799 | // init mejs |
800 | 800 | mejs.MediaPluginBridge.initPlugin(settings.pluginId); |
801 | | |
| 801 | |
802 | 802 | // create timer |
803 | 803 | setInterval(function() { |
804 | 804 | mejs.YouTubeApi.createEvent(player, pluginMediaElement, 'timeupdate'); |
805 | | }, 250); |
| 805 | }, 250); |
806 | 806 | }, |
807 | 807 | 'onStateChange': function(e) { |
808 | | |
| 808 | |
809 | 809 | mejs.YouTubeApi.handleStateChange(e.data, player, pluginMediaElement); |
810 | | |
| 810 | |
811 | 811 | } |
812 | 812 | } |
813 | 813 | }); |
814 | 814 | }, |
815 | | |
| 815 | |
816 | 816 | createEvent: function (player, pluginMediaElement, eventName) { |
817 | 817 | var obj = { |
818 | 818 | type: eventName, |
… |
… |
mejs.YouTubeApi = { |
820 | 820 | }; |
821 | 821 | |
822 | 822 | if (player && player.getDuration) { |
823 | | |
824 | | // time |
| 823 | |
| 824 | // time |
825 | 825 | pluginMediaElement.currentTime = obj.currentTime = player.getCurrentTime(); |
826 | 826 | pluginMediaElement.duration = obj.duration = player.getDuration(); |
827 | | |
| 827 | |
828 | 828 | // state |
829 | 829 | obj.paused = pluginMediaElement.paused; |
830 | | obj.ended = pluginMediaElement.ended; |
831 | | |
| 830 | obj.ended = pluginMediaElement.ended; |
| 831 | |
832 | 832 | // sound |
833 | 833 | obj.muted = player.isMuted(); |
834 | 834 | obj.volume = player.getVolume() / 100; |
835 | | |
| 835 | |
836 | 836 | // progress |
837 | 837 | obj.bytesTotal = player.getVideoBytesTotal(); |
838 | 838 | obj.bufferedBytes = player.getVideoBytesLoaded(); |
839 | | |
| 839 | |
840 | 840 | // fake the W3C buffered TimeRange |
841 | 841 | var bufferedTime = obj.bufferedBytes / obj.bytesTotal * obj.duration; |
842 | | |
| 842 | |
843 | 843 | obj.target.buffered = obj.buffered = { |
844 | 844 | start: function(index) { |
845 | 845 | return 0; |
… |
… |
mejs.YouTubeApi = { |
851 | 851 | }; |
852 | 852 | |
853 | 853 | } |
854 | | |
| 854 | |
855 | 855 | // send event up the chain |
856 | 856 | pluginMediaElement.dispatchEvent(obj.type, obj); |
857 | | }, |
858 | | |
| 857 | }, |
| 858 | |
859 | 859 | iFrameReady: function() { |
860 | | |
| 860 | |
861 | 861 | this.isLoaded = true; |
862 | 862 | this.isIframeLoaded = true; |
863 | | |
| 863 | |
864 | 864 | while (this.iframeQueue.length > 0) { |
865 | 865 | var settings = this.iframeQueue.pop(); |
866 | 866 | this.createIframe(settings); |
867 | | } |
| 867 | } |
868 | 868 | }, |
869 | | |
| 869 | |
870 | 870 | // FLASH! |
871 | 871 | flashPlayers: {}, |
872 | 872 | createFlash: function(settings) { |
873 | | |
| 873 | |
874 | 874 | this.flashPlayers[settings.pluginId] = settings; |
875 | | |
| 875 | |
876 | 876 | /* |
877 | 877 | settings.container.innerHTML = |
878 | 878 | '<object type="application/x-shockwave-flash" id="' + settings.pluginId + '" data="//www.youtube.com/apiplayer?enablejsapi=1&playerapiid=' + settings.pluginId + '&version=3&autoplay=0&controls=0&modestbranding=1&loop=0" ' + |
… |
… |
mejs.YouTubeApi = { |
884 | 884 | |
885 | 885 | var specialIEContainer, |
886 | 886 | youtubeUrl = '//www.youtube.com/apiplayer?enablejsapi=1&playerapiid=' + settings.pluginId + '&version=3&autoplay=0&controls=0&modestbranding=1&loop=0'; |
887 | | |
| 887 | |
888 | 888 | if (mejs.MediaFeatures.isIE) { |
889 | | |
| 889 | |
890 | 890 | specialIEContainer = document.createElement('div'); |
891 | 891 | settings.container.appendChild(specialIEContainer); |
892 | 892 | specialIEContainer.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" ' + |
… |
… |
mejs.YouTubeApi = { |
903 | 903 | '<param name="allowScriptAccess" value="always">' + |
904 | 904 | '<param name="wmode" value="transparent">' + |
905 | 905 | '</object>'; |
906 | | } |
907 | | |
| 906 | } |
| 907 | |
908 | 908 | }, |
909 | | |
| 909 | |
910 | 910 | flashReady: function(id) { |
911 | 911 | var |
912 | 912 | settings = this.flashPlayers[id], |
913 | 913 | player = document.getElementById(id), |
914 | 914 | pluginMediaElement = settings.pluginMediaElement; |
915 | | |
916 | | // hook up and return to MediaELementPlayer.success |
917 | | pluginMediaElement.pluginApi = |
| 915 | |
| 916 | // hook up and return to MediaELementPlayer.success |
| 917 | pluginMediaElement.pluginApi = |
918 | 918 | pluginMediaElement.pluginElement = player; |
919 | 919 | mejs.MediaPluginBridge.initPlugin(id); |
920 | | |
| 920 | |
921 | 921 | // load the youtube video |
922 | 922 | player.cueVideoById(settings.videoId); |
923 | | |
| 923 | |
924 | 924 | var callbackName = settings.containerId + '_callback'; |
925 | | |
| 925 | |
926 | 926 | window[callbackName] = function(e) { |
927 | 927 | mejs.YouTubeApi.handleStateChange(e, player, pluginMediaElement); |
928 | 928 | } |
929 | | |
| 929 | |
930 | 930 | player.addEventListener('onStateChange', callbackName); |
931 | | |
| 931 | |
932 | 932 | setInterval(function() { |
933 | 933 | mejs.YouTubeApi.createEvent(player, pluginMediaElement, 'timeupdate'); |
934 | 934 | }, 250); |
935 | | |
| 935 | |
936 | 936 | mejs.YouTubeApi.createEvent(player, pluginMediaElement, 'canplay'); |
937 | 937 | }, |
938 | | |
| 938 | |
939 | 939 | handleStateChange: function(youTubeState, player, pluginMediaElement) { |
940 | 940 | switch (youTubeState) { |
941 | 941 | case -1: // not started |
… |
… |
mejs.YouTubeApi = { |
951 | 951 | break; |
952 | 952 | case 1: |
953 | 953 | pluginMediaElement.paused = false; |
954 | | pluginMediaElement.ended = false; |
| 954 | pluginMediaElement.ended = false; |
955 | 955 | mejs.YouTubeApi.createEvent(player, pluginMediaElement, 'play'); |
956 | 956 | mejs.YouTubeApi.createEvent(player, pluginMediaElement, 'playing'); |
957 | 957 | break; |
958 | 958 | case 2: |
959 | 959 | pluginMediaElement.paused = true; |
960 | | pluginMediaElement.ended = false; |
| 960 | pluginMediaElement.ended = false; |
961 | 961 | mejs.YouTubeApi.createEvent(player, pluginMediaElement, 'pause'); |
962 | 962 | break; |
963 | 963 | case 3: // buffering |
… |
… |
mejs.YouTubeApi = { |
965 | 965 | break; |
966 | 966 | case 5: |
967 | 967 | // cued? |
968 | | break; |
969 | | |
970 | | } |
971 | | |
| 968 | break; |
| 969 | |
| 970 | } |
| 971 | |
972 | 972 | } |
973 | 973 | } |
974 | 974 | // IFRAME |