使用百度的接口以後返回以http開頭的連接
例如:http://tsn.baidu.com/text2audio?tex=16%25E5%258F%25B7%25E9%25A4%2590%25E6%25A1%258C%25E5%25B7%25B2%25E7%25BB%2593%25E8%25B4%25A6&per=0&spd=5&pit=5&vol=5&cuid=1234567JAVA&tok=24.c26af36cb3be64753e57f138d403ebe4.2592000.1550033657.282335-15413771&aue=6&lan=zh&ctp=1
當用戶結完帳以後使用webscoket將信息推送給前端收銀系統,信息包括桌id,店鋪id,以及URL連接
再使用js,將URL連接傳給頁面
function voiceAnnouncements(str){
var ua = navigator.userAgent.toLowerCase();
var audiopath = str;
//var audiopath = video;
if (ua.match(/msie ([\d.]+)/)) {
jQuery('#alert_sound').html('<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"><param name="AutoStart" value="1" /><param name="Src" value="' + audiopath + '" /></object>');
}
else if (ua.match(/firefox\/([\d.]+)/)) {
// jQuery('#alert_sound').html('<embed src="' + audiopath + '" type="audio/wav" hidden="true" loop="false" mastersound></embed>');
jQuery('#alert_sound').html('<audio autoplay="autoplay"><source src="' + audiopath + '" type="audio/wav"/><source src="'+str+'" type="audio/mpeg"/></audio>');
}
else if (ua.match(/chrome\/([\d.]+)/)) {
jQuery('#alert_sound').html('<audio src="' + audiopath + '" type="audio/wav" autoplay="autoplay" hidden="true"></audio>');
}
else if (ua.match(/opera.([\d.]+)/)) {
jQuery('#alert_sound').html('<embed src="' + audiopath + '" hidden="true" loop="false"><noembed><bgsounds src=' + audiopath + '></noembed>');
}
else if (ua.match(/version\/([\d.]+).*safari/)) {
jQuery('#alert_sound').html('<audio src="' + audiopath + '" type="audio/wav" autoplay=」autoplay」 hidden="true"></audio>');
}
else {
jQuery('#alert_sound').html('<embed src="' + audiopath + '" type="audio/wav" hidden="true" loop="false" mastersound></embed>');
}
}
複製代碼