Skip to content

Commit

Permalink
updated hash iframe object passing
Browse files Browse the repository at this point in the history
fixed jquery conflict
mwEmbed sequencer updates

git-svn-id: http://www.kaltura.org/kalorg/html5video/trunk/mwEmbed@1260 b58a29cf-3064-46da-94c6-1c29cc75c8e5
  • Loading branch information
KalturaGitBot committed Dec 2, 2010
1 parent a85c8a5 commit d43220b
Show file tree
Hide file tree
Showing 16 changed files with 201 additions and 53 deletions.
4 changes: 2 additions & 2 deletions modules/EmbedPlayer/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@
// Do short detection, to avoid extra player library request in ~most~ cases.
//( If browser is firefox include native, if browser is IE include java )
if( $j.browser.msie ) {
dependencyRequest[0].push( 'mw.EmbedPlayerJava' )
dependencyRequest[0].push( 'mw.EmbedPlayerJava' );
}

// Safari gets slower load since we have to detect ogg support
Expand All @@ -352,7 +352,7 @@
}

// Check if the iFrame player server is enabled:
if (mw.getConfig('EmbedPlayer.EnableIFramePlayerServer')) {
if (mw.getConfig('EmbedPlayer.EnableIframeApi')) {
dependencyRequest[0].push('mw.EmbedPlayerNative');
dependencyRequest[0].push('$j.postMessage');
dependencyRequest[0].push('mw.IFramePlayerApiServer');
Expand Down
4 changes: 2 additions & 2 deletions modules/EmbedPlayer/mw.IFramePlayerApiServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ mw.IFramePlayerApiServer.prototype = {
'hanldeMsg': function( event ){
//mw.log( 'IFramePlayerApiServer:: hanldeMsg ');
// Check if the server should even be enabled
if( !mw.getConfig( 'EmbedPlayer.EnableIFramePlayerServer' )){
mw.log( 'Error: EmbedPlayer.EnableIFramePlayerServer is false');
if( !mw.getConfig( 'EmbedPlayer.EnableIframeApi' )){
mw.log( 'Error: Loading iFrame playerApi but config EmbedPlayer.EnableIframeApi is false');
return false;
}

Expand Down
25 changes: 18 additions & 7 deletions modules/KalturaSupport/kalturaIframe.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* kalturaIframe supp
* kalturaIframe support
*
*/

Expand Down Expand Up @@ -110,12 +110,12 @@ private function getFlavorSources(){
$resultObject = $client->doQueue();
$client->throwExceptionIfError($resultObject);
} catch( Exception $e ){
$this->error = $e;
return ;
$this->error = "Error getting sources from server, something maybe broken or server is under high load. Please try again.";
return array();
}
// add any web sources
$sources = array();
foreach($resultObject as $KalturaFlavorAsset ){
foreach( $resultObject as $KalturaFlavorAsset ){

$assetUrl = KALTURA_CDN_URL .'/p/' . $partnerId . '/sp/' .
$partnerId . '00/flvclipper/entry_id/' .
Expand Down Expand Up @@ -211,7 +211,7 @@ private function getVideoHTML( ){

// Output each source as a child element ( for javascript off browsers to have a chance
// to playback the content
foreach($sources as $source ){
foreach( $sources as $source ){
$o.="\n" .'<source ' .
'type="' . htmlspecialchars( $source['type'] ) . '" ' .
'src="' . htmlspecialchars( $source['src'] ) . '" '.
Expand Down Expand Up @@ -311,6 +311,17 @@ function outputIFrame( ){
document.write(unescape("%3Cscript src='<?php echo KALTURA_MWEMBED_PATH ?>mwEmbedLoader.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
// Parse any configuration options passed in via hash url:
var hashString = document.location.hash;
if( hashString ){
var hashObj = JSON.parse(
decodeURIComponent( hashString.replace( /^#/, '' ) )
);
if( hashObj.mwConfig ){
mw.setConfig( hashConfig );
}
}

// Don't rewrite the video tag from the loader ( if html5 is supported it will be
// invoked bellow and respect the persistant video tag option for iPad overlays )
mw.setConfig( 'Kaltura.LoadScriptForVideoTags', false );
Expand All @@ -325,8 +336,8 @@ function outputIFrame( ){
// We can't support full screen in object context since it requires outer page DOM control
mw.setConfig( 'EmbedPlayer.EnableFullscreen', false );

// Enable the iframe player server:
mw.setConfig( 'EmbedPlayer.EnableIFramePlayerServer', true );
// By default the iFrame api is dissabled ( its enabled via iframe url hash config )
mw.setConfig( 'EmbedPlayer.EnableIframeApi', false );

// Load the mwEmbed resource library
mw.ready(function(){
Expand Down
57 changes: 43 additions & 14 deletions modules/KalturaSupport/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,13 @@
)
});
// Check if we are doing iFrame rewrite ( skip local library loading )
if( mw.getConfig( 'Kaltura.IframeRewrite' ) ){
// Establish the "server" domain via mwEmbed path:
var mwPathUri = mw.parseUri( mw.getMwEmbedPath() );
var iframeServer = mwPathUri.protocol + '://' + mwPathUri.host;
// Load the iFrame player client ( if not already loaded )
mw.load( ['mw.EmbedPlayerNative', '$j.postMessage', 'mw.IFramePlayerApiClient', 'JSON'], function(){
if( mw.getConfig( 'Kaltura.IframeRewrite' ) ){
// Local function to handle iframe rewrites:
var doRewriteIframe = function( appendToIframeRequest ){
// Establish the "server" domain via mwEmbed path:
var mwPathUri = mw.parseUri( mw.getMwEmbedPath() );
var iframeServer = mwPathUri.protocol + '://' + mwPathUri.host;

$j( '.mwEmbedKalturaVideoSwap,.mwEmbedKalturaPlaylistSwap' ).each( function( inx, playerTarget ) {
// Output the iframe request in kaltura /{key}/{value} request format:
var iframeRequest = '';
Expand All @@ -207,28 +208,56 @@
'/' + encodeURIComponent( $j(playerTarget).attr( tagKey ) );
}
}
var kArgumentsSeperator ='/?';

// @@todo should move these url flags into config
// Add debug flag if set:
if( mw.getConfig( 'debug' ) ){
iframeRequest+='/?debug=true';
iframeRequest+= kArgumentsSeperator + 'debug=true';
kArgumentsSeperator ='';
}
// Pass along forceHTML5 if present:
if( document.URL.indexOf('forceMobileHTML5') != -1 ){
iframeRequest+= kArgumentsSeperator + 'forceMobileHTML5=true';
kArgumentsSeperator ='';
};

// Append any requested string to the url
if( appendToIframeRequest){
iframeRequest+= appendToIframeRequest
}
// Add the parent frame location as a hash url:
iframeRequest+= '#' + encodeURIComponent(
JSON.stringify( { 'parentUrl' : document.location.href } )
);
var iframeId = $j( playerTarget ).attr('id');
var $iframe = $j('<iframe />').attr({
'id' : $j( playerTarget ).attr('id'),
'class' : $j( playerTarget ).attr('class' ),
'class' : $j( playerTarget ).attr('class' ) + ' mwEmbedKalturaIframe',
'src' : mw.getMwEmbedPath() + 'mwEmbedFrame.php' + iframeRequest,
'height' : $j( playerTarget ).height(),
'width' : $j( playerTarget ).width()
}).css('border', '0px');

// Replace the player with the iframe:
$j( playerTarget ).replaceWith( $iframe );
$j( '#' + iframeId ).iFramePlayer({
});
}

if( mw.getConfig('EmbedPlayer.EnableIframeApi') ){
// Load the iFrame player client
mw.load( ['mw.EmbedPlayerNative', '$j.postMessage', 'mw.IFramePlayerApiClient', 'JSON'], function(){
// Rewrite the iframe encoding the parent url hash to support the iframe api
doRewriteIframe('#' + encodeURIComponent(
JSON.stringify( {
'parentUrl' : document.location.href,
'mwConfig' : mw.getNonDefaultConfigObject(),
} )
));
// Invoke the iframe player api system:
$j( '.mwEmbedKalturaIframe').iFramePlayer({
'iframeServer' : iframeServer
});
});
});
} else {
doRewriteIframe();
}
// Don't do any other rewrites or library loading
return true;
}
Expand Down
5 changes: 4 additions & 1 deletion modules/KalturaSupport/mw.KWidgetSupport.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ mw.KWidgetSupport.prototype = {
var _this = this;
mw.log(' kWidgetSupport::check for sources: ' + $j( embedPlayer ).attr( 'kentryid' ) );
// Check if entry id is a url ( add the source directly )
if( $j( embedPlayer ).attr( 'kentryid' ).indexOf('://') != -1 ){
if( $j( embedPlayer ).attr( 'kentryid' )
&&
$j( embedPlayer ).attr( 'kentryid' ).indexOf('://') != -1 )
{
embedPlayer.mediaElement.tryAddSource(
$j('<source />')
.attr( {
Expand Down
9 changes: 6 additions & 3 deletions modules/Playlist/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

mw.addResourcePaths( {
"mw.Playlist" : "mw.Playlist.js",
"mw.PlaylistHandlerMediaRss" : "mw.PlaylistHandlerMediaRss.js"
"mw.PlaylistHandlerMediaRss" : "mw.PlaylistHandlerMediaRss.js",
"mw.PlaylistLayoutJQueryUi" : "mw.PlaylistLayoutJQueryUi.js",
"mw.PlaylistLayoutMobile" : "mw.PlaylistLayoutMobile.js"
});

// Set the default config
Expand All @@ -33,8 +35,9 @@

// Module loader
mw.addModuleLoader( 'Playlist', function(){
var resourceList = ["mw.Playlist", "mw.PlaylistHandlerMediaRss" ]
return resourceList;
//@@todo loader should check playlist configuration and conditionally load the MobileTheme
return ["mw.Playlist", "mw.PlaylistHandlerMediaRss",
'mw.PlaylistThemeUi', 'mw.PlaylistLayoutMobile'];
});


Expand Down
21 changes: 18 additions & 3 deletions modules/Playlist/mw.Playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ mw.Playlist.prototype = {
// Stores the cached player size:
targetPlayerSize: null,

// Interface type can jqueryui or jquerymobile
interfaceType : 'jqueryui',
// The source handler
sourceHandler: null,

// the theme handler:
theme : null,


// constructor
Expand All @@ -38,6 +41,14 @@ mw.Playlist.prototype = {
if( options.sourceHandler ) {
this.sourceHandler = options.sourceHandler;
}
// Set the layoutHandler
if( !options.layoutHandler || option.layoutHandler == 'jqueryui' ){
this.layoutHandler = new mw.PlaylistThemeUi( this );
} else if( option.layoutHandler == 'mobile' ) {
this.layoutHandler = new mw.PlaylistThemeMobile( this );
} else {
mw.log("Error:: unsuported playlist theme: " + option.layoutHandler );
}


// Set binding to disable "waitForMeta" for playlist items ( we know the size and length )
Expand Down Expand Up @@ -88,7 +99,10 @@ mw.Playlist.prototype = {
$j( _this.target ).empty().text( gM('mwe-playlist-empty') )
return ;
}


// Setup the layout
_this.layoutHandler.drawUi( _this.target )

// Empty the target and setup player and playerList divs
$j( _this.target )
.empty()
Expand Down Expand Up @@ -292,6 +306,7 @@ mw.Playlist.prototype = {
'top' : $j( _this.target + ' .media-rss-video-player-container' ).height() + 8
})
}

// Add scroll buttons:
$j( _this.target ).append(
$j( '<div />').css({
Expand Down
1 change: 1 addition & 0 deletions modules/Playlist/mw.PlaylistLayoutJQueryUi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* jquery ui theme for playlist */
1 change: 1 addition & 0 deletions modules/Playlist/mw.PlaylistLayoutMobile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* small screen mobile theme for playlist */
2 changes: 1 addition & 1 deletion modules/Playlist/tests/Player_MediaRss.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
$j('#mediaRssMobile').playlist({
'src' : "kalturaInterviewPlaylist.xml",
'type' : 'application/rss+xml',
'interface' : 'mobile'
'theme' : 'mobile'
});
});
</script>
Expand Down
5 changes: 3 additions & 2 deletions modules/SmilPlayer/mw.SmilAnimate.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,10 @@ mw.SmilAnimate.prototype = {
transformMediaForTime: function( smilElement, animateTime, callback ){
// Get the video element
var assetId = this.smil.getSmilElementPlayerID( smilElement );
var media = $j( assetId ).find('audio,video').get( 0 );
var media = $j('#' + assetId ).find('audio,video').get( 0 );

if( !media ){
mw.log("Error: transformMediaForTime could not find media asest: " +assetId );
mw.log("Error: transformMediaForTime could not find media asest: " + assetId );
}


Expand Down
Loading

0 comments on commit d43220b

Please sign in to comment.