From 9b2d1891d581d2124b6232c2ece05769fa5c0fb6 Mon Sep 17 00:00:00 2001 From: STDquantum <405720329@qq.com> Date: Sun, 17 Dec 2023 20:19:29 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E5=92=8C=E9=9F=B3=E9=A2=91?= =?UTF-8?q?=E6=92=AD=E6=94=BE=E4=B8=80=E4=B8=AA=EF=BC=8C=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E7=9A=84=E5=B0=B1=E6=9A=82=E5=81=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/DataBase/output_pc.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/app/DataBase/output_pc.py b/app/DataBase/output_pc.py index 35a9037..0330610 100644 --- a/app/DataBase/output_pc.py +++ b/app/DataBase/output_pc.py @@ -1220,6 +1220,7 @@ html_end = ''' } document.querySelector("#chat-container").scrollTop = 0; updatePaginationInfo(); + refreshMediaListener(); } function prevPage() { @@ -1256,6 +1257,39 @@ html_end = ''' // 初始化页面 renderPage(currentPage); + + function refreshMediaListener() { + const audioTags = document.querySelectorAll('audio'); + const videoTags = document.querySelectorAll('video'); + + audioTags.forEach(audio => { + audio.addEventListener('play', function () { + pauseOtherMedia(audio); + }); + }); + videoTags.forEach(video => { + video.addEventListener('play', function () { + pauseOtherMedia(video); + }); + }); + + function pauseOtherMedia(currentMedia) { + const audioTags = document.querySelectorAll('audio'); + const videoTags = document.querySelectorAll('video'); + audioTags.forEach(media => { + if (media !== currentMedia && !media.paused) { + media.pause(); + } + }); + videoTags.forEach(media => { + if (media !== currentMedia && !media.paused) { + media.pause(); + } + }); + } + } + + refreshMediaListener();