Skip to content

Commit

Permalink
got first test passing
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Dale committed Oct 5, 2012
1 parent 1918aa5 commit fc46d95
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 47 deletions.
1 change: 1 addition & 0 deletions players/kaltura/popcorn.kaltura.html
Expand Up @@ -216,6 +216,7 @@ <h1>HTML5 Video Events and API in Kaltura</h1>
<div id="video"></div>

<div id='buttons'>
<button onclick="document._video.requestFullScreen()">requestFullScreen()</button>
<button onclick="document._video.load()">load()</button>
<button onclick="document._video.play()">play()</button>
<button onclick="document._video.pause()">pause()</button><br>
Expand Down
9 changes: 6 additions & 3 deletions players/kaltura/popcorn.kaltura.unit.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Vimeo Player Unit Test Suite</title>
<title>Kaltura Player Unit Test Suite</title>
<link rel="stylesheet" href="../../test/qunit/qunit.css" type="text/css" media="screen">
<script src="../../test/qunit/qunit.js"></script>
<script src="../../test/jquery.js"></script>
Expand All @@ -13,8 +13,11 @@
<script src="../../popcorn.js"></script>
<script src="../../modules/player/popcorn.player.js"></script>

<script src="popcorn.vimeo.unit.js"></script>
<script src="popcorn.vimeo.js"></script>
<script src="popcorn.kaltura.unit.js"></script>
<script src="../../wrappers/common/popcorn._MediaElementProto.js"></script>
<script src="../../wrappers/kaltura/popcorn.HTMLKalturaVideoElement.js"></script>
<script src="popcorn.kaltura.js"></script>

<script src="../../test/inject.js"></script>

</head>
Expand Down
50 changes: 15 additions & 35 deletions players/kaltura/popcorn.kaltura.unit.js
@@ -1,37 +1,17 @@
asyncTest( "Options Check", function() {

expect( 7 );
var varz = {
title: 0,
byline: 0,
portrait:0,
autoplay:1,
loop:1,
color: "FFAADD",
fullscreen: 0
},
p2 = Popcorn.vimeo( "#player_1", "http://vimeo.com/11336811", varz );
expect( 1 );
var p2 = Popcorn.kaltura( "#player_1", "http://www.kaltura.com/index.php/kwidget/cache_st/1292436446/wid/_243342/uiconf_id/2877502/entry_id/0_uka1msg4" )

p2.listen( "loadeddata", function() {
var flashvars = $( 'param[name="flashvars"]' ).attr( "value" );

var splitvars = flashvars.split( "&" );

for ( var i = 0, len = splitvars.length; i < len; i++ ) {
var item = splitvars[ i ].split( "=" );
if ( varz.hasOwnProperty( item[ 0 ] ) ) {
equal( varz[ item[ 0 ] ], item[ 1 ], item[ 0 ] + " is the expected value" );
}
}

ok( true, "loadeddata fired ");
start();
});

});

asyncTest( "Update Timer", function() {

var p2 = Popcorn.vimeo( "#player_1", "http://player.vimeo.com/video/11336811" ),
var p2 = Popcorn.kaltura( "#player_1", "http://www.kaltura.com/index.php/kwidget/cache_st/1292436446/wid/_243342/uiconf_id/2877502/entry_id/0_uka1msg4" ),
expects = 17,
count = 0,
execCount = 0,
Expand Down Expand Up @@ -226,7 +206,7 @@ asyncTest( "Update Timer", function() {

asyncTest( "Plugin Factory", function() {

var popped = Popcorn.vimeo( "#player_1", "http://player.vimeo.com/video/11336811" ),
var popped = Popcorn.kaltura( "#player_1", "http://www.kaltura.com/index.php/kwidget/cache_st/1292436446/wid/_243342/uiconf_id/2877502/entry_id/0_uka1msg4" ),
methods = "load play pause currentTime mute volume roundTime exec removePlugin",

// 15*2+2+2. executor/complicator each do 15
Expand Down Expand Up @@ -342,7 +322,7 @@ asyncTest( "Plugin Factory", function() {

});

asyncTest( "Popcorn vimeo Plugin Url and Duration Tests", function() {
asyncTest( "Popcorn kaltura Plugin Url and Duration Tests", function() {
function plus() {
if ( ++count == expects ) {
popcorn.pause();
Expand All @@ -352,7 +332,7 @@ asyncTest( "Popcorn vimeo Plugin Url and Duration Tests", function() {

var count = 0,
expects = 3,
popcorn = Popcorn.vimeo( "#player_1", "http://player.vimeo.com/video/11336811" );
popcorn = Popcorn.kaltura( "#player_1", "http://www.kaltura.com/index.php/kwidget/cache_st/1292436446/wid/_243342/uiconf_id/2877502/entry_id/0_uka1msg4" );

expect( expects );

Expand All @@ -372,16 +352,16 @@ asyncTest( "Popcorn vimeo Plugin Url and Duration Tests", function() {
popcorn.play();
});

asyncTest( "Popcorn vimeo Plugin Url Regex Test", function() {
asyncTest( "Popcorn kaltura Plugin Url Regex Test", function() {

var urlTests = [
{ name: "standard",
url: "http://player.vimeo.com/video/11336811",
expected: "http://player.vimeo.com/video/11336811"
url: "http://www.kaltura.com/index.php/kwidget/cache_st/1292436446/wid/_243342/uiconf_id/2877502/entry_id/0_uka1msg4",
expected: "http://www.kaltura.com/index.php/kwidget/cache_st/1292436446/wid/_243342/uiconf_id/2877502/entry_id/0_uka1msg4"
},
{ name: "short url",
url: "http://vimeo.com/11336811",
expected: "http://vimeo.com/11336811"
url: "http://www.kaltura.com/index.php/kwidget/cache_st/1292436446/wid/_243342/uiconf_id/2877502/entry_id/0_uka1msg4",
expected: "http://www.kaltura.com/index.php/kwidget/cache_st/1292436446/wid/_243342/uiconf_id/2877502/entry_id/0_uka1msg4"
}
];

Expand All @@ -393,7 +373,7 @@ asyncTest( "Popcorn vimeo Plugin Url Regex Test", function() {
Popcorn.forEach( urlTests, function( values, key ) {

var urlTest = urlTests[ key ],
popcorn = Popcorn.vimeo( "#player_2", urlTest.url );
popcorn = Popcorn.kaltura( "#player_2", urlTest.url );

popcorn.listen( "loadeddata", function() {

Expand All @@ -410,7 +390,7 @@ asyncTest( "Popcorn vimeo Plugin Url Regex Test", function() {
});
});

asyncTest( "Popcorn Vimeo Plugin offsetHeight && offsetWidth Test", function() {
asyncTest( "Popcorn kaltura Plugin offsetHeight && offsetWidth Test", function() {

var popped,
elem,
Expand All @@ -424,7 +404,7 @@ asyncTest( "Popcorn Vimeo Plugin offsetHeight && offsetWidth Test", function() {
start();
}
}
popped = Popcorn.vimeo( "#player_3", "http://player.vimeo.com/video/11336811" );
popped = Popcorn.kaltura( "#player_3", "http://www.kaltura.com/index.php/kwidget/cache_st/1292436446/wid/_243342/uiconf_id/2877502/entry_id/0_uka1msg4" );

popped.listen( "loadeddata", function() {
elem = document.querySelector( "div#player_3 object" );
Expand Down
31 changes: 22 additions & 9 deletions wrappers/kaltura/popcorn.HTMLKalturaVideoElement.js
Expand Up @@ -10,7 +10,7 @@
var EMPTY_STRING = '';

// Some default sizes:
MIN_WIDTH = 300, MIN_HEIGHT = 200;
MIN_WIDTH = 240, MIN_HEIGHT = 180;

function HTMLKalturaVideoElement(id, options) {
var self = this, parent = typeof id === "string" ? Popcorn.dom.find(id)
Expand Down Expand Up @@ -65,7 +65,8 @@
*/
function setKalturaConfig(){
// By default lead with html5
if( typeof options.leadWithHTML5 == 'undefined' || options.leadWithHTML5 === true ){
if( typeof self._options.leadWithHTML5 == 'undefined' || self._options.leadWithHTML5 === true ){
mw.setConfig( 'EmbedPlayer.NativeControls', true);
mw.setConfig( 'KalturaSupport.LeadWithHTML5', true);
}
}
Expand All @@ -90,12 +91,15 @@
// Load the kWidget library ( if not already set )
if (!window.kWidget) {
// replace in an embedIframeJs url if kWidgetUrl is not set
var src = options.kWidgetUrl
||
aSrc.replace(
'index.php\/kwidget\/cache_st\/[^\]*/wid/',
'p/').replace('uiconf_id\/',
'embedIframeJs/uiconf_id/');
var src = self._options.kWidgetUrl
||
// 1.7 is not on production yet once it is; substitute in the regex
'http://html5video.org/kaltura-player/mwEmbedLoader.php'
//aSrc.replace(
// /index.php\/kwidget\/cache_st\/[^/]*\/wid\/_([^/]*)\/(uiconf_id\/[^/]*)\/.*/,
// 'p/$1/sp/$100/$2/partner_id/$1').replace('uiconf_id\/',
// 'embedIframeJs/uiconf_id/');


Popcorn.getScript(
src,
Expand All @@ -117,7 +121,6 @@
}
// kWidget has been loaded set config
setKalturaConfig();


// Get embed settings:
var embedSettings = kWidget.getEmbedSettings(aSrc,
Expand Down Expand Up @@ -150,7 +153,9 @@

// setup listener events: ( if the player is HTML5 ) just directly map:
if( kdp.evaluate('{isHTML5}') ){

var vid =window.frames[ playerUID + '_ifp' ].document.getElementById( 'pid_' + playerUID );

["loadstart", "progress", "suspend", "abort", "error", "emptied",
"stalled", "loadedmetadata", "loadeddata", "canplay", "canplaythrough",
"waiting", "seeking", "seeked", "ended", "durationchange", "timeupdate",
Expand Down Expand Up @@ -181,6 +186,8 @@

// Once media is ready to be played trigger associated events
kdp.kBind('mediaReady', function() {
// if we have not already done so dispatch "loadeddata"
self.dispatchEvent( "loadeddata" );
playerReady = true;
// run any playerReadyCallbacks
while( playerReadyCallbacks.length ){
Expand Down Expand Up @@ -230,6 +237,12 @@
kdp.sendNotification('doPause');
}
}
self.requestFullScreen = function(){
if( kdp ){
var embedPlayer = window.frames[ playerUID + '_ifp' ].document.getElementById( playerUID );
embedPlayer.fullscreen();
}
}

// Setup a player callback for defining all the mapped properties:
addPlayerReadyCallback( function(){
Expand Down

0 comments on commit fc46d95

Please sign in to comment.