Skip to content

Commit 2414864

Browse files
author
Taois
committed
feat:控制栏画质切换
1 parent 17afe47 commit 2414864

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

dashboard/src/components/players/ArtVideoPlayer.vue

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,35 @@ const initQualityData = () => {
690690
})
691691
}
692692
693+
// 更新控制栏中的画质文本
694+
const updateQualityControlText = () => {
695+
if (!artPlayerInstance.value) return
696+
697+
try {
698+
// 通过DOM直接更新
699+
const container = artPlayerInstance.value.template.$container
700+
if (container) {
701+
// 查找控制栏中的画质按钮
702+
const controlsRight = container.querySelector('.art-controls-right')
703+
if (controlsRight) {
704+
const buttons = controlsRight.querySelectorAll('.art-control')
705+
// 遍历所有按钮,找到包含"画质"文本的按钮
706+
for (let i = 0; i < buttons.length; i++) {
707+
const button = buttons[i]
708+
if (button.innerHTML.includes('画质')) {
709+
const newText = `画质: ${getCurrentQualityLabel.value}`
710+
button.innerHTML = newText
711+
console.log('更新控制栏画质文本:', newText)
712+
return
713+
}
714+
}
715+
}
716+
}
717+
} catch (error) {
718+
console.error('更新控制栏画质文本失败:', error)
719+
}
720+
}
721+
693722
// 处理画质切换
694723
const handleQualityChange = (qualityName) => {
695724
const quality = availableQualities.value.find(q => q.name === qualityName)
@@ -713,6 +742,9 @@ const handleQualityChange = (qualityName) => {
713742
currentQuality.value = qualityName
714743
currentPlayingUrl.value = quality.url
715744
745+
// 更新控制栏中的画质文本
746+
updateQualityControlText()
747+
716748
// 触发画质切换事件,让父组件更新videoUrl
717749
// 父组件更新videoUrl后会触发watch监听器重新初始化播放器
718750
emit('quality-change', quality)

0 commit comments

Comments
 (0)