Commit 729b70d5 authored by Ted Trask's avatar Ted Trask

Fix message playback, support both mp3 and wav audio formats, and modify...

Fix message playback, support both mp3 and wav audio formats, and modify listmessages HTML view to use HTML5 audio tag

Playback was broken since change from Play link to button
Known issue that IE11 audio tag does not support wav format
parent 7acf0bc5
......@@ -64,130 +64,9 @@ end
</script>
<script type="text/javascript">
<% -- Browser detect script from http://www.quirksmode.org/js/detect.html %>
var BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent)
|| this.searchVersion(navigator.appVersion)
|| "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function (data) {
for (var i=0;i<data.length;i++) {
var dataString = data[i].string;
var dataProp = data[i].prop;
this.versionSearchString = data[i].versionSearch || data[i].identity;
if (dataString) {
if (dataString.indexOf(data[i].subString) != -1)
return data[i].identity;
}
else if (dataProp)
return data[i].identity;
}
},
searchVersion: function (dataString) {
var index = dataString.indexOf(this.versionSearchString);
if (index == -1) return;
return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
},
dataBrowser: [
{
string: navigator.userAgent,
subString: "Chrome",
identity: "Chrome"
},
{ string: navigator.userAgent,
subString: "OmniWeb",
versionSearch: "OmniWeb/",
identity: "OmniWeb"
},
{
string: navigator.vendor,
subString: "Apple",
identity: "Safari",
versionSearch: "Version"
},
{
prop: window.opera,
identity: "Opera"
},
{
string: navigator.vendor,
subString: "iCab",
identity: "iCab"
},
{
string: navigator.vendor,
subString: "KDE",
identity: "Konqueror"
},
{
string: navigator.userAgent,
subString: "Firefox",
identity: "Firefox"
},
{
string: navigator.vendor,
subString: "Camino",
identity: "Camino"
},
{ // for newer Netscapes (6+)
string: navigator.userAgent,
subString: "Netscape",
identity: "Netscape"
},
{
string: navigator.userAgent,
subString: "MSIE",
identity: "Explorer",
versionSearch: "MSIE"
},
{
string: navigator.userAgent,
subString: "Gecko",
identity: "Mozilla",
versionSearch: "rv"
},
{ // for older Netscapes (4-)
string: navigator.userAgent,
subString: "Mozilla",
identity: "Netscape",
versionSearch: "Mozilla"
}
],
dataOS : [
{
string: navigator.platform,
subString: "Win",
identity: "Windows"
},
{
string: navigator.platform,
subString: "Mac",
identity: "Mac"
},
{
string: navigator.userAgent,
subString: "iPhone",
identity: "iPhone/iPod"
},
{
string: navigator.platform,
subString: "Linux",
identity: "Linux"
}
]
};
BrowserDetect.init();
function PlayMessage() {
$(".temporaryplayer").remove();
if ( BrowserDetect.browser == "Safari" ) {
$(this).parent().parent().after("<tr class='temporaryplayer'><td colspan='9'><object type='audio/x-wav' data='" + $(this).attr("href") + "' width='100%' height='25'><param name='src' value='" + $(this).attr("href") + "'> <param name='autoplay' value='true'> <param name='autoStart' value='1'> </object></td></tr>");
} else {
$(this).parent().parent().after("<tr class='temporaryplayer'><td colspan='9'><embed width='100%' height='25px' autostart='1' playcount='1' src='" + $(this).attr("href") + "' type='application/x-mplayer2'></embed></td></tr>");
};
$(this).parent().parent().parent().after("<tr class='temporaryplayer'><td colspan='9'><audio autoplay controls src='" + $(this).parent().prop("action") + "?submit=true&" + $(this).parent().serialize() + "'></audio></td></tr>");
return false;
}
function HandleMulti() {
......
......@@ -419,7 +419,7 @@ mymodule.get_config = function()
result.event_socket_ip = cfe({ value=config.event_socket_ip, label="FS Event Socket IP" })
result.event_socket_port = cfe({ value=config.event_socket_port, label="FS Event Socket Port" })
result.event_socket_password = cfe({ value=config.event_socket_password, label="FS Event Socket Password" })
result.callback_command = cfe({ value=config.callback_command, label="FS API Command for Callback", desc="Use $1 for extension, $2 for wav filename, and $3 for originating user. No other parameters allowed." })
result.callback_command = cfe({ value=config.callback_command, label="FS API Command for Callback", desc="Use $1 for extension, $2 for audio filename, and $3 for originating user. No other parameters allowed." })
return cfe({ type="group", value=result, label="Voicemail Config" })
end
......@@ -476,6 +476,12 @@ mymodule.download_message = function(self, downloadrequest)
else
file.label = posix.basename(tmp[1].file_path)
file.value = fs.read_file(tmp[1].file_path)
file.length = #file.value
local option = string.match(file.label, "[^.]*$")
if "wav" == option then option = "x-wav"
elseif "mp3" == option then option = "mpeg"
end
file.option = "audio/"..option
-- Mark the message as read
voicemail_read(tmp[1].username, config.domain, downloadrequest.value.message.value)
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment