美文网首页
微信小程序live-player全屏设置

微信小程序live-player全屏设置

作者: xiesen | 来源:发表于2021-09-04 17:47 被阅读0次
效果 效果1.jpg 效果2.jpg

wxml

<view wx:if="{{!isFull}}">
  <cu-custom
    bgImage="http://guoxing-share.oss-cn-shanghai.aliyuncs.com/images/df9846ec-2992-4e53-8288-2a8d76741a51.png?Expires=3171606190&OSSAccessKeyId=LTAI4FmWK4wdCL5r7aLZesP4&Signature=qFSV7Hc1gph440RNOdJSWxxLg0U%3D"
    isBack="{{true}}">
    <view slot="backText"></view>
    <view slot="content" style="color: white;">直播</view>
  </cu-custom>
  <live-player class="player" src="rtmp://devlivepull.migucloud.com/live/67K2J8GO_C0_3" mode="RTC" autoplay
    catchtouchmove bindstatechange="statechange" binderror="error">
    <cover-view class='img-idv' bindtap="fullScreen">
      <cover-view class='view-number'>
        观看人数:290人
      </cover-view>
      <cover-view class='img-warp'>
        <cover-image src="../images/mine/confirmed.png" class='full-img' />
      </cover-view>
    </cover-view>
  </live-player>
</view>


<live-player wx:else class="full-player" src="rtmp://devlivepull.migucloud.com/live/67K2J8GO_C0_3" mode="RTC" autoplay
  catchtouchmove bindstatechange="statechange" binderror="error">
  <cover-view class='full-img-idv' bindtap="fullScreen">
    <cover-view class='full-view-number'>
      观看人数:290人
    </cover-view>
    <cover-view class='full-img-warp'>
      <cover-image src="../images/mine/confirmed.png" class='full-img' />
    </cover-view>
  </cover-view>
</live-player>

js

Page({
  data: {
    isFull: false,
  },
  statechange(e) {
    console.log('live-player code:', e.detail.code)
  },
  error(e) {
    console.error('live-player error:', e.detail.errMsg)
  },
  fullScreen: function() {
    this.setData({
      isFull: !this.data.isFull
    })
  }
})

wxss

.player{
  width: 100%; 
  height: 60vmin;
}
.img-idv{
  width: 100%;
  height: 100%;
  background:rgba(0, 0, 0, 0.2);
}
.view-number{
  background-color: #BFBFBF;
  height: 48rpx;
  display: inline-block;
  padding: 2rpx 30rpx;
  line-height: 48rpx;
  border-radius: 25rpx;
  margin-left: 20px;
  margin-top: 16rpx;
}
.img-warp{
  float: right;
  margin-top: 53vmin;
}
.full-img{
  width: 5vmin;
  height: 5vmin;
}
.full-player{
  width: 100%;
  height: 100vh;
} 
.full-view-number{
  margin-top: 5vh;
}
.full-img-warp{
  float: right;
  margin-top: 90vh;
}

相关文章

网友评论

      本文标题:微信小程序live-player全屏设置

      本文链接:https://www.haomeiwen.com/subject/uxirwltx.html