Play Recordings in FreePBX 2.x With Chrome and Firefox

For those who may wish to use an older version of FreePBX. You may find that you are now unable to play audio from your recorded calls in the CDR module due to new browser limitations. I crafted a workaround for this so that you can play the recordings inside of the most recent Chrome and Firefox releases.

  1. Inside of /var/www/html/admin/modules/cdr you need to create a directory “tempfiles” and make sure it is owned by “asterisk:asterisk”

  2. Then edit the following files as I have done below:

page.cdr.php (look for the function below and change it like so):

function cdr_formatRecordingFile($recordingfile, $basename, $id, $uid) {
if ($recordingfile) {
	$audio = $recordingfile;
	$recurl	= $_SERVER['SCRIPT_NAME']."?display=cdr&action=cdr_play&recordingpath=$audio";
	$playbackRow= $id +1;
	echo "<td title=\"basename\"><a href=\"#\" onClick=\"javascript:cdr_play($playbackRow, '$recurl'); return false;\"><img src=\"assets/cdr/images/cdr_sound.png\" alt=\"Call recording\" /></a>
	<a href=\"$download_url\"><img src=\"assets/cdr/images/cdr_download.png\" alt=\"Call recording\" /></a></td>";
} else {
	echo "<td></td>";


cdr_play.php (This is the entire file, you should be able to delete everything and paste it right in):

if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); }

 * @file
 * popup window for playing recording
$file = ($_REQUEST['recordingpath']);
$retgroups = array();
preg_match("/(^\/[a-z0-9_.]+\/[a-z0-9_.]+\/[a-z0-9_.]+\/[a-z0-9_.]+\/[a-z0-9_.]+\/[a-z0-9_.]+\/[a-z0-9_.]+\/)([a-z0-9_.\-]+)/", $file, $retgroups);
$path = $retgroups[1];
$soundfile = $retgroups[2];
$webdir = "/var/www/html/admin/modules/cdr/tempfiles/";
//Get rid of any files in the tempfiles folder
$storedfiles = glob($webdir.'*');
foreach($storedfiles as $item){
copy($path.$soundfile, $webdir.$soundfile);
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
    <TITLE>CDR Viewer</TITLE>
			<style type="text/css">
				.popup_download {
					color: #105D90; 
					margin: 5px; 
					font-size: 12px; 
					text-align: left;
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
	  <audio controls>
		<source src="/admin/modules/cdr/tempfiles/<?php echo $soundfile ?>" type="audio/wav">
		Your browser does not support the audio element.

That’s it, run a CDR report with some recordings and play them. The recordings are stored in the tempfile directory but are deleted each time you open a new recording to play.

The nice thing about FreePBX 13 and how this functions is that FreePBX 13 determines your browser and transcodes on-the-fly to give you the best possible single codec to be able to playback in any device.

This allows you to listen to ANY recording in ANY browser (even wav files in internet explorer because IE does not support WAV). The code posted above would only work on wav recordings.