public:// urls being printed in source code I have a weird issue with a Drupal website I am working on. The site has an audio player, jplayer, that plays MP3 files. Some of the files do not play. The only difference I've found between the files that play and the ones that do not is that the files that do not play have a src in the form of public://audio/example.mp3. The ones that do play have a typical url of http://example.com/audio/example.mp3. Is there anything that I should investigate as to why some of the urls get printed out with a public:// url?

This is the source code that makes the jplayer work..

&lt;?php


/**
 * Implementation of theme_menu_tree().
 */
function wyep_menu_tree(&amp;$variables) {
  return '&lt;ul class="menu"&gt;' . $variables['tree'] . '&lt;/ul&gt;';
}


/**
 * Implementation of theme_file_link().
 */
function play_file_link($variables) {

  //watchdog('theme_file_link', '&lt;code&gt;&lt;pre&gt;' . print_r($variables, TRUE) . '&lt;/pre&gt;&lt;/code&gt;');

  global $base_path, $base_url;

  $file = $variables['file'];

  $file-&gt;url = str_replace('public:/', $base_url . '/' . variable_get('file_public_path', 'files'), $file-&gt;uri);


  switch ($file-&gt;filemime) {
case 'audio/mpeg':  
    return '&lt;script type="text/javascript"&gt;
              jQuery(document).ready(function(){
                jQuery("#jquery_jplayer_' . $file-&gt;fid . '").jPlayer({
                    ready: function (event) {
                        jQuery(this).jPlayer("setMedia", {
                            mp3:"/files/' . $file-&gt;filename . '"
                        });
                    },
                    cssSelectorAncestor: "#jp_container_' . $file-&gt;fid . '",
                    swfPath: "' . $base_url . '/sites/all/libraries/jplayer/Jplayer.swf",
                    supplied: "mp3",
                    wmode: "window"
                });
              });
            &lt;/script&gt;

                &lt;div id="jquery_jplayer_' . $file-&gt;fid . '" class="jp-jplayer"&gt;&lt;/div&gt;

                &lt;div id="jp_container_' . $file-&gt;fid . '" class="jp-audio"&gt;
                    &lt;div class="jp-type-single"&gt;
                        &lt;div class="jp-gui jp-interface"&gt;
                            &lt;ul class="jp-controls"&gt;
                                &lt;li&gt;&lt;a href="javascript:;" class="jp-play" tabindex="1"&gt;play&lt;/a&gt;&lt;/li&gt;
                                &lt;li&gt;&lt;a href="javascript:;" class="jp-pause" tabindex="1"&gt;pause&lt;/a&gt;&lt;/li&gt;
                                &lt;li&gt;&lt;a href="javascript:;" class="jp-stop" tabindex="1"&gt;stop&lt;/a&gt;&lt;/li&gt;
                            &lt;/ul&gt;
                            &lt;div class="jp-progress"&gt;
                                &lt;div class="jp-seek-bar"&gt;
                                    &lt;div class="jp-play-bar"&gt;&lt;/div&gt;
                                &lt;/div&gt;
                            &lt;/div&gt;
                            &lt;div class="jp-time-holder"&gt;
                                &lt;div class="jp-current-time"&gt;&lt;/div&gt;
                                &lt;div class="jp-duration"&gt;&lt;/div&gt;
                            &lt;/div&gt;
                        &lt;/div&gt;
                        &lt;div class="jp-no-solution"&gt;
                            &lt;span&gt;Update Required&lt;/span&gt;
                            To play the media you will need to either update your browser to a recent version or update your &lt;a href="http://get.adobe.com/flashplayer/" target="_blank"&gt;Flash plugin&lt;/a&gt;.
                        &lt;/div&gt;
                    &lt;/div&gt;
                &lt;/div&gt;';
  }

}
Drupal 7 uses stream wrappers instead of "file paths" to reference files in the public and private upload directories. If you want to research that more, the rabbit hole starts here - http://drupal.org/node/555118

In a "vanilla" D7 setup "public://" is equivalent to the D6 "sites//files" or "sites/default/files" directory. These directories still exist in D7 but have been moved in D8 - using a stream wrapper means the files can be moved anywhere, even a remote location, and still be referenced in a consistent fashion if you update the default stream wrapper.

Clive's comment referencing file_create_url() is a function that takes a stream uri and converts it to a url that a web browser can use.

The problem is that your server-side code delivering media to jPlayer is not sending URIs in the right format. If it's a contrib module, you should open an issue in the queue and link to it here; Clive or myself might be able to provide a patch.

I'm going to assume that the module you're using was originally released in D6 and then upgraded at some point to D7? (maybe the upgrade didn't go so well :P)

Edit:

Based on the code that was posted after I originally put this answer up I'd suggest looking into two things:


Shouldn't 
$file-&gt;url = str_replace('public:/', $base_url . '/' . variable_get('file_public_path', 'files'), $file-&gt;uri); 
be 
$file-&gt;url = file_create_url($file-&gt;uri); ?
The "setMedia" action for jPlayer, I can't remember off the top of my head if it needs to be a url or a file path, but if it's a url shouldn't you be using $file->url? if it's a file path shouldn't it be generated by drupal_realpath()?