Commit 23735ee1 by Lee Munkyeong

Merge branch 'feature/develop_encode_video' into 'develop'

Feature/develop encode video

See merge request !147
parents e40c06b5 a2f34c2e
......@@ -243,7 +243,7 @@ $('#image-form').on('submit', function(e) {
$('.loader').addClass('active');
CHAT_UI.showLoadingIndicator();
var fd = new FormData($(this)[0]);
console.log($(this)[0]);
//画像の大きさが500pixelより大きかったら、thumbnailを生成
CHAT.createThumbnailAndUpload(file, function(resizeFile, thumbnailCreated) {
if (resizeFile && thumbnailCreated) {
......@@ -825,6 +825,95 @@ CHAT_UI.deleteButtonAction = function(isInvite) {
CHAT_UI.showConfirmView(isInvite)
$('#select_user_list .user_list').find('.userCheckBox').show();
}
var GetFileBlobUsingURL = function (url, convertBlob) {
var xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.responseType = "blob";
xhr.addEventListener('load', function() {
console.log(xhr.response);
convertBlob(xhr.response);
});
xhr.send();
};
var blobToFile = function (blob, name) {
blob.lastModifiedDate = new Date();
blob.name = name;
return blob;
};
var GetFileObjectFromURL = function(filePathOrUrl, convertBlob) {
GetFileBlobUsingURL(filePathOrUrl, function (blob) {
convertBlob(blobToFile(blob, 'testFile.mp4'));
});
};
CHAT_UI.videoEncodeFail = function() {
alert(getLocalizedString('error_send_video'));
CHAT_UI.dismissLoadingIndicator();
}
CHAT_UI.videoEncodeEnd = function(encodedUri) {
var fileName = encodedUri.split('/')[encodedUri.split('/').length-1];
var fileURL = 'file:'+encodedUri;
var xhr = new XMLHttpRequest();
xhr.open("GET", fileURL);
xhr.responseType = "blob";
xhr.addEventListener('load', function() {
var formData = new FormData();
formData.append("image", xhr.response, fileName);
formData.append('sid', CHAT.globalLoginParameter.sid);
formData.append('roomId', CHAT.globalLoginParameter.roomId);
jQuery.ajax({
async: true,
url: CMS_SERVER_URL + "/chatapi/file/upload",
type: "post",
data: formData,
contentType: false,
processData: false,
error: function () {
alert(getLocalizedString('error_send_video'));
CHAT_UI.dismissLoadingIndicator();
}
}).done(function(res) {
if (CHAT_UTIL.isAndroid()) {
android.removeEncodedVideo(encodedUri);
}
var imgPath = CMS_SERVER_URL + '/chatapi/file/getImage?fileName=' + res.fileName + '&roomId=' + CHAT.globalLoginParameter.roomId;
var imageName = res.fileName;
// uploadFileの判断
var extension = imageName.substr(imageName.lastIndexOf('.') + 1).toLowerCase();
if (res.thumbnailPath && res.thumbnailPath.length > 0) {
imgPath = CMS_SERVER_URL + '/chatapi/file/getImage?fileName=' + res.thumbImageFileName + '&roomId=' + CHAT.globalLoginParameter.roomId;
}
let downloadPath = CMS_SERVER_URL + '/chatapi/file/download?fileName=' + imageName + '&roomId=' + CHAT.globalLoginParameter.roomId;
var videoSrc = CMS_SERVER_URL + '/chatapi/file/getImage?fileName=' + res.fileName + '&roomId=' + CHAT.globalLoginParameter.roomId;
const totalDiv = $('<div/>', {id:"attachedImages"});
const videoTag = $('<video/>', {controls:"true", width:'auto', style:'max-width:100%'});
const source = $('<source/>', {src:videoSrc});
const downloadIcon = $('<a/>',{href:downloadPath, class:'fa fa-download', download:res.fileName});
videoTag.append(source);
totalDiv.append(videoTag);
totalDiv.append(downloadIcon);
let text = totalDiv.prop('outerHTML');
let encodedText
try {
encodedText = encodeURIComponent(text)
} catch(e) {
encodedText = text;
}
socket.emit('createMessage', {
text: encodedText + messageSeperator + messageType.VIDEO
}, 1);
$('.overlay').removeClass('active undismissable');
$('.loader').removeClass('active');
CHAT_UI.dismissLoadingIndicator();
})
});
xhr.send();
};
CHAT_UI.htmlElementTextInitialize = function(languageCode) {
moment.locale(languageCode);
......
......@@ -99,5 +99,6 @@ $.lang.en = {
"not_support_version" : "did not support this device version.",
"err_target_android_version_not_support" : "did not support document collaboration on this user's device version.",
"err_not_exist_room" : "this room is not exist.",
"norify_request_host_change" : "%@ request host permission \ndo you want to approve?"
"norify_request_host_change" : "%@ request host permission \ndo you want to approve?",
"error_send_video": "Fail to send."
}
......@@ -99,5 +99,6 @@ $.lang.ja = {
"not_support_version" : "現在の端末バージョンでは利用できません。",
"err_target_android_version_not_support" : "対象ユーザの端末バージョンでは文書協業が利用できません。",
"err_not_exist_room" : "該当のルームが存在しません。",
"norify_request_host_change" : "%@様からホスト変更リクエストがあります。\n承認しますか?"
"norify_request_host_change" : "%@様からホスト変更リクエストがあります。\n承認しますか?",
"error_send_video": "送信に失敗しました。"
}
\ No newline at end of file
......@@ -99,5 +99,6 @@ $.lang.ko = {
"not_support_version" : "현재단말버전에서는 지원되지않는기능입니다.",
"err_target_android_version_not_support" : "해당 유저의 단말버전에서는 문서협업이 이용불가능합니다.",
"err_not_exist_room" : "해당 룸이 존재하지않습니다.",
"norify_request_host_change" : "%@님이 호스트변경을 요청하셨습니다.\n승인하시겠습니까?"
"norify_request_host_change" : "%@님이 호스트변경을 요청하셨습니다.\n승인하시겠습니까?",
"error_send_video": "전송에 실패했습니다."
}
......@@ -213,7 +213,8 @@ $(function () {
coview_api.addEventListener("destroy", function () {
console.log("=============> DESTROY : share destroy");
coview_api.LeaveRoom();
alert(getLocalizedString("inform_exit_host_collaboration"));
Coview_exitCollaboration();
$(".coview_share_area").hide();
$("#loadingIndicator").removeClass("full_active");
});
......
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