mirror of
https://github.com/tl-open-source/tl-rtc-file.git
synced 2025-09-27 03:46:11 +08:00

feat: 支持单独发送文件 feat: 支持文本私聊 feat: 支持seafile网盘暂存文件 feat: 支持直播房间 feat: 支持取件码下载文件 feat: 支持预览视频文件 feat: 支持报错告警 feat: 调整补充启动logo feat: 调整补充免责协议 feat: 调整补充配置中的版本号 feat: 调整优化开源协议 feat: 调整补充定制收费服务 feat: 调整优化服务端代码 feat: 调整优化批量发送逻辑 feat: 调整优化样式体验 feat: 调整优化conf中ws, manage相关配置 feat: 调整优化文件发送时间间隔为1秒钟 feat: 调整优化文件发送体验 feat: 调整优化选择文件逻辑 feat: 调整优化启动文件/命令 feat: 调整优化socket配置区分 feat: 调整优化分享进入房间 feat: 调整优化右上角消息提示 feat: 调整删除npm依赖 feat: 调整删除首次弹窗 feat: 即将支持远程cavas画笔 feat: 即将支持远程控制
127 lines
4.1 KiB
JavaScript
127 lines
4.1 KiB
JavaScript
var screen = new Vue({
|
|
el: '#screenApp',
|
|
data: function () {
|
|
return {
|
|
stream: null,
|
|
chunks: [],
|
|
mediaRecorder: null,
|
|
recording: null,
|
|
times: 0,
|
|
interverlId: 0,
|
|
size: 0,
|
|
}
|
|
},
|
|
methods: {
|
|
getMediaPlay: function () {
|
|
if (navigator.getDisplayMedia) {
|
|
return navigator.getDisplayMedia({ video: true, audio: true });
|
|
} else if (navigator.mediaDevices.getDisplayMedia) {
|
|
return navigator.mediaDevices.getDisplayMedia({ video: true, audio: true });
|
|
} else if (navigator.mediaDevices.getUserMedia) {
|
|
return navigator.mediaDevices.getUserMedia({ video: { mediaSource: 'screen' }, audio: true });
|
|
} else {
|
|
return navigator.getUserMedia({
|
|
video: { 'mandatory': { 'chromeMediaSource': 'desktop' } },
|
|
audio: true
|
|
})
|
|
}
|
|
},
|
|
startScreen: async function () {
|
|
let that = this;
|
|
if (this.recording) {
|
|
window.URL.revokeObjectURL(this.recording);
|
|
}
|
|
|
|
this.chunks = [];
|
|
this.recording = null;
|
|
|
|
try {
|
|
this.stream = await this.getMediaPlay();
|
|
} catch (error) {
|
|
console.log(error)
|
|
}
|
|
|
|
if (this.stream == null) {
|
|
if (window.layer) {
|
|
layer.msg("获取设备录制权限失败")
|
|
}
|
|
window.Bus.$emit("changeScreenState", false)
|
|
return;
|
|
}
|
|
|
|
this.mediaRecorder = new MediaRecorder(this.stream, { mimeType: 'video/webm' });
|
|
this.mediaRecorder.addEventListener('dataavailable', event => {
|
|
if (event.data && event.data.size > 0) {
|
|
that.size += event.data.size
|
|
that.chunks.push(event.data);
|
|
}
|
|
});
|
|
this.mediaRecorder.start(10);
|
|
|
|
//计算时间
|
|
this.interverlId = setInterval(() => {
|
|
that.times += 1;
|
|
window.Bus.$emit("changeScreenTimes", that.times)
|
|
$("#screenIcon").css("color","#fb0404")
|
|
$("#screenTimes").css("color","#fb0404")
|
|
setTimeout(() => {
|
|
$("#screenIcon").css("color","#000000")
|
|
$("#screenTimes").css("color","#000000")
|
|
}, 500)
|
|
}, 1000);
|
|
|
|
if (window.layer) {
|
|
layer.msg("开始录制,再次点击录制即可停止")
|
|
}
|
|
},
|
|
stopScreen: function (callback) {
|
|
let hasErr = false;
|
|
|
|
try {
|
|
this.mediaRecorder.stop();
|
|
} catch (e) {
|
|
if (window.layer) {
|
|
layer.msg("屏幕录制完毕! 检测到录制不完整,如需停止录制,请点击本页面的停止按钮来停止录制")
|
|
}
|
|
hasErr = true
|
|
}
|
|
|
|
this.stream.getTracks().forEach(track => track.stop());
|
|
this.recording = window.URL.createObjectURL(new Blob(this.chunks, { type: 'video/webm' }));
|
|
|
|
clearInterval(this.interverlId);
|
|
|
|
this.mediaRecorder = null;
|
|
this.chunks = [];
|
|
this.stream = null;
|
|
|
|
let data = {
|
|
donwId: 'd_' + parseInt(Math.random(10000) * 10000),
|
|
times: this.times,
|
|
src: this.recording,
|
|
size: this.size
|
|
}
|
|
|
|
this.times = 0;
|
|
this.size = 0;
|
|
|
|
window.Bus.$emit("changeScreenTimes", 0)
|
|
|
|
callback(data)
|
|
|
|
if (window.layer && !hasErr) {
|
|
layer.msg("录制完成,请在接收文件列表查看")
|
|
}
|
|
|
|
setTimeout(() => {
|
|
$("#screenIcon").css("color","#000000")
|
|
}, 1000);
|
|
|
|
return;
|
|
},
|
|
},
|
|
mounted: function () {
|
|
window.Bus.$on("startScreen", this.startScreen);
|
|
window.Bus.$on("stopScreen", this.stopScreen);
|
|
}
|
|
}) |