Incorrect MIME Type Sent When Playing Voicemail/Call Recordings In Web Browser

Hello Everyone,

This sort of goes along with my other post from last year: What Is The Format Of Call Recordings but I felt this deserved a new post because I think I’ve narrowed the problem down and it could even be a potential bug. Here’s the situation: all of my voicemails and call recordings are saved on my FreePBX/Asterisk box as *.wav with a MIME type of: audio/x-wave. However when I view the speaker icon info on the FreePBX User Portal, my web browser lists the audio file as: MIME type: audio/basic. If I type: about:plugins in Firefox’s web address bar I can see that my embedded VLC plugin is not compatible with MIME type: audio/basic hence, this is why VLC cannot play the simple wav audio files through my FreePBX User Portal. The voicemail files are pulled from the FreePBX/Asterisk server via the: audio.php script, but why does this script not correctly identify the audio file as MIME type: audio/x-wave as that is clearly the file MIME type? I’m by no means a PHP expert but it appears the audio.php script is setup to identify the audio file(s) indicated by the bold font below: <?php

/**

  • @file
  • plays recording file
    */

if (isset($_GET[‘recindex’])) {

chdir("…");
include_once("./includes/bootstrap.php");

$path = $_SESSION['ari_user']['recfiles'][$_GET['recindex']];

// See if the file exists
if (!is_file($path)) { die(“404 File not found!”); }

// Gather relevent info about file
$size = filesize($path);
$name = basename($path);
$extension = strtolower(substr(strrchr($name,"."),1));

// This will set the Content-Type to the appropriate setting for the file
$ctype =’’;
switch( $extension ) {
case “mp3”: $ctype=“audio/mpeg”; break;
case “wav”: $ctype=“audio/x-wav”; break;
case “Wav”: $ctype=“audio/x-wav”; break;
case “WAV”: $ctype=“audio/x-wav”; break;
case “gsm”: $ctype=“audio/x-gsm”; break;

// not downloadable
default: die("<b>404 File not found!</b>"); break ;

}

// need to check if file is mislabeled or a liar.
$fp=fopen($path, “rb”);
if ($size && $ctype && $fp) {
header(“Pragma: public”);
header(“Expires: 0”);
header(“Cache-Control: must-revalidate, post-check=0, pre-check=0”);
header(“Cache-Control: public”);
header(“Content-Description: wav file”);
header("Content-Type: " . $ctype);
header(“Content-Disposition: attachment; filename=” . $name);
header(“Content-Transfer-Encoding: binary”);
header("Content-length: " . $size);
ob_clean();
fpassthru($fp);
}
}

?>

Could one of the PHP “Gods” help me understand why my web browser lists the incorrect MIME type for my audio file(s) played through a web browser or should I just file a Bug Report? I’m using Firefox 19 on Ubuntu 12.10 but the problem still exists for my co-workers who use Windows 7x64 machines with Firefox 19. I’m also using an older Track of FreePBX: freepbxdistro-version: 1.810.210.57-1 (FreePBX 2.10.1.5 Web UI) but the script appears to be the same on freepbxdistro-version: 3.211.63-5 which I have installed on a VirtualBox.

Could anyone help me out on this problem?

Look like the play.php page embeds file with audio/basic (which is not usually used for .wav files (.au and .snd yes)

recordings/misc/play_page.php: echo("<embed width=‘100%’ type=‘audio/basic’

You could try setting it to audio/wav and see if it makes a difference.

Try changing recordings/misc/play_page.php to echo("<embed width=‘100%’ type=‘audio/wav’

It blocked my code above

ok…last time:

try to change the type in the recordings/misc/play_page.php to audio/wav