Audio file not playing
bartoki - December 28, 2007 - 23:11
| Project: | Mediafield Display |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Jump to:
Description
Combining 1pixelout with mediafield is a huge help to my site. Unfortunately, I am getting the message "Error opening file" whenever I attempt to play the attached audio file. I believe this problem is related to a similar issue reported with http://drupal.org/node/157922 where the media url is not being interpreted properly, however I'm unable to track it down due to my inexperience with code. My audio files are being stored as /files/musicfile.mp3. Thanks in advance to anyone that can help.

#1
Looking at this problem some more, I've isolated where I think the problem is occurring. In the file mediafield_display.module where the 1pixelout player is called, it's generating an incorrect URL for the audio file (below).
function theme_mediafield_display_1pixelout($file, $item, $field) {
global $base_url;
$options = array();
$options['soundFile'] = check_url($base_url .'/'. $file['filepath']);
$url = $base_url .'/'. drupal_get_path('module', 'mediafield_display') .'/players/1pixelout.swf';
$flashvars = array();
foreach ($options as $key => $val) {
$flashvars[] = rawurlencode($key) .'='. rawurlencode($val);
}
$flashvars = implode('&', $flashvars);
$output = <<<EOT
<object type="application/x-shockwave-flash" data="$url" width="290" height="24" >
<param name="movie" value="$url" />
<param name="wmode" value="transparent" />
<param name="menu" value="false" />
<param name="quality" value="high" />
<param name="FlashVars" value="$flashvars" />
</object>
EOT;
return $output;
}
I believe this may be similar to http://drupal.org/node/179439 where the solution was to use str_replace (below).
function theme_audio_1pixelout_node_player($node, $options = array()) {
// make sure it's compatible with the flash player
if (!audio_is_flash_playable($node)) {
return NULL;
}
$options['soundFile'] = check_url($node->url_play);
$url = base_path() . drupal_get_path('module', 'audio') .'/players/1pixelout.swf';
$flashvars = audio_query_string_encode($options);
// '#' seems to encode as %2523, reverse this, using a more robust hex prefix..
$flashvars = str_replace('%2523', '0x', $flashvars);
// '/' seems to encode as %252F, reverse this back to '/'
$flashvars = str_replace('%252F', '/', $flashvars);
$output = <<<EOT
<object type="application/x-shockwave-flash" data="$url" width="290" height="24" >
<param name="movie" value="$url" />
<param name="wmode" value="transparent" />
<param name="menu" value="false" />
<param name="quality" value="high" />
<param name="FlashVars" value="$flashvars" />
<embed src="$url" flashvars="$flashvars" width="290" height="24" />
</object>
EOT;
return $output;
}
However, I'm unable to tweak mediafield_display.module to generate the proper URL for the audio. Am I barking up the right tree?
#2
I just created an official release, Can you try it with that and see if it helps? The part of the code that you're describing has been reworked; it may solve your problem.
#3
I seem to be having a similar error.
The player appears, but clicking for playback causes "Error opening file". I also get a log entry stating a 404 error.
The 404 url is
https://abolitionwya.org.uk/%2Fabolitionwya.org.uk/files/media/audio/01_...
when it should be
https://abolitionwya.org.uk/files/media/audio/01_Veneno.mp3
A strange thing is that the player works if the user is accessing the site via HTTP not HTTPS.
Weird.
Drew