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..
<?php
/**
* Implementation of theme_menu_tree().
*/
function wyep_menu_tree(&$variables) {
return '<ul class="menu">' . $variables['tree'] . '</ul>';
}
/**
* Implementation of theme_file_link().
*/
function play_file_link($variables) {
//watchdog('theme_file_link', '<code><pre>' . print_r($variables, TRUE) . '</pre></code>');
global $base_path, $base_url;
$file = $variables['file'];
$file->url = str_replace('public:/', $base_url . '/' . variable_get('file_public_path', 'files'), $file->uri);
switch ($file->filemime) {
case 'audio/mpeg':
return '<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#jquery_jplayer_' . $file->fid . '").jPlayer({
ready: function (event) {
jQuery(this).jPlayer("setMedia", {
mp3:"/files/' . $file->filename . '"
});
},
cssSelectorAncestor: "#jp_container_' . $file->fid . '",
swfPath: "' . $base_url . '/sites/all/libraries/jplayer/Jplayer.swf",
supplied: "mp3",
wmode: "window"
});
});
</script>
<div id="jquery_jplayer_' . $file->fid . '" class="jp-jplayer"></div>
<div id="jp_container_' . $file->fid . '" class="jp-audio">
<div class="jp-type-single">
<div class="jp-gui jp-interface">
<ul class="jp-controls">
<li><a href="javascript:;" class="jp-play" tabindex="1">play</a></li>
<li><a href="javascript:;" class="jp-pause" tabindex="1">pause</a></li>
<li><a href="javascript:;" class="jp-stop" tabindex="1">stop</a></li>
</ul>
<div class="jp-progress">
<div class="jp-seek-bar">
<div class="jp-play-bar"></div>
</div>
</div>
<div class="jp-time-holder">
<div class="jp-current-time"></div>
<div class="jp-duration"></div>
</div>
</div>
<div class="jp-no-solution">
<span>Update Required</span>
To play the media you will need to either update your browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>.
</div>
</div>
</div>';
}
}
file_create_url()
. What module(s) are you using for the MP3 functionality?