mirror of
https://github.com/LC044/WeChatMsg
synced 2025-02-22 02:22:17 +08:00
视频和音频播放一个,其他的就暂停
This commit is contained in:
parent
bc6a479b4d
commit
9b2d1891d5
@ -1220,6 +1220,7 @@ html_end = '''
|
|||||||
}
|
}
|
||||||
document.querySelector("#chat-container").scrollTop = 0;
|
document.querySelector("#chat-container").scrollTop = 0;
|
||||||
updatePaginationInfo();
|
updatePaginationInfo();
|
||||||
|
refreshMediaListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
function prevPage() {
|
function prevPage() {
|
||||||
@ -1256,6 +1257,39 @@ html_end = '''
|
|||||||
|
|
||||||
// 初始化页面
|
// 初始化页面
|
||||||
renderPage(currentPage);
|
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();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
Loading…
Reference in New Issue
Block a user