with specific configuration.
+ * @see https://developers.facebook.com/docs/plugins/embedded-video-player
+ */
+
+var FacebookRenderer = {
+ name: 'facebook',
+
+ options: {
+ prefix: 'facebook',
+ facebook: {
+ appId: '{your-app-id}',
+ xfbml: true,
+ version: 'v2.6'
+ }
+ },
+
+ /**
+ * Determine if a specific element type can be played with this render
+ *
+ * @param {String} type
+ * @return {Boolean}
+ */
+ canPlayType: function canPlayType(type) {
+ return ~['video/facebook', 'video/x-facebook'].indexOf(type.toLowerCase());
+ },
+
+ /**
+ * Create the player instance and add all native events/methods/properties as possible
+ *
+ * @param {MediaElement} mediaElement Instance of mejs.MediaElement already created
+ * @param {Object} options All the player configuration options passed through constructor
+ * @param {Object[]} mediaFiles List of sources with format: {src: url, type: x/y-z}
+ * @return {Object}
+ */
+ create: function create(mediaElement, options, mediaFiles) {
+
+ var fbWrapper = {},
+ apiStack = [],
+ eventHandler = {},
+ readyState = 4,
+ autoplay = mediaElement.originalNode.autoplay;
+
+ var src = '',
+ paused = true,
+ ended = false,
+ hasStartedPlaying = false,
+ fbApi = null,
+ fbDiv = null;
+
+ options = Object.assign(options, mediaElement.options);
+ fbWrapper.options = options;
+ fbWrapper.id = mediaElement.id + '_' + options.prefix;
+ fbWrapper.mediaElement = mediaElement;
+
+ // wrappers for get/set
+ var props = mejs.html5media.properties,
+ assignGettersSetters = function assignGettersSetters(propName) {
+
+ var capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1);
+
+ fbWrapper['get' + capName] = function () {
+
+ if (fbApi !== null) {
+ var value = null;
+
+ // figure out how to get youtube dta here
+ switch (propName) {
+ case 'currentTime':
+ return fbApi.getCurrentPosition();
+
+ case 'duration':
+ return fbApi.getDuration();
+
+ case 'volume':
+ return fbApi.getVolume();
+
+ case 'paused':
+ return paused;
+
+ case 'ended':
+ return ended;
+
+ case 'muted':
+ return fbApi.isMuted();
+
+ case 'buffered':
+ return {
+ start: function start() {
+ return 0;
+ },
+ end: function end() {
+ return 0;
+ },
+ length: 1
+ };
+ case 'src':
+ return src;
+
+ case 'readyState':
+ return readyState;
+ }
+
+ return value;
+ } else {
+ return null;
+ }
+ };
+
+ fbWrapper['set' + capName] = function (value) {
+
+ if (fbApi !== null) {
+
+ switch (propName) {
+
+ case 'src':
+ var url = typeof value === 'string' ? value : value[0].src;
+
+ // Only way is to destroy instance and all the events fired,
+ // and create new one
+ fbDiv.remove();
+ createFacebookEmbed(url, options.facebook);
+
+ // This method reloads video on-demand
+ FB.XFBML.parse();
+
+ if (autoplay) {
+ fbApi.play();
+ }
+
+ break;
+
+ case 'currentTime':
+ fbApi.seek(value);
+ break;
+
+ case 'muted':
+ if (value) {
+ fbApi.mute();
+ } else {
+ fbApi.unmute();
+ }
+ setTimeout(function () {
+ var event = mejs.Utils.createEvent('volumechange', fbWrapper);
+ mediaElement.dispatchEvent(event);
+ }, 50);
+ break;
+
+ case 'volume':
+ fbApi.setVolume(value);
+ setTimeout(function () {
+ var event = mejs.Utils.createEvent('volumechange', fbWrapper);
+ mediaElement.dispatchEvent(event);
+ }, 50);
+ break;
+
+ case 'readyState':
+ var event = mejs.Utils.createEvent('canplay', fbWrapper);
+ mediaElement.dispatchEvent(event);
+ break;
+
+ default:
+
+ break;
+ }
+ } else {
+ // store for after "READY" event fires
+ apiStack.push({ type: 'set', propName: propName, value: value });
+ }
+ };
+ };
+
+ for (var i = 0, total = props.length; i < total; i++) {
+ assignGettersSetters(props[i]);
+ }
+
+ // add wrappers for native methods
+ var methods = mejs.html5media.methods,
+ assignMethods = function assignMethods(methodName) {
+
+ // run the method on the native HTMLMediaElement
+ fbWrapper[methodName] = function () {
+
+ if (fbApi !== null) {
+
+ // DO method
+ switch (methodName) {
+ case 'play':
+ return fbApi.play();
+ case 'pause':
+ return fbApi.pause();
+ case 'load':
+ return null;
+
+ }
+ } else {
+ apiStack.push({ type: 'call', methodName: methodName });
+ }
+ };
+ };
+
+ for (var _i = 0, _total = methods.length; _i < _total; _i++) {
+ assignMethods(methods[_i]);
+ }
+
+ /**
+ * Dispatch a list of events
+ *
+ * @private
+ * @param {Array} events
+ */
+ function sendEvents(events) {
+ for (var _i2 = 0, _total2 = events.length; _i2 < _total2; _i2++) {
+ var event = mejs.Utils.createEvent(events[_i2], fbWrapper);
+ mediaElement.dispatchEvent(event);
+ }
+ }
+
+ /**
+ * Create a new Facebook player and attach all its events
+ *
+ * This method creates a
element that, once the API is available, will generate an