/** gets any defiend on-page uiConf js */ private function getPerUiConfJS() { if (!$this->getResultObject() || !isset($this->getResultObject()->urlParameters['uiconf_id']) || !isset($this->getResultObject()->urlParameters['wid']) && !isset($this->getResultObject()->urlParameters['p'])) { // directly issue the UiConfJs callback return 'kWidget.inLoaderUiConfJsCallback();'; } // load the onPage js services $mweUiConfJs = new mweApiUiConfJs(); // output is set to empty string: $o = ''; // always include UserAgentPlayerRules: $o .= $mweUiConfJs->getUserAgentPlayerRules(); // support including special player rewrite flags if set in uiConf: if ($this->getResultObject()->getPlayerConfig(null, 'Kaltura.LeadWithHTML5') === true) { $o .= "\n" . 'mw.setConfig(\'Kaltura.LeadWithHTML5\', true );'; } if ($this->getResultObject()->getPlayerConfig(null, 'Kaltura.ForceFlashOnIE10') === true) { $o .= "\n" . 'mw.setConfig(\'Kaltura.ForceFlashOnIE10\', true );' . "\n"; } // Only include on page plugins if not in iframe Server if (!isset($_REQUEST['iframeServer'])) { $o .= $mweUiConfJs->getPluginPageJs('kWidget.inLoaderUiConfJsCallback'); } else { $o .= 'kWidget.inLoaderUiConfJsCallback();'; } // set the flag so that we don't have to request the services.php $o .= "\n" . 'kWidget.uiConfScriptLoadList[\'' . $mweUiConfJs->getResultObject()->urlParameters['uiconf_id'] . '\'] = 1; '; return $o; }
/** gets any defiend on-page uiConf js */ private function getPerUiConfJS() { if (!$this->request()->get('uiconf_id') || !$this->getUiConfObject() || !$this->request()->get('wid') && !$this->request()->get('p')) { // directly issue the UiConfJs callback return 'kWidget.inLoaderUiConfJsCallback();'; } // load the onPage js services $mweUiConfJs = new mweApiUiConfJs(); // output is set to empty string: $o = ''; // always include UserAgentPlayerRules: $o .= $mweUiConfJs->getUserAgentPlayerRules(); // support including special player rewrite flags if set in uiConf: if ($this->getUiConfObject()->getPlayerConfig(null, 'Kaltura.LeadWithHTML5') === true || $this->getUiConfObject()->getPlayerConfig(null, 'KalturaSupport.LeadWithHTML5') === true) { $o .= "\n" . "kWidget.addUserAgentRule('{$this->request()->get('uiconf_id')}', '/.*/', 'leadWithHTML5');"; } if ($this->getUiConfObject()->getPlayerConfig(null, 'Kaltura.ForceFlashOnIE10') === true) { $o .= "\n" . 'mw.setConfig(\'Kaltura.ForceFlashOnIE10\', true );' . "\n"; } if ($this->getUiConfObject()->isJson()) { $o .= "\n" . "kWidget.addUserAgentRule('{$this->request()->get('uiconf_id')}', '/.*/', 'leadWithHTML5');"; } // If we have entry data if ($this->request()->get('entry_id')) { global $container, $wgExternalPlayersSupportedTypes; try { $entryResult = $container['entry_result']; $entry = $entryResult->getResult(); $metaData = @get_object_vars($entry['meta']); if (isset($metaData["externalSourceType"])) { if (in_array(strtolower($metaData["externalSourceType"]), array_map('strtolower', $wgExternalPlayersSupportedTypes))) { $o .= "\n" . 'mw.setConfig(\'forceMobileHTML5\', true );' . "\n"; } } } catch (Exception $e) { // } } // Only include on page plugins if not in iframe Server if (!isset($_REQUEST['iframeServer'])) { $o .= $mweUiConfJs->getPluginPageJs('kWidget.inLoaderUiConfJsCallback'); } else { $o .= 'kWidget.inLoaderUiConfJsCallback();'; } // set the flag so that we don't have to request the services.php $o .= "\n" . 'kWidget.uiConfScriptLoadList[\'' . $this->request()->get('uiconf_id') . '\'] = 1; '; return $o; }
function outputIFrame() { //die( '<pre>' . htmlspecialchars($this->getVideoHTML()) ); global $wgResourceLoaderUrl; $path = str_replace('ResourceLoader.php', '', $wgResourceLoaderUrl); // Check for plugins ( can overide output) $this->checkIframePlugins(); $this->setIFrameHeaders(); ?> <!DOCTYPE html> <html> <head> <script type="text/javascript"> /*@cc_on@if(@_jscript_version<9){'video audio source track'.replace(/\w+/g,function(n){document.createElement(n)})}@end@*/ </script> <?php echo $this->outputIframeHeadCss(); ?> </head> <body> <?php // Check if the object should be writen by javascript ( instead of outputing video tag and player pay load ) if ($this->getResultObject()->isJavascriptRewriteObject()) { echo $this->getFlashEmbedHTML(); } else { if ($this->getResultObject()->isPlaylist()) { echo $this->getPlaylistWraper($this->getVideoHTML($this->getPlaylistPlayerSizeCss() . ';display:block;')); } else { // For the actual video tag we need to use a document.write since android dies // on some video tag properties ?> <script type="text/javascript"> function getViewPortSize(){ var w; var h; // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight if (typeof window.innerWidth != 'undefined'){ w = window.innerWidth, h = window.innerHeight } // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document) else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0){ w = document.documentElement.clientWidth, h = document.documentElement.clientHeight } else {// older versions of IE w = document.getElementsByTagName('body')[0].clientWidth, h = document.getElementsByTagName('body')[0].clientHeight } return { 'w': w, 'h': h }; } var videoTagHTML = <?php echo json_encode($this->getVideoHTML()); ?> ; var ua = navigator.userAgent // Android can't handle position:absolute style on video tags if( ua.indexOf('Android' ) !== -1 ){ // Also android does not like "type" on source tags videoTagHTML= videoTagHTML.replace(/type=\"[^\"]*\"/g, ''); } // IE < 8 does not handle class="persistentNativePlayer" very well: if( ua.indexOf("MSIE ")!== -1 && parseFloat( ua.substring( ua.indexOf("MSIE ") + 5, ua.indexOf(";", ua.indexOf("MSIE ") ) )) <= 8 ) { videoTagHTML = videoTagHTML.replace( /class=\"persistentNativePlayer\"/gi, '' ); } var size = getViewPortSize(); styleValue = 'display: block;width:' + size.w + 'px;height:' + size.h + 'px;'; videoTagHTML = videoTagHTML.replace(/style=\"\"/, 'style="' + styleValue + '"'); document.write( videoTagHTML ); </script> <?php } } ?> <script type="text/javascript"> // In same page iframe mode the script loading happens inline and not all the settings get set in time // its critical that at least EmbedPlayer.IsIframeServer is set early on. window.preMwEmbedConfig = {}; window.preMwEmbedConfig['EmbedPlayer.IsIframeServer'] = true; </script> <!-- Add the mwEmbedLoader.php --> <script src="<?php echo $this->getMwEmbedLoaderLocation(); ?> " type="text/javascript"></script> <!-- Add the kaltura ui logic as inline script: --> <script type="text/javascript"><?php $uiConfJ = new mweApiUiConfJs(); echo $uiConfJ->getUserAgentPlayerRules(); ?> </script> <script type="text/javascript" > // Insert JSON support if in missing ( IE 7, 8 ) if( typeof JSON == 'undefined' ){ document.write(unescape("%3Cscript src='<?php echo $path; ?> /libraries/json/json2.js' type='text/javascript'%3E%3C/script%3E")); } </script> <script type="text/javascript"> // IE has out of order stuff execution... we have a pooling funciton to make sure mw is ready before we procceed. var waitForMwCount = 0; var waitforMw = function( callback ){ if( window['mw'] ){ callback(); return ; } setTimeout(function(){ waitForMwCount++; if( waitForMwCount < 1000 ){ waitforMw( callback ); } else { console.log("Error in loading mwEmbedLodaer"); } }, 10 ); }; waitforMw( function(){ <?php global $wgAllowCustomResourceIncludes; if ($wgAllowCustomResourceIncludes && $this->getCustomPlayerIncludesJSON()) { echo 'mw.setConfig( \'Mw.CustomResourceIncludes\', ' . $this->getCustomPlayerIncludesJSON() . ' );'; } ?> // Parse any configuration options passed in via hash url more reliable than window['parent'] try{ if( window['parent'] && window['parent']['preMwEmbedConfig'] ){ // Grab config from parent frame: mw.setConfig( window['parent']['preMwEmbedConfig'] ); // Set the "iframeServer" to the current domain ( do not include hash tag ) mw.setConfig( 'EmbedPlayer.IframeParentUrl', document.URL.replace(/#.*/, '' ) ); } } catch( e ) { // could not get config from parent javascript scope try hash string: var hashString = document.location.hash; try{ var hashObj = JSON.parse( unescape( hashString.replace( /^#/, '' ) ) ); if( hashObj && hashObj.mwConfig ){ mw.setConfig( hashObj.mwConfig ); } } catch( e ) { // error could not parse hash tag ( run with default config ) } } mw.setConfig('KalturaSupport.PlayerConfig', <?php echo json_encode($this->getResultObject()->getPlayerConfig()); ?> ); // We should first read the config for the hashObj and after that overwrite with our own settings // The entire block below must be after mw.setConfig( hashObj.mwConfig ); // Don't do an iframe rewrite inside an iframe mw.setConfig('Kaltura.IframeRewrite', false ); // Set a prepend flag so its easy to see whats happening on client vs server side of the iframe: mw.setConfig('Mw.LogPrepend', 'iframe:'); // Don't rewrite the video tag from the loader ( if html5 is supported it will be // invoked below and respect the persistant video tag option for iPad overlays ) mw.setConfig( 'Kaltura.LoadScriptForVideoTags', false ); // Don't wait for player metada for size layout and duration Won't be needed since // we add durationHint and size attributes to the video tag mw.setConfig( 'EmbedPlayer.WaitForMeta', false ); // Add Packaging Kaltura Player Data ( JSON Encoded ) mw.setConfig( 'KalturaSupport.IFramePresetPlayerData', <?php echo $this->getResultObject()->getJSON(); ?> ); mw.setConfig('EmbedPlayer.IframeParentPlayerId', '<?php echo $this->getIframeId(); ?> ' ); // Set uiConf global vars for this player ( overides iframe based hash url config ) <?php echo $this->getCustomPlayerConfig(); ?> // Remove the fullscreen option if we are in an iframe: if( mw.getConfig('EmbedPlayer.IsFullscreenIframe') ){ mw.setConfig('EmbedPlayer.EnableFullscreen', false ); } else { // If we don't get a 'EmbedPlayer.IframeParentUrl' update fullscreen to pop-up new // window. ( we won't have the iframe api to resize the iframe ) if( mw.getConfig('EmbedPlayer.IframeParentUrl') === null ){ mw.setConfig( "EmbedPlayer.NewWindowFullscreen", true ); } } // For testing limited capacity browsers //var kIsHTML5FallForward = function(){ return false }; //var kSupportsFlash = function(){ return false }; <?php if (!$this->getResultObject()->isJavascriptRewriteObject()) { echo $this->javascriptPlayerLogic(); } ?> // Because IE has out of order execution issues, we don't check the dom until we get here: setTimeout(function(){ kRunMwDomReady( 'endOfIframeJs' ); },0); }); </script> </body> </html> <?php }