video标签层级很高,尝试了添加z-index,但无效果
通过查阅资料,得知cover-view层级比video层级高
效果图
需求是为了使直播时,可选是原画/流畅
解决方案
首先,在pages.json中配置右上角的图标
language
{
"path" : "pages/event/live",
"style" : {
"navigationBarTitleText": "直播详情",
"navigationBarTextStyle":"white",
"disableScroll": true,
"app-plus":{
"titleNView":{
"backgroundColor":"#010001",
"buttons":[{
"fontSrc": "/static/iconfontapp.ttf",
"text": "\ue66f",
"fontSize": "22px",
"color": "#FFFFFF"
},{
"fontSrc": "/static/iconfontapp.ttf",
"text": "\ue60b",
"fontSize": "22px",
"color": "#FFFFFF"
}]
}
}
}
},
然后在需要展示这个按钮的页面,加上操作方法
javascript
<template>
<view v-if="liveUrl">
<video class="v-video-play" autoplay
:src="liveUrl" controls
:show-progress="false">
<template v-if="speedShow && range && range.length">
<cover-view class="cover-box w100"></cover-view>
<cover-view v-for="(item, index) in range" :key="index" @click="selectitem(item.value)" class="sb-txt cf" :class="[{'cred': item.value == rangeValue},`f${index + 1}`]">{{ item.text }}</cover-view>
</template>
</video>
</view>
</template>
<script>
export default {
data() {
return {
rangeValue: 'FD', // 默认流畅
range: [], // 画质选项的列表
speedShow: false // 是否点击了切换的按钮
}
},
onNavigationBarButtonTap(button) {
let _event = this.event
if(button.index === 0) {//如果点击的是分享按钮
shareWx({
title: _event.title,
summary: '活动直播 - 墨天轮',
href: domain + `/event/live/${_event.id}`,
imageUrl: _event.shareImageUrl
})
} else if (button.index === 1) {//如果点击的是清晰度切换按钮
this.speedShow = !this.speedShow
}
},
}
</script>