From cf115e6e8ee7cf67b0559248f4221b57104b2498 Mon Sep 17 00:00:00 2001 From: yinjiacheng Date: Mon, 9 Sep 2024 16:58:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0video=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/component/video/video.uvue | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/pages/component/video/video.uvue b/pages/component/video/video.uvue index a4ca8e70..2c5dc077 100644 --- a/pages/component/video/video.uvue +++ b/pages/component/video/video.uvue @@ -15,6 +15,9 @@ src="../../../static/test-video/fast-backward.png" @tap="fastBackward"> + @@ -25,7 +28,7 @@ - 子组件实现快进、快退功能(全屏后显示) + 子组件实现快进、快退、发送弹幕功能(全屏后显示) @@ -276,6 +279,23 @@ if (pos > this.endPos) pos = this.endPos; this.seek(pos); }, + onSendDanmuConfirm: function (event : UniInputConfirmEvent) { + this.videoContext?.sendDanmu({ + text: event.detail.value, + color: '#ff0000' + } as Danmu); + }, + onSendDanmuKeyboardHeightChange: function (event : UniInputKeyboardHeightChangeEvent) { + const element = uni.getElementById('input-send-danmu') as UniElement; + if (event.detail.height.toInt() == 0) { + element.style.setProperty('bottom', '50px'); + } else { + element.style.setProperty('bottom', event.detail.height + element.getBoundingClientRect().height); + } + }, + onSendDanmuBlur: function (_ : UniInputBlurEvent) { + (uni.getElementById('input-send-danmu') as UniElement).style.setProperty('bottom', '50px'); + }, // 属性 onSrcComfirm: function (event : UniInputConfirmEvent) { let value = event.detail.value; @@ -575,4 +595,14 @@ transform: translate(50%, -50%); position: absolute; } + + .input-send-danmu { + height: 40px; + padding: 8px 13px; + margin: 0 var(--status-bar-height); + bottom: 50px; + position: absolute; + background-color: rgba(0, 0, 0, 0.5); + color: #FFF; + } -- GitLab