Skip to content

Commit

Permalink
sync with mwEmbedStandAlone
Browse files Browse the repository at this point in the history
minor fix to embedPlayer array check in config merge

git-svn-id: http://www.kaltura.org/kalorg/html5video/trunk/mwEmbed@1189 b58a29cf-3064-46da-94c6-1c29cc75c8e5
  • Loading branch information
KalturaGitBot committed Nov 15, 2010
1 parent 861c945 commit 5b5f308
Show file tree
Hide file tree
Showing 12 changed files with 898 additions and 847 deletions.
426 changes: 209 additions & 217 deletions modules/EmbedPlayer/loader.js

Large diffs are not rendered by default.

118 changes: 62 additions & 56 deletions modules/EmbedPlayer/mw.EmbedPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ mw.setDefaultConfig( 'EmbedPlayer.SourceAttributes', [
'title',

// boolean if we support temporal url requests on the source media
'URLTimeEncoding',
'URLTimeEncoding',

// Media has a startOffset ( used for plugins that
// display ogg page time rather than presentation time
Expand Down Expand Up @@ -475,8 +475,8 @@ EmbedPlayerManager.prototype = {

// Set swapPlayerElement has height / width set and set to loading:
$j( swapPlayerElement ).css( {
'width' : playerInterface.width,
'height' : playerInterface.height
'width' : playerInterface.width + 'px',
'height' : playerInterface.height + 'px'
} );

// If we don't already have a loadSpiner add one:
Expand Down Expand Up @@ -1464,7 +1464,6 @@ mw.EmbedPlayer.prototype = {
* element Source element to grab size from
*/
setPlayerSize: function( element ) {

this.height = $j(element).css( 'height' );
this.width = $j(element).css( 'width' );

Expand Down Expand Up @@ -1495,7 +1494,7 @@ mw.EmbedPlayer.prototype = {
// Firefox sets audio height to "0px" while webkit uses 32px .. force
// zero:
if( element.tagName.toLowerCase() == 'audio' && this.height == '32' ) {
this.height = 0;
this.height = 0;
}

// Use default aspect ration to get height or width ( if rewriting a
Expand Down Expand Up @@ -2034,7 +2033,7 @@ mw.EmbedPlayer.prototype = {
* Show the player
*/
showPlayer : function () {
mw.log( 'EmbedPlayer:: Show player: ' + this.id + ' interace: w:' + this.width + ' h:' + this.height);
mw.log( 'EmbedPlayer:: Show player: ' + this.id + ' interace: w:' + this.width + ' h:' + this.height );
var _this = this;
// Set-up the local controlBuilder instance:
this.controlBuilder = new mw.PlayerControlBuilder( this );
Expand All @@ -2043,23 +2042,20 @@ mw.EmbedPlayer.prototype = {
// Make sure we have mwplayer_interface
if( $j( this ).parent( '.mwplayer_interface' ).length == 0 ) {
// Select "player"
$j( this )
.wrap(
$j( this ).wrap(
$j('<div>')
.addClass( 'mwplayer_interface ' + this.controlBuilder.playerClass )
.css({
'width' : this.width,
'height' : this.height,
'width' : this.width + 'px',
'height' : this.height + 'px',
'position' : 'relative',
'background' : '#000'
})
)
// position the "player" absolute inside the relative interface
// parent:
.css('position', 'absolute');
}


}

// Set up local jQuery object reference to "mwplayer_interface"
this.$interface = $j( this ).parent( '.mwplayer_interface' );
Expand Down Expand Up @@ -2477,60 +2473,70 @@ mw.EmbedPlayer.prototype = {
},

/**
* Get the share embed object code
*
* NOTE this could probably share a bit more code with getShareEmbedVideoJs
*/
getShareEmbedObject: function(){
var iframeUrl = mw.getMwEmbedPath() + 'mwEmbedFrame.php?';
var params = {};
* Get the share embed object code
*
* NOTE this could probably share a bit more code with getShareEmbedVideoJs
*/
getShareIframeObject: function(){

if ( this.roe ) {
params.roe = this.roe;
} else if( this.apiTitleKey ) {
params.apiTitleKey = this.apiTitleKey;
if ( this.apiProvider ) {
// Commons always uses the commons api provider ( special hack
// should refactor )
if( mw.parseUri( document.URL ).host == 'commons.wikimedia.org'){
this.apiProvider = 'commons';
}
params.apiProvider = this.apiProvider;
}
// If using a gadget do the new embed format:
// @@NOTE this should be factored out into mediaWiki gadget helper
if( typeof wgServer != 'undefined' && typeof mwCheckForGadget != 'undefined' ){
var iframeUrl = wgServer + wgArticlePath.replace( /\$1/, wgPageName ) +
'?' + mw.getConfig( 'Mw.AppendWithJS' ) +
'&embedplayer=yes';
} else {
// Output all the video sources:
for( var i=0; i < this.mediaElement.sources.length; i++ ){
var source = this.mediaElement.sources[i];
if( source.src ) {
params['src[]'] = mw.absoluteUrl( source.src );
// old style embed:
var iframeUrl = mw.getMwEmbedPath() + 'mwEmbedFrame.php?';
var params = {};

if ( this.roe ) {
params.roe = this.roe;
} else if( this.apiTitleKey ) {
params.apiTitleKey = this.apiTitleKey;
if ( this.apiProvider ) {
// Commons always uses the commons api provider ( special hack should refactor )
if( mw.parseUri( document.URL ).host == 'commons.wikimedia.org'){
this.apiProvider = 'commons';
}
params.apiProvider = this.apiProvider;
}
} else {
// Output all the video sources:
for( var i=0; i < this.mediaElement.sources.length; i++ ){
var source = this.mediaElement.sources[i];
if( source.src ) {
params['src[]'] = mw.absoluteUrl( source.src );
}
}
// Output the poster attr
if( this.poster ){
params.poster = this.poster;
}
}
// Output the poster attr
if( this.poster ){
params.poster = this.poster;

// Set the skin if set to something other than default
if( this.skinName ){
params.skin = this.skinName;
}

if( this.duration ) {
params.durationHint = parseFloat( this.duration );
}
iframeUrl += $j.param( params );
}

// Set the skin if set to something other than default
if( this.skinName ){
params.skin = this.skinName;
}

if( this.duration ) {
params.durationHint = parseFloat( this.duration );
}
iframeUrl += $j.param( params );


// Set up embedFrame src path
var embedCode = '&lt;iframe src=&quot;' + mw.escapeQuotesHTML( iframeUrl ) + '&quot; ';

// Set width / height of embed object
embedCode += 'width=&quot;' + this.getPlayerWidth() +'&quot; ';
embedCode += 'height=&quot;' + this.getPlayerHeight() + '&quot; ';

embedCode += 'frameborder=&quot;0&quot; ';

// Close up the embedCode tag:
embedCode+='&gt;&lt/iframe&gt;';

// Return the embed code
return embedCode;
},
Expand Down Expand Up @@ -3074,14 +3080,14 @@ mw.EmbedPlayer.prototype = {

// Get the buffer target based for playlist vs clip
$buffer = this.$interface.find( '.mw_buffer' );
//mw.log(' set bufferd %:' + this.bufferedPercent );
// Update the buffer progress bar (if available )
if ( this.bufferedPercent != 0 ) {
// mw.log('Update buffer css: ' + ( this.bufferedPercent * 100 ) +
// '% ' + $buffer.length );
if ( this.bufferedPercent > 1 ){
this.bufferedPercent = 1;
}

}
$buffer.css({
"width" : ( this.bufferedPercent * 100 ) + '%'
});
Expand Down
27 changes: 15 additions & 12 deletions modules/EmbedPlayer/mw.EmbedPlayerNative.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ mw.EmbedPlayerNative = {
'error',
'emptied',
'stalled',
'play',
'pause',
'play',
'pause',
'loadedmetadata',
'loadeddata',
'waiting',
'playing',
'canplay',
'canplaythough',
'seeking',
'seeking',
'seeked',
'timeupdate',
'ended',
'ratechange',
'durationchange',
'volumechange'
],

// Native player supported feature set
supports: {
'playHead' : true,
Expand All @@ -64,9 +64,9 @@ mw.EmbedPlayerNative = {
'volumeControl' : true,
'overlays' : true
},

/**
* updates the supported features given the "type of player"
* Updates the supported features given the "type of player"
*/
updateFeatureSupport: function(){
// iWhatever devices appear to have a broken
Expand Down Expand Up @@ -181,14 +181,15 @@ mw.EmbedPlayerNative = {
return ;
}
$j.each( _this.nativeEvents, function( inx, eventName ){
$j( vid ).bind( eventName , function(){
$j( vid ).bind( eventName , function(){
if( _this._propagateEvents ){
var argArray = $j.makeArray( arguments );
// Check if there is local handler:
if( _this['on' + eventName ] ){
_this['on' + eventName ].apply( _this, arguments );
_this['on' + eventName ].apply( _this, argArray);
} else {
// no local handler directly propagate the event to the abstract object:
$j( _this ).trigger( eventName, arguments )
// No local handler directly propagate the event to the abstract object:
$j( _this ).trigger( eventName, argArray )
}
}
})
Expand All @@ -202,7 +203,7 @@ mw.EmbedPlayerNative = {

// Update the bufferedPercent
if( vid && vid.buffered && vid.buffered.end && vid.duration ) {
this.bufferedPercent = (vid.buffered.end(0) / vid.duration);
this.bufferedPercent = ( vid.buffered.end(0) / vid.duration );
}
_this.parent_monitor();
},
Expand Down Expand Up @@ -560,7 +561,9 @@ mw.EmbedPlayerNative = {
* Note: this way of updating buffer was only supported in firefox 3.x and
* not supported in firefox 4.x
*/
onprogress: function( e ) {
onprogress: function( event ) {
var e = event.originalEvent;
//mw.log("onprogress: e:" + e + ' ' + e.loaded + ' && ' + e.total );
if( e.loaded && e.total ) {
this.bufferedPercent = e.loaded / e.total;
this.progressEventData = e.loaded;
Expand Down
12 changes: 5 additions & 7 deletions modules/EmbedPlayer/skins/mw.PlayerControlBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ mw.PlayerControlBuilder.prototype = {
*/
addControlComponents: function( ) {
var _this = this;
mw.log( 'PlayerControlsBuilder:: addControlComponents' );

// Set up local pointer to the embedPlayer
var embedPlayer = this.embedPlayer;
Expand All @@ -148,10 +147,8 @@ mw.PlayerControlBuilder.prototype = {
var $controlBar = embedPlayer.$interface.find( '.control-bar' );

this.available_width = embedPlayer.getPlayerWidth();

// Make pointer to the embedPlayer
this.embedPlayer = embedPlayer;


mw.log( 'PlayerControlsBuilder:: addControlComponents into:' + this.available_width );
// Build the supportedComponets list
this.supportedComponets = $j.extend( this.supportedComponets, embedPlayer.supports );

Expand Down Expand Up @@ -254,7 +251,7 @@ mw.PlayerControlBuilder.prototype = {
*/
getInterfaceSizeTextCss: function( size ) {
// Some arbitrary scale relative to window size ( 400px wide is text size 105% )
var textSize = size.width / 3.8;
var textSize = size.width / 5;
if( textSize < 95 ) textSize = 95;
if( textSize > 200 ) textSize = 200;
//mw.log(' win size is: ' + $j( window ).width() + ' ts: ' + textSize );
Expand Down Expand Up @@ -796,7 +793,8 @@ mw.PlayerControlBuilder.prototype = {
'id' : 'ffwarn_' + embedPlayer.id,
'type' : "checkbox",
'name' : 'ffwarn_' + embedPlayer.id
}).click( function() {
})
.click( function() {
mw.log("WarningBindinng:: set " + preferenceId + ' to hidewarning ' );
// Set up a cookie for 30 days:
$j.cookie( preferenceId, 'hidewarning', { expires: 30 } );
Expand Down
14 changes: 6 additions & 8 deletions modules/KalturaSupport/mw.KAds.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ mw.KAds.prototype = {
}
});
} else {
// need to add support for mw.addToPlayerTimeline for non VAST ads^
//@@TODO need to add support for mw.addToPlayerTimeline for non VAST ads^
}
}
})
Expand All @@ -73,16 +73,14 @@ mw.KAds.prototype = {
},
getAdDisplayConf: function( adUrl, callback ){
var _this = this;
// We use a xml proxy ( passing on the clients ip for geo lookup )
// since the ad server is almost never on the same domain as the api.
// @@todo also we should explore html5 based cross domain request to avoid the proxy
var proxyUrl = mw.getConfig( 'Kaltura.XmlProxyUrl' );
if( !proxyUrl){
mw.log("Error: mw.KAds : missing kaltura proxy url ( can't load ad ) ");
return;
return ;
}
// In theory if on the same server we don't need to proxy
// ( but ad servers are almost always on a different server )
// @@todo also we should explore html5 based cross domain request
// if the servers set the proper access permissions
// ( because cookies won't work well with the proxy )
$j.getJSON( proxyUrl + '?url=' + encodeURIComponent( adUrl ) + '&callback=?', function( result ){
var adDisplayConf = {};
if( result['http_code'] == 'ERROR' || result['http_code'] == 0 ){
Expand Down Expand Up @@ -142,7 +140,7 @@ mw.KAds.prototype = {
if( ! currentSeq.bindEvents ){
currentSeq.bindEvents = [];
}
currentSeq.bindEvents.push( function( embedPlayer ){
currentSeq.bindEvents.push( function( embedPlayer ){
_this.bindVastEvent(embedPlayer, $j(tracking).attr('event'), $j(tracking).text() );
});
});
Expand Down
Loading

0 comments on commit 5b5f308

Please sign in to comment.