[mirotalksfu] - add chat video/audio from url

هذا الالتزام موجود في:
Miroslav Pejic
2022-09-20 14:20:14 +02:00
الأصل 3f9dab7427
التزام c4de8fa5a7
2 ملفات معدلة مع 20 إضافات و0 حذوفات

عرض الملف

@@ -440,11 +440,16 @@ body {
}
.msg-text {
display: inline-block;
overflow-wrap: break-word;
word-wrap: break-word;
hyphens: auto;
}
.msg-text iframe {
width: 100%;
}
.msg-a {
color: #fff;
}

عرض الملف

@@ -2357,6 +2357,7 @@ class RoomClient {
if (this.isHtml(message)) return this.stripHtml(message);
if (this.isValidHttpURL(message)) {
if (isImageURL(message)) return '<img src="' + message + '" alt="img" width="180" height="auto"/>';
if (this.isVideoTypeSupported(message)) return this.getIframe(message);
return '<a href="' + message + '" target="_blank" class="msg-a">' + message + '</a>';
}
if (isChatMarkdownOn) return marked.parse(message);
@@ -2395,6 +2396,20 @@ class RoomClient {
return url.protocol === 'http:' || url.protocol === 'https:';
}
getIframe(url) {
let is_youtube = this.getVideoType(url) == 'na' ? true : false;
let video_audio_url = is_youtube ? this.getYoutubeEmbed(url) : url;
return `
<iframe
title="Chat-IFrame"
src="${video_audio_url}"
width="auto"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen
></iframe>`;
}
getLineBreaks(message) {
return (message.match(/\n/g) || []).length;
}