上传语音的时候,返回的语音文件木有带后缀
上传语音的时候,返回的语音文件木有带后缀,是不是我上传的时候有问题...
//发送各种消息
function sendMessage(messageType, product, duration) {
var id = conn.getUniqueId();//生成本地消息id
var msg;
switch (messageType) {
case "text":
msg = new WebIM.message('txt', id);//创建文本消息
//var myMessageText = $("#waitSendMsg").val();
var myMessageText = "";
//编码消息
var encodeMessage = base64encode(utf16to8(myMessageText));
msg.set({
msg: encodeMessage,
to: Target.LoginName,
success: function (Mess) { //消息发送成功回调
bindSendHtml(myMessageText);
$("#waitSendMsg").val("");
$("#chatinput").html("");
saveHistory(id, 1, myMessageText);
}
});
break;
case "picture":
$.showPreloader('图片正在传输...');
msg = new WebIM.message('img', id);
var input = document.getElementById(fileInputId);//选择图片的input
var file = WebIM.utils.getFileUrl(input);
var allowType = {
"jpg": true,
"gif": true,
"png": true,
"bmp": true
};
var data;
//如果浏览器支持canvas 则可以压缩 将对象文件数据指向压缩后的Blob对象
if(isCanvasSupported)
{
file.data = blobImageFile;//file
}
if (file.filetype.toLowerCase() in allowType) {
msg.set({
apiUrl: WebIM.config.apiURL,
file: file,
to: Target.LoginName,
onFileUploadError: function (error) { },//图片上传失败
onFileUploadComplete: function (d) {
//图片地址:data.uri + '/' + data.entities[0].uuid;
data = d;
},
success: function (id1) {
$.hidePreloader();
var picMessage = "";;
bindSendHtml(picMessage);
saveHistory(id, 2, picMessage);
},//图片消息发送成功
flashUpload: WebIM.flashUpload
});
}
break;
case "productLink":
//编码消息
var encodeMessage = base64encode(utf16to8(product));
msg = new WebIM.message('txt', id);//创建文本消息
msg.set({
msg: encodeMessage,
to: Target.LoginName,
success: function (Mess) { //消息发送成功回调
bindSendHtml(product);
//所有选择框去除勾选
jQuery("#productList li").each(function (index, element) {
if (jQuery(element).hasClass("selected1")) {
jQuery(element).removeClass("selected1")
}
});
//勾选产品数目为0
jQuery("#sendNum").text("0");
count = 0;
saveHistory(id, 3, product);
}
});
break;
//语音
case "audio":
var input = document.getElementById("pictureInput");//选择图片的input
var file = WebIM.utils.getFileUrl(input);
file.data = mp3Blob;//file
file.fileName = 'audio_' + id;
file.type = "video/webm";
msg = new WebIM.message('audio', id);//创建文本消息
msg.set({
apiUrl: WebIM.config.apiURL,
file: file,//需要传这个
to: Target.LoginName,
length: duration || 0,
onFileUploadError: function onFileUploadError(error) {
//me.refs.audio.value = null;
//Demo.api.appendMsg({
// data: Demo.lan.sendAudioFailed,
// from: Demo.user,
// to: Demo.selected
//}, 'txt');
},
onFileUploadComplete: function onFileUploadComplete(data) {
debugger;
url = data.uri + '/' + data.entities[0].uuid;
me.refs.audio.value = null;
},
success: function success(id, sid) {
debugger;
// url = data.uri + '/' + data.entities[0].uuid;
//blobToDataURL(mp3Blob, function (base64Code) {
// base64AudioCode = base64Code;
//});
var myMessageText = " ";
bindSendHtml(myMessageText);
//$("#audio_" + id).attr("src",url);
saveHistory(id, 4, myMessageText);
},
flashUpload: WebIM.flashUpload
});
break;
}
//msg.body.roomType = true;聊天模式:是否是聊天室
conn.send(msg.body);
}
//发送各种消息
function sendMessage(messageType, product, duration) {
var id = conn.getUniqueId();//生成本地消息id
var msg;
switch (messageType) {
case "text":
msg = new WebIM.message('txt', id);//创建文本消息
//var myMessageText = $("#waitSendMsg").val();
var myMessageText = "
" + $("#chatinput").html() + "
//编码消息
var encodeMessage = base64encode(utf16to8(myMessageText));
msg.set({
msg: encodeMessage,
to: Target.LoginName,
success: function (Mess) { //消息发送成功回调
bindSendHtml(myMessageText);
$("#waitSendMsg").val("");
$("#chatinput").html("");
saveHistory(id, 1, myMessageText);
}
});
break;
case "picture":
$.showPreloader('图片正在传输...');
msg = new WebIM.message('img', id);
var input = document.getElementById(fileInputId);//选择图片的input
var file = WebIM.utils.getFileUrl(input);
var allowType = {
"jpg": true,
"gif": true,
"png": true,
"bmp": true
};
var data;
//如果浏览器支持canvas 则可以压缩 将对象文件数据指向压缩后的Blob对象
if(isCanvasSupported)
{
file.data = blobImageFile;//file
}
if (file.filetype.toLowerCase() in allowType) {
msg.set({
apiUrl: WebIM.config.apiURL,
file: file,
to: Target.LoginName,
onFileUploadError: function (error) { },//图片上传失败
onFileUploadComplete: function (d) {
//图片地址:data.uri + '/' + data.entities[0].uuid;
data = d;
},
success: function (id1) {
$.hidePreloader();
var picMessage = "
" + "" + "
bindSendHtml(picMessage);
saveHistory(id, 2, picMessage);
},//图片消息发送成功
flashUpload: WebIM.flashUpload
});
}
break;
case "productLink":
//编码消息
var encodeMessage = base64encode(utf16to8(product));
msg = new WebIM.message('txt', id);//创建文本消息
msg.set({
msg: encodeMessage,
to: Target.LoginName,
success: function (Mess) { //消息发送成功回调
bindSendHtml(product);
//所有选择框去除勾选
jQuery("#productList li").each(function (index, element) {
if (jQuery(element).hasClass("selected1")) {
jQuery(element).removeClass("selected1")
}
});
//勾选产品数目为0
jQuery("#sendNum").text("0");
count = 0;
saveHistory(id, 3, product);
}
});
break;
//语音
case "audio":
var input = document.getElementById("pictureInput");//选择图片的input
var file = WebIM.utils.getFileUrl(input);
file.data = mp3Blob;//file
file.fileName = 'audio_' + id;
file.type = "video/webm";
msg = new WebIM.message('audio', id);//创建文本消息
msg.set({
apiUrl: WebIM.config.apiURL,
file: file,//需要传这个
to: Target.LoginName,
length: duration || 0,
onFileUploadError: function onFileUploadError(error) {
//me.refs.audio.value = null;
//Demo.api.appendMsg({
// data: Demo.lan.sendAudioFailed,
// from: Demo.user,
// to: Demo.selected
//}, 'txt');
},
onFileUploadComplete: function onFileUploadComplete(data) {
debugger;
url = data.uri + '/' + data.entities[0].uuid;
me.refs.audio.value = null;
},
success: function success(id, sid) {
debugger;
// url = data.uri + '/' + data.entities[0].uuid;
//blobToDataURL(mp3Blob, function (base64Code) {
// base64AudioCode = base64Code;
//});
var myMessageText = "
语音
bindSendHtml(myMessageText);
//$("#audio_" + id).attr("src",url);
saveHistory(id, 4, myMessageText);
},
flashUpload: WebIM.flashUpload
});
break;
}
//msg.body.roomType = true;聊天模式:是否是聊天室
conn.send(msg.body);
}
没有找到相关结果
已邀请:
6 个回复
lizg - ……
、格調 小紫
msg = new WebIM.message('audio', id);//创建语音
视频消息的怎样写??????
lizg - ……
、格調 小紫
Objectid:"WEBIM_30c1af1e60"
type:102
__proto__:Object
102是啥????
lizg - ……
、格調 小紫