--- providers/soundcloud.inc	2011-04-27 22:19:10.000000000 -0600
+++ providers/soundcloudNEW.inc	2011-04-27 22:02:54.000000000 -0600
@@ -72,9 +72,9 @@ function emaudio_soundcloud_extract($emb
  * The embedded flash displaying the SoundCloud audio.
  */
 function theme_emaudio_soundcloud_flash($item, $embed, $width, $height, $autoplay) {
-  // If the swf element is NULL, then we have an embed code instead of a URL; 
-  // return this directly.
-  if (is_null($item['data']['swf'])) {
+  // If embed code is between <object> tags, assume its embed code, not URL
+  // return the embed code directly.
+	if (preg_match('/^<object.*<\/object>.*/i', $item['embed'])) {
     return $item['embed'];
   }
 
@@ -83,14 +83,14 @@ function theme_emaudio_soundcloud_flash(
     if ($item['data']['emaudio_soundcloud_version'] >= 1) {
       $id = form_clean_id('soundcloud');
       $autoplay = $autoplay ? '&amp;auto_play=true' : '';
-      $output .= <<<SOUNDCLOUDEMBED
-        <object type="application/x-shockwave-flash" data="{$item['data']['swf']}$autoplay" width="$width" height="81" id="$id">
-          <param name="movie" value="{$item['data']['swf']}" />
-          <param name="allowscriptaccess" value="always"></param>
-          <embed allowscriptaccess="always" height="81" src="{$item['data']['swf']}$autoplay" type="application/x-shockwave-flash" width="$width">
-          </embed>
-        </object>
-SOUNDCLOUDEMBED;
+      $swf = 'http://soundcloud.com/oembed?url=http://soundcloud.com/'.urldecode($item['data']['swf']);
+      $xml = drupal_http_request($swf);
+	  if(($xml->code) == 200) { // code 200 assumes successful query of the soundcloud servers
+		$xml = new SimpleXmlElement($xml->data);
+		$output = (string)$xml->html;
+	  } else { // any code but 200 we'll assume is an error
+		$output = 'SoundCloud server returned an ERROR: ' . $xml->code . ' ' . $xml->status_message;
+	  }
     }
   }
 
@@ -112,8 +112,9 @@ function emaudio_soundcloud_data($field,
     $patterns = array();
     $h1tags = preg_match('/(<link href="(.*)" rel="video_src" \/>)/i', $response->data, $patterns);
     $data['player'] = isset($patterns[2]) ? explode('&', $patterns[2]) : NULL;
-    $data['swf'] = isset($data['player'][0]) ? $data['player'][0] : NULL;
+  	$data['swf'] = $item['value'];
   }
+  
   return $data;
 }
 
