diff --git ooyala.module ooyala.module
index 0ea89d9..271dd7a 100755
--- ooyala.module
+++ ooyala.module
@@ -111,9 +111,7 @@ function ooyala_theme() {
     'ooyala_player' => array(
       'arguments' => array(
         'embedcode' => NULL,
-        'player_id' => NULL,
-        'width' => NULL,
-        'height' => NULL,
+        'params' => NULL,
       ),
     ),
     'ooyala_thickbox_player' => array(
@@ -581,31 +579,50 @@ function ooyala_message($message, $variables = array(), $type = 'status') {
 
 /**
  * A public API function used to output an Ooyala player.
- */
-function ooyala_player($embedcode, $player_id = NULL, $width = NULL, $height = NULL, $autoplay = FALSE) {
-  return theme('ooyala_player', $embedcode, $player_id, $width, $height, $autoplay);
+ *
+ * This function should be used to output a video player instead of calling
+ * theme('ooyala_player') to ensure that player.js $_GET parameters are correct.
+ *
+ * @param $embedcode
+ *   Embedcode of the video to display.
+ * @param $params
+ *   An associative array of paramaters that will be passed as $_GET variables
+ *   to the Ooyala player.js file.
+ *
+ * @return
+ *   An HTML <script> tag pointing to the Ooyala player.js file which will
+ *   display the video player using Ooyala's API.
+ */
+function ooyala_player($embedcode, $params = array()) {
+  // Setup some default paramaters.
+  $params += array(
+    'embedCode' => $embedcode,
+    'height' => variable_get('ooyala_video_height', 300),
+    'playerId' => 'ooyala_player',
+    'width' => variable_get('ooyala_video_width', 400),
+  );
+
+  // The callback paramter determines the name of an optional javascript
+  // function that should recieve notification of Player API events. We do not
+  // allow this to be modified to ensure that multiple modules can play together
+  // nicely. See ooyala_player.js for additional information about resonding to
+  // Player API events.
+  $params['callback'] = 'receiveOoyalaEvent';
+
+  return theme('ooyala_player', $embedcode, $params);
 }
 
 /**
  * Theme function to output an Ooyala video player.
  */
-function theme_ooyala_player($embedcode, $player_id = NULL, $width = NULL, $height = NULL, $autoplay = FALSE) {
+function theme_ooyala_player($embedcode, $params = array()) {
   static $js_added;
 
   if (!isset($js_added)) {
     drupal_add_js(drupal_get_path('module', 'ooyala') . '/ooyala_player.js');
   }
 
-  if (empty($width)) {
-    $width = variable_get('ooyala_video_width', 400);
-  }
-  if (empty($height)) {
-    $height = variable_get('ooyala_video_height', 300);
-  }
-
-  $player_id = isset($player_id) ? $player_id : 'ooyala_player';
-
-  return sprintf('<script src="http://www.ooyala.com/player.js?playerId=' . $player_id . '&callback=receiveOoyalaEvent&autoplay=%d&width=%d&height=%d&embedCode=%s"></script>', $autoplay, $width, $height, $embedcode );
+  return '<script src="http://www.ooyala.com/player.js?' . drupal_query_string_encode($params) . '"></script>';
 }
 
 /**
@@ -710,18 +727,19 @@ function theme_ooyala_format($element) {
  */
 function theme_ooyala_formatter_ooyala_video($element) {
   $values = array();
+  $output = '';
   $item = $element;
-  foreach (element_children($element) as $key) {
-    unset($item[$key]);
-    $item['#item'] = $element[$key]['#item'];
+  foreach (element_children($element) as $delta) {
+    $item['#item'] = $element[$delta]['#item'];
     if ($item['#item']['safe']) {
-      $values[] = $item['#item']['safe'];
+      $params = array(
+        'playerId' => $item['#field_name'] . '_' .$delta . '_ooyala_player',
+      );
+      $output .= ooyala_player($item['#item']['safe'], $params);
     }
   }
 
-  $player_id = $element['#field_name'] . '_ooyala_player';
-
-  return !empty($values) ? theme('ooyala_player', implode($values)) : '';
+  return !empty($output) ? $output : '';
 }
 
 /**
@@ -842,7 +860,14 @@ function theme_ooyala_video_status($status = NULL, $label = TRUE) {
  * Preprocess function for ooyala-thickbox-player.tpl.php.
  */
 function template_preprocess_ooyala_thickbox_player(&$variables) {
-  $variables['playercode'] = theme('ooyala_player', $variables['embedcode'], $variables['width'], $variables['height'], variable_get('ooyala_thickbox_autoplay',true) );
+  $params = array(
+    'autoplay' => variable_get('ooyala_thickbox_autoplay', TRUE),
+    'height' => isset($variables['height']) ? $variables['height'] : NULL,
+    'playerId' => 'ooyala_player_thickbox',
+    'width' => isset($variables['width']) ? $variables['width'] : NULL,
+  );
+
+  $variables['playercode'] = ooyala_player($variables['embedcode'], $params);
 }
 
 /**
@@ -939,7 +964,11 @@ function _ooyala_check_directory($path) {
  */
 
 function ooyala_thickbox_player_page($embedcode) {
-  print ooyala_player($embedcode, 'ooyala_thickbox_player', NULL, NULL, variable_get('ooyala_thickbox_autoplay', TRUE));
+  $params = array(
+    'autoplay' => variable_get('ooyala_thickbox_autoplay', TRUE),
+    'playerId' => 'ooyala_thickbox_player',
+  );
+  print ooyala_player($embedcode, $params);
 }
 
 /**
