diff --git Gruntfile.js Gruntfile.js
index 5b81dc7..cbbacf3 100644
|
|
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']); |
| 181 | |
180 | 182 | }; |
| 183 | No newline at end of file |
diff --git src/js/me-shim.js src/js/me-shim.js
index 56510f6..b3f0c8f 100644
|
|
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 = { |
531 | 531 | } |
532 | 532 | if (options.pluginVars) { |
533 | 533 | initVars = initVars.concat(options.pluginVars); |
534 | | } |
| 534 | } |
535 | 535 | |
536 | 536 | switch (playback.method) { |
537 | 537 | case 'silverlight': |
… |
… |
mejs.HtmlMediaElementShim = { |
561 | 561 | '<param name="wmode" value="transparent" />' + |
562 | 562 | '<param name="allowScriptAccess" value="always" />' + |
563 | 563 | '<param name="allowFullScreen" value="true" />' + |
564 | | '<param name="scale" value="default" />' + |
| 564 | '<param name="scale" value="default" />' + |
565 | 565 | '</object>'; |
566 | 566 | |
567 | 567 | } else { |
… |
… |
mejs.HtmlMediaElementShim = { |
580 | 580 | 'flashvars="' + initVars.join('&') + '" ' + |
581 | 581 | 'width="' + width + '" ' + |
582 | 582 | 'height="' + height + '" ' + |
583 | | 'scale="default"' + |
| 583 | 'scale="default"' + |
584 | 584 | 'class="mejs-shim"></embed>'; |
585 | 585 | } |
586 | 586 | break; |
587 | | |
| 587 | |
588 | 588 | case 'youtube': |
589 | | |
590 | | |
| 589 | |
| 590 | |
591 | 591 | var videoId; |
592 | 592 | // youtu.be url from share button |
593 | 593 | if (playback.url.lastIndexOf("youtu.be") != -1) { |
… |
… |
mejs.HtmlMediaElementShim = { |
606 | 606 | pluginId: pluginid, |
607 | 607 | videoId: videoId, |
608 | 608 | height: height, |
609 | | width: width |
610 | | }; |
611 | | |
| 609 | width: width |
| 610 | }; |
| 611 | |
612 | 612 | if (mejs.PluginDetector.hasPluginVersion('flash', [10,0,0]) ) { |
613 | 613 | mejs.YouTubeApi.createFlash(youtubeSettings); |
614 | 614 | } else { |
615 | | mejs.YouTubeApi.enqueueIframe(youtubeSettings); |
| 615 | mejs.YouTubeApi.enqueueIframe(youtubeSettings); |
616 | 616 | } |
617 | | |
| 617 | |
618 | 618 | break; |
619 | | |
| 619 | |
620 | 620 | // DEMO Code. Does NOT work. |
621 | 621 | case 'vimeo': |
622 | 622 | var player_id = pluginid + "_player"; |
623 | 623 | pluginMediaElement.vimeoid = playback.url.substr(playback.url.lastIndexOf('/')+1); |
624 | | |
| 624 | |
625 | 625 | 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>'; |
626 | 626 | if (typeof($f) == 'function') { // froogaloop available |
627 | 627 | var player = $f(container.childNodes[0]); |
… |
… |
mejs.HtmlMediaElementShim = { |
629 | 629 | $.extend( player, { |
630 | 630 | playVideo: function() { |
631 | 631 | player.api( 'play' ); |
632 | | }, |
| 632 | }, |
633 | 633 | stopVideo: function() { |
634 | 634 | player.api( 'unload' ); |
635 | | }, |
| 635 | }, |
636 | 636 | pauseVideo: function() { |
637 | 637 | player.api( 'pause' ); |
638 | | }, |
| 638 | }, |
639 | 639 | seekTo: function( seconds ) { |
640 | 640 | player.api( 'seekTo', seconds ); |
641 | | }, |
| 641 | }, |
642 | 642 | setVolume: function( volume ) { |
643 | 643 | player.api( 'setVolume', volume ); |
644 | | }, |
| 644 | }, |
645 | 645 | setMuted: function( muted ) { |
646 | 646 | if( muted ) { |
647 | 647 | player.lastVolume = player.api( 'getVolume' ); |
… |
… |
mejs.HtmlMediaElementShim = { |
692 | 692 | else { |
693 | 693 | console.warn("You need to include froogaloop for vimeo to work"); |
694 | 694 | } |
695 | | break; |
| 695 | break; |
696 | 696 | } |
697 | 697 | // hide original element |
698 | 698 | htmlMediaElement.style.display = 'none'; |
… |
… |
mejs.HtmlMediaElementShim = { |
700 | 700 | htmlMediaElement.removeAttribute('autoplay'); |
701 | 701 | |
702 | 702 | // FYI: options.success will be fired by the MediaPluginBridge |
703 | | |
| 703 | |
704 | 704 | return pluginMediaElement; |
705 | 705 | }, |
706 | 706 | |
707 | 707 | updateNative: function(playback, options, autoplay, preload) { |
708 | | |
| 708 | |
709 | 709 | var htmlMediaElement = playback.htmlMediaElement, |
710 | 710 | m; |
711 | | |
712 | | |
| 711 | |
| 712 | |
713 | 713 | // add methods to video object to bring it into parity with Flash Object |
714 | 714 | for (m in mejs.HtmlMediaElement) { |
715 | 715 | htmlMediaElement[m] = mejs.HtmlMediaElement[m]; |
… |
… |
mejs.HtmlMediaElementShim = { |
718 | 718 | /* |
719 | 719 | Chrome now supports preload="none" |
720 | 720 | if (mejs.MediaFeatures.isChrome) { |
721 | | |
| 721 | |
722 | 722 | // special case to enforce preload attribute (Chrome doesn't respect this) |
723 | 723 | if (preload === 'none' && !autoplay) { |
724 | | |
| 724 | |
725 | 725 | // forces the browser to stop loading (note: fails in IE9) |
726 | 726 | htmlMediaElement.src = ''; |
727 | 727 | htmlMediaElement.load(); |
… |
… |
mejs.HtmlMediaElementShim = { |
745 | 745 | |
746 | 746 | // fire success code |
747 | 747 | options.success(htmlMediaElement, htmlMediaElement); |
748 | | |
| 748 | |
749 | 749 | return htmlMediaElement; |
750 | 750 | } |
751 | 751 | }; |
… |
… |
mejs.YouTubeApi = { |
771 | 771 | }, |
772 | 772 | iframeQueue: [], |
773 | 773 | enqueueIframe: function(yt) { |
774 | | |
| 774 | |
775 | 775 | if (this.isLoaded) { |
776 | 776 | this.createIframe(yt); |
777 | 777 | } else { |
… |
… |
mejs.YouTubeApi = { |
780 | 780 | } |
781 | 781 | }, |
782 | 782 | createIframe: function(settings) { |
783 | | |
| 783 | |
784 | 784 | var |
785 | | pluginMediaElement = settings.pluginMediaElement, |
| 785 | pluginMediaElement = settings.pluginMediaElement, |
786 | 786 | player = new YT.Player(settings.containerId, { |
787 | 787 | height: settings.height, |
788 | 788 | width: settings.width, |
… |
… |
mejs.YouTubeApi = { |
790 | 790 | playerVars: {controls:0}, |
791 | 791 | events: { |
792 | 792 | 'onReady': function() { |
793 | | |
| 793 | |
794 | 794 | // hook up iframe object to MEjs |
795 | 795 | settings.pluginMediaElement.pluginApi = player; |
796 | | |
| 796 | |
797 | 797 | // init mejs |
798 | 798 | mejs.MediaPluginBridge.initPlugin(settings.pluginId); |
799 | | |
| 799 | |
800 | 800 | // create timer |
801 | 801 | setInterval(function() { |
802 | 802 | mejs.YouTubeApi.createEvent(player, pluginMediaElement, 'timeupdate'); |
803 | | }, 250); |
| 803 | }, 250); |
804 | 804 | }, |
805 | 805 | 'onStateChange': function(e) { |
806 | | |
| 806 | |
807 | 807 | mejs.YouTubeApi.handleStateChange(e.data, player, pluginMediaElement); |
808 | | |
| 808 | |
809 | 809 | } |
810 | 810 | } |
811 | 811 | }); |
812 | 812 | }, |
813 | | |
| 813 | |
814 | 814 | createEvent: function (player, pluginMediaElement, eventName) { |
815 | 815 | var obj = { |
816 | 816 | type: eventName, |
… |
… |
mejs.YouTubeApi = { |
818 | 818 | }; |
819 | 819 | |
820 | 820 | if (player && player.getDuration) { |
821 | | |
822 | | // time |
| 821 | |
| 822 | // time |
823 | 823 | pluginMediaElement.currentTime = obj.currentTime = player.getCurrentTime(); |
824 | 824 | pluginMediaElement.duration = obj.duration = player.getDuration(); |
825 | | |
| 825 | |
826 | 826 | // state |
827 | 827 | obj.paused = pluginMediaElement.paused; |
828 | | obj.ended = pluginMediaElement.ended; |
829 | | |
| 828 | obj.ended = pluginMediaElement.ended; |
| 829 | |
830 | 830 | // sound |
831 | 831 | obj.muted = player.isMuted(); |
832 | 832 | obj.volume = player.getVolume() / 100; |
833 | | |
| 833 | |
834 | 834 | // progress |
835 | 835 | obj.bytesTotal = player.getVideoBytesTotal(); |
836 | 836 | obj.bufferedBytes = player.getVideoBytesLoaded(); |
837 | | |
| 837 | |
838 | 838 | // fake the W3C buffered TimeRange |
839 | 839 | var bufferedTime = obj.bufferedBytes / obj.bytesTotal * obj.duration; |
840 | | |
| 840 | |
841 | 841 | obj.target.buffered = obj.buffered = { |
842 | 842 | start: function(index) { |
843 | 843 | return 0; |
… |
… |
mejs.YouTubeApi = { |
849 | 849 | }; |
850 | 850 | |
851 | 851 | } |
852 | | |
| 852 | |
853 | 853 | // send event up the chain |
854 | 854 | pluginMediaElement.dispatchEvent(obj.type, obj); |
855 | | }, |
856 | | |
| 855 | }, |
| 856 | |
857 | 857 | iFrameReady: function() { |
858 | | |
| 858 | |
859 | 859 | this.isLoaded = true; |
860 | 860 | this.isIframeLoaded = true; |
861 | | |
| 861 | |
862 | 862 | while (this.iframeQueue.length > 0) { |
863 | 863 | var settings = this.iframeQueue.pop(); |
864 | 864 | this.createIframe(settings); |
865 | | } |
| 865 | } |
866 | 866 | }, |
867 | | |
| 867 | |
868 | 868 | // FLASH! |
869 | 869 | flashPlayers: {}, |
870 | 870 | createFlash: function(settings) { |
871 | | |
| 871 | |
872 | 872 | this.flashPlayers[settings.pluginId] = settings; |
873 | | |
| 873 | |
874 | 874 | /* |
875 | 875 | settings.container.innerHTML = |
876 | 876 | '<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 = { |
882 | 882 | |
883 | 883 | var specialIEContainer, |
884 | 884 | youtubeUrl = '//www.youtube.com/apiplayer?enablejsapi=1&playerapiid=' + settings.pluginId + '&version=3&autoplay=0&controls=0&modestbranding=1&loop=0'; |
885 | | |
| 885 | |
886 | 886 | if (mejs.MediaFeatures.isIE) { |
887 | | |
| 887 | |
888 | 888 | specialIEContainer = document.createElement('div'); |
889 | 889 | settings.container.appendChild(specialIEContainer); |
890 | 890 | specialIEContainer.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" ' + |
… |
… |
mejs.YouTubeApi = { |
901 | 901 | '<param name="allowScriptAccess" value="always">' + |
902 | 902 | '<param name="wmode" value="transparent">' + |
903 | 903 | '</object>'; |
904 | | } |
905 | | |
| 904 | } |
| 905 | |
906 | 906 | }, |
907 | | |
| 907 | |
908 | 908 | flashReady: function(id) { |
909 | 909 | var |
910 | 910 | settings = this.flashPlayers[id], |
911 | 911 | player = document.getElementById(id), |
912 | 912 | pluginMediaElement = settings.pluginMediaElement; |
913 | | |
914 | | // hook up and return to MediaELementPlayer.success |
915 | | pluginMediaElement.pluginApi = |
| 913 | |
| 914 | // hook up and return to MediaELementPlayer.success |
| 915 | pluginMediaElement.pluginApi = |
916 | 916 | pluginMediaElement.pluginElement = player; |
917 | 917 | mejs.MediaPluginBridge.initPlugin(id); |
918 | | |
| 918 | |
919 | 919 | // load the youtube video |
920 | 920 | player.cueVideoById(settings.videoId); |
921 | | |
| 921 | |
922 | 922 | var callbackName = settings.containerId + '_callback'; |
923 | | |
| 923 | |
924 | 924 | window[callbackName] = function(e) { |
925 | 925 | mejs.YouTubeApi.handleStateChange(e, player, pluginMediaElement); |
926 | 926 | } |
927 | | |
| 927 | |
928 | 928 | player.addEventListener('onStateChange', callbackName); |
929 | | |
| 929 | |
930 | 930 | setInterval(function() { |
931 | 931 | mejs.YouTubeApi.createEvent(player, pluginMediaElement, 'timeupdate'); |
932 | 932 | }, 250); |
933 | | |
| 933 | |
934 | 934 | mejs.YouTubeApi.createEvent(player, pluginMediaElement, 'canplay'); |
935 | 935 | }, |
936 | | |
| 936 | |
937 | 937 | handleStateChange: function(youTubeState, player, pluginMediaElement) { |
938 | 938 | switch (youTubeState) { |
939 | 939 | case -1: // not started |
… |
… |
mejs.YouTubeApi = { |
949 | 949 | break; |
950 | 950 | case 1: |
951 | 951 | pluginMediaElement.paused = false; |
952 | | pluginMediaElement.ended = false; |
| 952 | pluginMediaElement.ended = false; |
953 | 953 | mejs.YouTubeApi.createEvent(player, pluginMediaElement, 'play'); |
954 | 954 | mejs.YouTubeApi.createEvent(player, pluginMediaElement, 'playing'); |
955 | 955 | break; |
956 | 956 | case 2: |
957 | 957 | pluginMediaElement.paused = true; |
958 | | pluginMediaElement.ended = false; |
| 958 | pluginMediaElement.ended = false; |
959 | 959 | mejs.YouTubeApi.createEvent(player, pluginMediaElement, 'pause'); |
960 | 960 | break; |
961 | 961 | case 3: // buffering |
… |
… |
mejs.YouTubeApi = { |
963 | 963 | break; |
964 | 964 | case 5: |
965 | 965 | // cued? |
966 | | break; |
967 | | |
968 | | } |
969 | | |
| 966 | break; |
| 967 | |
| 968 | } |
| 969 | |
970 | 970 | } |
971 | 971 | } |
972 | 972 | // IFRAME |