Server Side playlist

Server Side playlists are built on the server and are in the page before javascript or the player is invoked. This is best for cases where you need to optimize your playlists for search engine discoverability. A sample file getKalturaPlaylist.php is included that includes a single simple method for translating kaltura playlist api response into a ul list The on-page plugin handles binding all elements of your choosing.


Player with Default Entry



Playlist Title: longer playlist

Player includes on-page playlist binding

  1. kWidget.embed({
  2. 'targetId': 'kaltura_player',
  3. 'wid': '_243342',
  4. 'uiconf_id' : '12905712',
  5. 'entry_id' : '0_l1v5vzh3',
  6. 'readyCallback': function( playerId ){
  7. var kdp = $( '#' + playerId ).get(0);
  8. $('li.kaltura-video').click(function(){
  9. var entryId = $(this).find('a').attr('data-entryid');
  10. kdp.sendNotification('changeMedia', {'entryId': entryId } );
  11. })
  12. }
  13. });

Server side code to generate playlist

  1. <?php
  2. include_once dirname( __FILE__ ) . '/getKalturaPlaylist.php';
  3. $playlist = getKalturaPlaylist( '243342', '1_h92ak5el' );
  4.  
  5. ?>
  6. <ul class="thumbnails">
  7. <?php
  8. foreach( $playlist['playlist'] as $key => $entry ){
  9. $entry = (array)$entry;
  10. ?>
  11. <li itemscope itemtype="http://schema.org/VideoObject"
  12. class="kaltura-video span2">
  13. <meta itemprop="duration" content="<?php echo $entry['duration'] ?>"
  14. <meta itemprop="thumbnailURL" content="<?php echo $entry['thumbnailUrl'] ?>">
  15. <a data-entryid="<?php echo $entry['id'] ?>" href="#" class="thumbnail" title="<?php echo $entry['name'] ?>">
  16. alt="<?php echo htmlspecialchars( $entry['name'] )?>"
  17. style="width: 160px; max-height: 120px;"
  18. src="<?php echo $entry['thumbnailUrl'] ?>/width/160">
  19. </a>
  20. <span itemprop="description"><?php echo htmlspecialchars( $entry['name'] )?></span>
  21. </li>
  22. <?php
  23. }
  24. ?>
  25. </ul>

getKalturaPlaylist.php

  1. <?php
  2. // Include the kaltura php api, you can get your copy here:
  3. // http://www.kaltura.com/api_v3/testme/client-libs.php
  4. require_once( dirname( __FILE__ ) . '/../../../modules/KalturaSupport/Client/kaltura_client_v3/KalturaClient.php');
  5. /**
  6. * Takes in a :
  7. * $wid, string, The widget id
  8. * $playlistId, string, The playlist_id
  9. */
  10. function getKalturaPlaylist( $partnerId, $playlistId ){
  11. $config = new KalturaConfiguration($partnerId);
  12. $config->serviceUrl = 'http://www.kaltura.com/';
  13. $client = new KalturaClient($config);
  14. $client->startMultiRequest();
  15. // the session:
  16. $kparams = array();
  17. $client->addParam( $kparams, 'widgetId', '_' . $partnerId );
  18. $client->queueServiceActionCall( 'session', 'startWidgetSession', $kparams );
  19. // The playlist meta:
  20. $kparams = array();
  21. $client->addParam( $kparams, 'ks', '{1:result:ks}' );
  22. $client->addParam( $kparams, 'id', $playlistId );
  23. $client->queueServiceActionCall( 'playlist', 'get', $kparams );
  24. // The playlist entries:
  25. $client->queueServiceActionCall( 'playlist', 'execute', $kparams );
  26. $rawResultObject = $client->doQueue();
  27. return array(
  28. 'meta' => (array)$rawResultObject[1],
  29. 'playlist' => (array)$rawResultObject[2]
  30. );
  31. }
  32. ?>
html5 qunit | flash qunit