/*	Load the media
==================================================
766511
function() {
		var self = this;

		// Create Dom elements
		this._el.content_item	= TL.Dom.create("div", "tl-media-item tl-media-documentcloud tl-media-shadow", this._el.content);
		this._el.content_item.id = TL.Util.unique_ID(7)

		// Check url
		if(this.data.url.match(/\.html$/)) {
		    this.data.url = this._transformURL(this.data.url);
		} else if(!(this.data.url.match(/.(json|js)$/))) {
		    trace("DOCUMENT CLOUD IN URL BUT INVALID SUFFIX");
		}

		// Load viewer API
        TL.Load.js([
					'https://assets.documentcloud.org/viewer/loader.js',
					'https://assets.documentcloud.org/viewer/viewer.js'],
            function() {	
	            self.createMedia();
			}
		);
	}
639208
public function updateMedia()
    {
        $aMediaUrls = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('aMediaUrls');
        if (is_array($aMediaUrls)) {
            foreach ($aMediaUrls as $sMediaId => $aMediaParams) {
                $oMedia = oxNew(\OxidEsales\Eshop\Application\Model\MediaUrl::class);
                if ($oMedia->load($sMediaId)) {
                    $oMedia->setLanguage(0);
                    $oMedia->assign($aMediaParams);
                    $oMedia->setLanguage($this->_iEditLang);
                    $oMedia->save();
                }
            }
        }
    }
443803
function () {
    if (this.loadTypeSet || this.loadType === LoaderBase.typeText) {
      this.content = this.xhr.response || this.xhr.responseText;
    } else {
      switch (this.loadType) {

        case LoaderBase.typeArraybuffer:

          if (ArrayBuffer) {
            this.content = stringToArrayBuffer(this.xhr.response);
          } else {
            throw new Error('This browser does not support ArrayBuffer');
          }
          break;

        case LoaderBase.typeBlob:
        case LoaderBase.typeVideo:
        case LoaderBase.typeAudio:

          if (Blob) {
            if (!this.fileMeta) {
              this.fileMeta = new FileMeta();
            }

            if (this.fileMeta.mime === null) {
              this.fileMeta.mime = getMimeFromURL(this.url);
            }

            this.content = new Blob([ stringToArrayBuffer(this.xhr.response) ], { type: this.fileMeta.mime });
          } else {
            throw new Error('This browser does not support Blob');
          }
          break;

        case LoaderBase.typeJSON:

          this.content = JSON.parse(this.xhr.response);
          break;

        case LoaderBase.typeDocument:

          // this needs some work pretty sure there's a better way to handle this
          this.content = this.xhr.response;
          break;

      }
    }
  }
187252
protected function assignMedia()
	{

		// On development create all the packed files on the fly:
		if ( \Sifo\Domains::getInstance()->getDevMode() )
		{
			$packer = new \Sifo\JsPacker();
			$packer->packMedia();
			$packer = new \Sifo\CssPacker();
			$packer->packMedia();
		}

		$this->assign( 'media', \Sifo\Config::getInstance()->getConfig( 'css' ) );
		$this->assign( 'css_groups', $this->css_groups );
		$this->assign( 'js_groups', $this->js_groups );

		$this->assign( 'static_rev', $this->getStaticRevision() );
		$this->assign( 'media_module', $this->fetch( 'shared/media_packer.tpl' ) );

	}
1181536
function load() {
  if (!loaded) {
    var addons = [], skipped = [];

    // load addon modules
    api.require.forEach(['socketstream-*','socketstream.*'],function(mod,id) {
      if (typeof mod === 'function') {
        try {
          mod(api);
          addons.push(id);
        } catch(ex) {
          debug('Failed to load '+id+'. ',ex);
        }
      } else {
        skipped.push(id);
      }
    });
    debug('Addons: '+
      addons.length? addons.join(' + ') + ' Loaded. ':' None. '+
      skipped.length? skipped.join(' + ') + ' Skipped. ':'');

    // load assets in cache
    http.load();

    // Load Client Asset Manager
    client.load();

    // Load internal and project responders
    api.server.responders = exports.responders.load();

    api.server.eventTransport = publish.transport.load();

    // Extend the internal API with a publish object you can call from your own server-side code
    api.publish = publish.api(api.server.eventTransport);

    // Bind responders to websocket
    ws.load(api.server.responders, api.server.eventTransport);

    debug('API loaded.');
  }
  loaded = true;
}
990448
private function loadImages()
    {
        if (count($this->images) == 1) {
            $this->addMeta('image', $this->images[0]);

            return;
        }

        foreach ($this->images as $number => $url) {
            $this->addMeta("image{$number}", $url);
        }
    }
876621
function fixUpMediaElement (mediaEl) {
  // Cross-origin.
  var newMediaEl = setCrossOrigin(mediaEl);

  // Plays inline for mobile.
  if (newMediaEl.tagName && newMediaEl.tagName.toLowerCase() === 'video') {
    newMediaEl.setAttribute('playsinline', '');
    newMediaEl.setAttribute('webkit-playsinline', '');
  }

  if (newMediaEl !== mediaEl) {
    mediaEl.parentNode.appendChild(newMediaEl);
    mediaEl.parentNode.removeChild(mediaEl);
  }
  return newMediaEl;
}
35058
function() {
		var api_url,
			self = this;

		// Create Dom element
		this._el.content_item	= TL.Dom.create("div", "tl-media-item tl-media-iframe tl-media-vimeo tl-media-shadow", this._el.content);

		// Get Media ID
		this.media_id = this.data.url.split(/video\/|\/\/vimeo\.com\//)[1].split(/[?&]/)[0];
		var start_time = null;

		// Get start time
		if (this.data.url.match(/#t=([^&]+).*/)) {
			start_time = this.data.url.match(/#t=([^&]+).*/)[1];
		}

		// API URL
		api_url = "https://player.vimeo.com/video/" + this.media_id + "?api=1&title=0&amp;byline=0&amp;portrait=0&amp;color=ffffff";
		if (start_time) {
			api_url = api_url += '&amp;#t=' + start_time;
		}

		this.player = TL.Dom.create("iframe", "", this._el.content_item);

		// Media Loaded Event
		this.player.addEventListener('load', function(e) {
			self.onMediaLoaded();
		});

		this.player.width 		= "100%";
		this.player.height 		= "100%";
		this.player.frameBorder = "0";
		this.player.src 		= api_url;

		this.player.setAttribute('allowfullscreen', '');
		this.player.setAttribute('webkitallowfullscreen', '');
		this.player.setAttribute('mozallowfullscreen', '');

		// After Loaded
		this.onLoaded();
	}
734406
function(e) {
              that.environment = {
                flash:e.jPlayer.flash.used,
                html:e.jPlayer.html.used
              };
              that.flagPlayerReady = true;
              that.loadTrack(that.options.url);
              if(that.options.autoPlay) {
                if(that.environment.flash){
                  that.player.jPlayer('play');
                } else {
                  that.doOnCanPlay = function(){
                    that.player.jPlayer('play');
                  };
                }
              }
              that.options.onReady();
            }
194325
public function load()
    {
        if (empty($this->_statements)) {
            parent::load();
        }

        /* @var $template_engine \TemplateEngine\TemplateEngine */
        $template_engine = TemplateEngine::getInstance();

        foreach ($this->getOrganizedStatements() as $type=>$statements) {
            foreach ($statements as $statement) {
                if ('css'===$type) {
                    $template_object = $template_engine->getTemplateObject('CssFile');
                    $css = $statement->getData();
                    if (isset($css['minified']) && true===$css['minified']) {
                        $template_object->addMinified($css['src'], $css['media']);
                    } else {
                        $template_object->add($css['src'], $css['media']);
                    }
                } elseif ('jsfiles_header'===$type) {
                    $template_object = $template_engine->getTemplateObject('JavascriptFile', 'jsfiles_header');
                    $js = $statement->getData();
                    if (
                        (isset($js['minified']) && true===$js['minified']) ||
                        (isset($js['packed']) && true===$js['packed'])
                    ) {
                        $template_object->addMinified($js['src']);
                    } else {
                        $template_object->add($js['src']);
                    }
                } elseif (in_array($type, array('js', 'jsfiles_footer'))) {
                    $template_object = $template_engine->getTemplateObject('JavascriptFile', 'jsfiles_footer');
                    $js = $statement->getData();
                    if (
                        (isset($js['minified']) && true===$js['minified']) ||
                        (isset($js['packed']) && true===$js['packed'])
                    ) {
                        $template_object->addMinified($js['src']);
                    } else {
                        $template_object->add($js['src']);
                    }
                }
            }
        }
    }
258321
def load(self):
    
    media_page = self.session.session.get(u'http://myanimelist.net/' + self.__class__.__name__.lower() + u'/' + str(self.id)).text
    self.set(self.parse(utilities.get_clean_dom(media_page)))
    return self
349270
public function loadMediaMatchAll($tags = [])
    {
        $tags = (array) $tags;
        $closure = function (MorphToMany $q) use ($tags) {
            $this->addMatchAllToEagerLoadQuery($q, $tags);
        };
        $closure = Closure::bind($closure, $this->first(), $this->first());

        return $this->load(['media' => $closure]);
    }
309322
public function getMedia()
    {
        if ($this->media === null) {
            $cache = $this->getMediaCache();

            // Use cached media if possible.
            $cacheKey = md5('media' . $this->getCacheKey());
            if (!$media = $cache->get($cacheKey)) {
                $media = new Media($this->getMediaFolder(), $this->getMediaOrder());
                $cache->set($cacheKey, $media);
            }
            $this->media = $media;
        }

        return $this->media;
    }
1369466
function loadStructure() {
  var pPage = getParam( 'layout' );
  
  if ( pPage == '' ) {
    pPage = "main";
  }
  pageInfo[ 'layout' ] = pPage;
  var avoidCache = false;
  if ( getParam( 'nc' ) == 'true' ) {
    avoidCache = true;
  }  

  var structureURLfallback = "svc/layout/"+pPage+"/structure" + ( avoidCache ?  nc = '?nc='+Math.random(): '' );
  if( mode == "php" ) {
    structureURLfallback = "svc/layout.php?page="+pPage+pEdit+ ( avoidCache ?  nc = '&nc='+Math.random(): '' );
  } else if ( mode == 'direct' ) {
    structureURLfallback =  "svc/layout/"+directPage+"/structure" + ( avoidCache ?  nc = '?nc='+Math.random(): '' );
  }
  
  // mobile detect -- to disable: just remove the script include from the index.html
  if ( typeof MobileDetect == 'function') { 
      var md = new MobileDetect(  navigator.userAgent );
      //console.log( navigator.userAgent );
      if ( md.tablet() ) {
        pageInfo["layoutMode"] = 'tablet';
        pPage = pPage +'-t';
      } else if ( md.mobile() ) {
        pageInfo["layoutMode"] = 'mobile';
        pPage = pPage +'-m';
      }
  }
  
  var pEdit = '';
  if ( getParam( 'edit' ) == 'true' ) {
    pEdit = "&edit=true";
  }
  
  var structureURL = "svc/layout/"+pPage+"/structure" + ( avoidCache ?  nc = '?nc='+Math.random(): '' );
  if( mode == "php" ) {
    structureURL = "svc/layout.php?page="+pPage+pEdit + ( avoidCache ?  nc = '&nc='+Math.random(): '' );
  } else if ( mode == 'direct' ) {
    structureURL =  "svc/layout/"+directPage+"/structure" + ( avoidCache ?  nc = '?nc='+Math.random(): '' );
  } 
  

  console.log("loadStructure: "+structureURL);
  $.getJSON( 
      structureURL, 
      processLayoutResponseJSON
  ).fail(
    function( jqxhr, textStatus, error ) {
      // no layout found -- check the fallback
      ajaxOngoing++;
      $.getJSON( 
          structureURLfallback, 
          processLayoutResponseJSON
      ).fail(
          function( jqxhr, textStatus, error ) {
            //TODO: If "main" not found, then generate a static main page!
            console.log( 'Request for "'+pPage+'" failed: ' + textStatus + ", " + error );
            window.location.href = 'index.html'; 
          }
      ).always(
          function() { ajaxOngoing--;  }
      );
    }
  ).always(
    function() { ajaxOngoing--; }
  );
}
926683
function() {
			this.states.add([
				new wp.media.controller.Library({
					id: 'insert',
					title: this.options.title,
					selection: this.options.selection,
					priority: 20,
					toolbar: 'main-insert',
					filterable: this.options.filterable,
					searchable: this.options.searchable,
					library: wp.media.query( this.options.query ),
					multiple: this.options.multiple,
					editable: this.options.editable,
					displaySettings: this.options.displaySettings,
					displayUserSettings: this.options.displayUserSettings
				}),

				new wp.media.controller.EditImage({ model: this.options.editImage })
			]);
		}
1055502
function () {
    var scope = angular.element(this._el.content).scope();

    // Loading Message
    this.loadingMessage();

    scope.$emit('onMediaLoaded', this);

    this.onLoaded();

    scope.$emit('onCaptionLoaded', this);
  }
419359
function() {
		var self = this,
			url_vars;

		this.youtube_loaded = false;

		// Create Dom element
		this._el.content_item	= TL.Dom.create("div", "tl-media-item tl-media-youtube tl-media-shadow", this._el.content);
		this._el.content_item.id = TL.Util.unique_ID(7)

		// URL Vars
		url_vars = TL.Util.getUrlVars(this.data.url);

		// Get Media ID
		this.media_id = {};

		if (this.data.url.match('v=')) {
			this.media_id.id	= url_vars["v"];
		} else if (this.data.url.match('\/embed\/')) {
			this.media_id.id	= this.data.url.split("embed\/")[1].split(/[?&]/)[0];
		} else if (this.data.url.match(/v\/|v=|youtu\.be\//)){
			this.media_id.id	= this.data.url.split(/v\/|v=|youtu\.be\//)[1].split(/[?&]/)[0];
		} else {
			trace("YOUTUBE IN URL BUT NOT A VALID VIDEO");
		}

		// Get start second
		if (this.data.url.match("start=")) {
			this.media_id.start = parseInt(this.data.url.split("start=")[1], 10);
		}
		else if (this.data.url.match("t=")) {
			this.media_id.start = parseInt(this.data.url.split("t=")[1], 10);
		}

		//Get end second
		if (this.data.url.match("end=")) {
			this.media_id.end = parseInt(this.data.url.split("end=")[1], 10);
		}

		this.media_id.hd		= Boolean(typeof(url_vars["hd"]) != 'undefined');


		// API Call
		TL.Load.js('https://www.youtube.com/iframe_api', function() {
			self.createMedia();
		});

	}