Skip to content

Commit

Permalink
updated timed media example for plyMedia
Browse files Browse the repository at this point in the history
git-svn-id: http://www.kaltura.org/kalorg/html5video/trunk/mwEmbed@1321 b58a29cf-3064-46da-94c6-1c29cc75c8e5
  • Loading branch information
KalturaGitBot committed Dec 13, 2010
1 parent e5fe88b commit 0c922ae
Show file tree
Hide file tree
Showing 21 changed files with 158 additions and 119 deletions.
1 change: 1 addition & 0 deletions cache.ks.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M2JiN2MzODJmM2MzMDU0ZmU5MTRmZGUxZDIwNDZjY2Q0Y2QxMDhhM3wyNDMzNDI7MjQzMzQyOzEyOTIzMzc0OTc7MDsxMjkyMjUxMDk3LjAxNzM7MDt2aWV3Oio7
1 change: 1 addition & 0 deletions includes/cache/192572.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ZmE3NzE3ZWMxNDY3ZGQ0MTgxOWZjNDVlNDVhNzg0YzQwYjUxMzFhZHwxOTI1NzI7MTkyNTcyOzEyOTIzNDc5NTU7MDsxMjkyMjYxNTU1LjY5Mzk7MDt2aWV3Oio7
1 change: 1 addition & 0 deletions loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ var mwEnabledModuleList = [
'MiroSubs',
'PlayerThemer',
'KalturaSupport',
'Plymedia',
'KalturaAdSupport'
];

Expand Down
26 changes: 4 additions & 22 deletions modules/EmbedPlayer/mw.EmbedPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2439,23 +2439,8 @@ mw.EmbedPlayer.prototype = {
addPlayBtnLarge:function(){
var _this = this;
$j( '#' + _this.pid ).siblings('.play-btn-large').remove();
$j( '#' + _this.pid ).after(
$j('<div />')
.css({
'position' : 'relative',
'top' : -1 * ( .5 * _this.getHeight() ) - 52,
'left' : ( .5 * _this.getWidth() ) - 75
})
.attr( {
'title' : gM( 'mwe-embedplayer-play_clip' ),
'class' : "play-btn-large"
} )
.click( function() {
$j( this ).hide();
_this.play();
// no need to hide the play button since android plays
// fullscreen
} )
this.$interface.append(
this.controlBuilder.getComponent('playButtonLarge')
)
},
/**
Expand Down Expand Up @@ -2740,6 +2725,7 @@ mw.EmbedPlayer.prototype = {
*/
pause: function( event ) {
var _this = this;
mw.log( "EmbedPlayer:: pause: " + this._propagateEvents );
// Trigger the pause event if not already paused and using native
// controls:
if( this.paused === false ){
Expand Down Expand Up @@ -2830,11 +2816,7 @@ mw.EmbedPlayer.prototype = {
this.updatePlayHead( 0 );

// Bind play-btn-large play
this.$interface.find( '.play-btn-large' )
.unbind( 'click' )
.click( function() {
_this.play();
} );
this.addPlayBtnLarge();
}
},

Expand Down
2 changes: 1 addition & 1 deletion modules/EmbedPlayer/mw.EmbedPlayerKplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ mw.EmbedPlayerKplayer = {
$j(_this).bind('openFullScreen', function() {
_this.postEmbedJS();
});
$j(_this).bind('onCloseFullScreen', function() {
$j(_this).bind('closeFullScreen', function() {
_this.postEmbedJS();
})

Expand Down
8 changes: 4 additions & 4 deletions modules/EmbedPlayer/skins/mw.PlayerControlBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ mw.PlayerControlBuilder.prototype = {
toggleFullscreen: function() {
if( this.fullscreenMode ){
this.restoreWindowPlayer();
$j( this.embedPlayer ).trigger( 'onCloseFullScreen' );
$j( this.embedPlayer ).trigger( 'closeFullScreen' );
}else{
this.doFullScreenPlayer();
$j( this.embedPlayer ).trigger( 'openFullScreen' );
Expand Down Expand Up @@ -501,8 +501,8 @@ mw.PlayerControlBuilder.prototype = {
'position' : _this.windowPositionStyle,
'z-index' : _this.windowZindex,
'overlow' : 'visible',
'top' : null,
'left' : null
'top' : 0,
'left' : 0
} );

// Restore absolute layout of parents:
Expand Down Expand Up @@ -1571,7 +1571,7 @@ mw.PlayerControlBuilder.prototype = {
} )
// Add play hook:
.click( function() {
ctrlObj.embedPlayer.play();
ctrlObj.embedPlayer.play();
return false; // Event Stop Propagation
} );
}
Expand Down
12 changes: 7 additions & 5 deletions modules/EmbedPlayer/tests/Player_Sources.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
<body>


<video poster="http://cdn.kaltura.org/apis/html5lib/kplayer-examples/media/elephants-dream.jpg"
duration="10:53" preload="auto">
<source type="video/webm" src="http://cdn.kaltura.org/apis/html5lib/kplayer-examples/media/elephants-dream_400p.webm" />
<source type="video/h264" src="http://cdn.kaltura.org/apis/html5lib/kplayer-examples/media/elephants-dream_iphone.m4v" />
<source type="video/ogg" src="http://cdn.kaltura.org/apis/html5lib/kplayer-examples/media/elephants-dream_400p.ogv" />
<video id="vid1" width="480" height="267"
poster="http://cdn.kaltura.org/apis/html5lib/kplayer-examples/media/bbb480.jpg"
durationHint="33"
controls>
<source src="http://cdn.kaltura.org/apis/html5lib/kplayer-examples/media/bbb_trailer_iphone.m4v">
<source src="http://cdn.kaltura.org/apis/html5lib/kplayer-examples/media/bbb400p.ogv" />
</video>



</body>
</html>
4 changes: 3 additions & 1 deletion modules/EmbedPlayer/tests/Player_Themable.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
<!--
<script type="text/javascript" src="../../../ResourceLoader.php?debug=true&class=mwEmbed"></script>
-->

<script type="text/javascript" src="../../../mwEmbed.js?debug=true"></script>

</head>
<script type="text/javascript">
//Show the controls ( this is a theme demo )
// Show the controls ( this is a theme demo )
mw.setConfig( 'EmbedPlayer.OverlayControls', false );
</script>
<body>
Expand Down
2 changes: 1 addition & 1 deletion modules/KalturaAdSupport/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

// Check for new Embed Player events:
$j( mw ).bind( 'newEmbedPlayerEvent', function( event, embedPlayer ){

// Check for KalturaSupport uiConf
$j( embedPlayer ).bind( 'KalturaSupport.checkUiConf', function( event, $uiConf, callback ){

Expand Down
53 changes: 53 additions & 0 deletions modules/KalturaAdSupport/tests/Ad_Events_test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<html>
<head>
<meta name="generator" content=
"HTML Tidy for Windows (vers 14 February 2006), see www.w3.org">

<title></title>
</head>
<body>
<h1>
HTML5 ad events test
</h1>
<video persistentNativePlayer="true" id="vid1" width="480" height="267"
poster="http://cdn.kaltura.org/apis/html5lib/kplayer-examples/media/bbb480.jpg"
durationHint="33"
controls>
<source src="http://cdn.kaltura.org/apis/html5lib/kplayer-examples/media/bbb_trailer_iphone.m4v" />
<source src="http://cdn.kaltura.org/apis/html5lib/kplayer-examples/media/bbb400p.ogv" />
</video>
<br>Prerool: <input id="prerool" type="text" size="40" value="http://cdn.kaltura.com/p/243342/sp/24334200/flvclipper/entry_id/1_v1z55w0b/flavor/1_jeqsr39h/a.mp4?novar=0"></input></br>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script src="../../../mwEmbedLoader.js?debug=true" type="text/javascript"></script>
<script type="text/javascript">
mw.setConfig( 'Kaltura.IframeRewrite', true );
mw.setConfig( 'EmbedPlayer.EnableIpadHTMLControls', true);
mw.setConfig( 'EmbedPlayer.OverlayControls', false);
//mw.setConfig( 'EmbedPlayer.EnableIframeApi', true );
mw.ready(function(){
var embedPlayer = $j('#vid1').get(0);

//$j( embedPlayer ).bind(

$j( embedPlayer ).bind( 'openFullScreen', function(){
embedPlayer.$interface.append(
'<span class="fullscreenOverlay" style="position:absolute;top:10px;' +
'left:10px;color:red">fullscreen overlay</span>'
);
});
$j( embedPlayer ).bind( 'closeFullScreen', function(){
embedPlayer.$interface.find('.fullscreenOverlay').fadeOut('fast');
});

$j( embedPlayer ).bind( 'monitorEvent', function(){
if( embedPlayer.$interface.find('.timeOverlay').length == 0 ){
embedPlayer.$interface.append(
'<span class="timeOverlay" style="position:absolute;top:200px;' +
'left:10px;color:red"></span>' );
}

});
});
</script>
</body>
</html>
74 changes: 46 additions & 28 deletions modules/KalturaSupport/kalturaIframe.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,11 @@ private function parseRequest(){
}
}

// Load the kaltura library and grab the most compatible flavour
// Load the kaltura library and grab the most compatible flavor
private function getFlavorSources(){

include_once( dirname( __FILE__ ) . '/kaltura_client_v3/KalturaClient.php' );
$userId = "username";
$secret = "dc8a616702359ec844b18143667d130a";
$adminsecret = "509d0007e53ecc4b05401ec12b15ed2f";
// Partner id is widget_id but strip the first character
$partnerId = substr( $this->playerAttributes['wid'], 1 );
$conf = new KalturaConfiguration( $partnerId );
$client = new KalturaClient( $conf );

$session = $client->session->startWidgetSession( $this->playerAttributes['wid'] );
$client->setKS($session->ks);
$client = $this->getClient();

// @@todo support MultiRequest
$client->startMultiRequest();
Expand All @@ -104,8 +95,9 @@ private function getFlavorSources(){
$client->addParam( $kparams, "entryId", $this->playerAttributes['entry_id'] );
$client->queueServiceActionCall( "flavorAsset", "getByEntryId", $kparams ); // sources


$client->addParam( $kparams, "contextDataParams", array( 'referer' => $_SERVER['HTTP_REFERER'] ) );
$client->queueServiceActionCall( "baseEntry", "getContextData", $kparams ); // access control
$client->queueServiceActionCall( "baseEntry", "getContextData", $kparams ); // access control

$client->addParam( $kparams, "entryId", $this->playerAttributes['entry_id'] );
$client->queueServiceActionCall( "baseEntry", "get", $kparams ); // Entry Meta
Expand All @@ -114,31 +106,29 @@ private function getFlavorSources(){
$client->addParam( $kparams, "id", $this->playerAttributes['uiconf_id'] );
$client->queueServiceActionCall( "uiconf", "get", $kparams );
}


$resultObject = $client->doQueue();
$this->resultObj = $resultObject;
$client->throwExceptionIfError($resultObject);
$this->resultObj = $client->doQueue();
$client->throwExceptionIfError($this->resultObj);
} catch( Exception $e ){
$this->error = "Error getting sources from server, something maybe broken or server is under high load. Please try again.";
return array();
}
// debugging

/*
echo "<style>body { overflow:scroll; position: static; }</style><pre>";
print_r($resultObject);

/*echo "<style>body { overflow:scroll; position: static; }</style><pre>";
print_r($this->resultObj);
exit();
*/

if( $this->checkAccessControl($resultObject[1]) ) {

if( $this->checkAccessControl($this->resultObj[1]) ) {

// add any web sources
$sources = array();
foreach( $resultObject[0] as $KalturaFlavorAsset ){
foreach( $this->resultObj[0] as $KalturaFlavorAsset ){

$assetUrl = KALTURA_CDN_URL .'/p/' . $partnerId . '/sp/' .
$partnerId . '00/flvclipper/entry_id/' .
$assetUrl = KALTURA_CDN_URL .'/p/' . $this->getPartnerId() . '/sp/' .
$this->getPartnerId() . '00/flvclipper/entry_id/' .
$this->playerAttributes['entry_id'] . '/flavor/' . $KalturaFlavorAsset->id;
if( strpos( $KalturaFlavorAsset->tags, 'iphone' ) !== false ){
$sources['iphone'] = array(
Expand Down Expand Up @@ -177,12 +167,41 @@ private function getFlavorSources(){
return array();
}
}

function getClient(){
global $mwEmbedRoot;

$cacheDir = $mwEmbedRoot . '/includes/cache';

$cacheFile = $cacheDir . '/' . $this->getPartnerId() . ".txt";
$cacheLife = 900; //cache for 15 min


$conf = new KalturaConfiguration( $this->getPartnerId() );
$client = new KalturaClient( $conf );

// Check modify time on cached php file
$filemtime = @filemtime($cacheFile); // returns FALSE if file does not exist
if ( !$filemtime || filesize( $cacheFile ) === 0 || ( time() - $filemtime >= $cacheLife ) ){
$session = $client->session->startWidgetSession( $this->playerAttributes['wid'] );
$sessionKS = $session->ks;
file_put_contents( $cacheFile, $sessionKS );
}else{
$sessionKS = file_get_contents( $cacheFile );
}
// set the kaltura ks and return the client
$client->setKS($sessionKS );

return $client;
}
function getPartnerId(){
// Partner id is widget_id but strip the first character
return substr( $this->playerAttributes['wid'], 1 );
}
/**
* Set the player data array
*/
function getPlayerData() {

$playerData = array(
'accessControl' => $this->resultObj[1],
'flavors' => $this->resultObj[0],
Expand Down Expand Up @@ -269,9 +288,8 @@ private function getVideoHTML( ){
'uiconf_id' => 'kuiconfid',
'wid' => 'kwidgetid'
);
$partnerId = substr( $this->playerAttributes['wid'], 1 );
$posterUrl = KALTURA_CDN_URL . '/p/' . $partnerId . '/sp/' .
$partnerId . '00/thumbnail/' .
$posterUrl = KALTURA_CDN_URL . '/p/' . $this->getPartnerId() . '/sp/' .
$this->getPartnerId() . '00/thumbnail/' .
'entry_id/' . $this->playerAttributes['entry_id'] .
'/height/480';
$sources = $this->getFlavorSources();
Expand Down
2 changes: 1 addition & 1 deletion modules/KalturaSupport/mw.KAnalytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ mw.KAnalytics.prototype = {
// When the close fullscreen button is pressed.
// ( presently does not register iphone / ipad until it has js bindings
// )
b( 'onCloseFullScreen', 'CLOSE_FULL_SCREEN' );
b( 'closeFullScreen', 'CLOSE_FULL_SCREEN' );

// When the user plays (after the ondone event was fired )
b( 'replayEvent', 'REPLAY' );
Expand Down
29 changes: 2 additions & 27 deletions modules/KalturaSupport/mw.KWidgetSupport.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ mw.KWidgetSupport.prototype = {
mw.addKAnalytics( embedPlayer, _this.kClient );
}


// Check for uiConf
if( playerData.uiConf ){
if( playerData.uiConf ){

var $uiConf = $j( playerData.uiConf );
// Trigger the check kaltura uiConf event
$j( embedPlayer ).triggerQueueCallback( 'KalturaSupport.checkUiConf', $uiConf, function(){
Expand Down Expand Up @@ -196,31 +196,6 @@ mw.KWidgetSupport.prototype = {
}
return false;
},
/**
* Adds the bindings for the uiConf
*/
checkUiConf: function( embedPlayer, callback ){
var _this = this;

this.loadUiConfData( embedPlayer, function( uiConf ) {
if( !uiConf ){
mw.log("Could not get uiConf for emmbed:" + embedPlayer.kwidgetid );
callback();
return;
}

//mw.log( uiConf.confFile );
//mw.log("\n\n" );
//mw.log( uiConf.confFileFeatures );

// Check for the bumper plugin ( note we should probably have a separate uiConf js class )
var $uiConf = $j( uiConf.confFile );

// Trigger the check kaltura uiConf event
$j( embedPlayer ).triggerQueueCallback( 'KalturaSupport.checkUiConf', $uiConf, callback);

})
},
/**
* Convert flavorData to embedPlayer sources
*
Expand Down
2 changes: 1 addition & 1 deletion modules/PlayerThemer/mw.PlayerThemer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ mw.PlayerThemer.prototype = {
// Fade away the button
$j(this).fadeOut( 'fast' );
_this.getEmbedPlayer().play();
})
})
},
'customShow' : function( _this ){
_this.$getCompoent('centerPlayButton').fadeIn('slow');
Expand Down
Loading

0 comments on commit 0c922ae

Please sign in to comment.