在live-player中使用cover-view自定义控制条,使用css属性transition和bottom实现控制条缓慢消失,在真机调试中控制条不会消失,去掉transition属性后,控制条就会消失。而在开发者工具就不会出现这样的问题。
真机调试:
开发者工具调试:
关键代码:
<live-player
id='live-player'
src="rtmp://58.200.131.2:1935/livetv/hunantv"
autoplay
:muted="!isVolume"
@netstatus="netchange"
@statechange="statechange"
@error="error"
style="width: 100%; height: 225px"
>
<!-- 防止用户拖动遮罩层 -->
<cover-view class="full" @click="showCtrls">
<!-- 控制条 -->
<cover-view
:class="(!isFull?'ctrls':'vertical-ctrls')+' u-flex u-flex-nowrap u-row-between'"
:style="'bottom:'+(!ctrlsShow?(isFull?'-50px':'-30px'):'0')"
>
<cover-view class="u-flex u-flex-nowrap">
<cover-image class="ctrls-icon" @click="play"
:src='baseUrl+"icon_play_"+(!isPlay?"on.png":"off.png")'>
</cover-image>
<cover-image class="ctrls-icon" @click="liveRefresh" :src="baseUrl+'icon_refresh.png'"></cover-image>
</cover-view>
<cover-view class="u-flex u-flex-nowrap">
<!-- <cover-image class="ctrls-icon" @click="play" :src="baseUrl+'icon_comment.png'"></cover-image> -->
<cover-image class="ctrls-icon" @click="()=>{this.isVolume=!this.isVolume}"
:src="baseUrl+'icon_volume_'+(isVolume?'on.png':'off.png')">
</cover-image>
<cover-image class="ctrls-icon fullIcon" @click="fullScreen"
:src="baseUrl+'icon_full_'+(!isFull?'on.png':'off.png')">
</cover-image>
</cover-view>
</cover-view>
</cover-view>
</live-player>
onLoad() {
// 创建 liveplayercontext
this.livePlayer = uni.createLivePlayerContext('live-player', this)
// 隐藏控制条
setTimeout(() => {this.ctrlsShow = false;console.log(666)}, 5000);
// this.ctrlsShow = false
},
.full{
width: 100%;
height: 100%;
background: transparent;
position: relative;
.ctrls{
background-color: rgba(0,0,0,.5);
width: 100vw;
height: 30px;
position: absolute;
bottom: 0;
padding: 0 10px;
box-sizing: border-box;
transition: 1s;
-webkit-transition: 1s;
.ctrls-icon{
width: 22px;
height: 22px;
margin-right: 15px;
}
.fullIcon{
margin-right: 0;
}
}
.vertical-ctrls{
background-color: rgba(0,0,0,.5);
width: 100vw;
height: 50px;
position: absolute;
bottom: 0;
padding: 0 30px;
box-sizing: border-box;
// transition: 1s;
.ctrls-icon{
width: 30px;
height: 30px;
margin-right: 30px;
}
.fullIcon{
margin-right: 0;
}
}
}
live-*组件已经实现了同层,使用view试下?