收藏
回答

微信原生的直播拉流组件中requestFullScreen()这个方法不生效?

组件名:<live-player></live-player>

基础库版本号:2.26.2

微信版本:8.0.34

//页面
<view bindtap="showFull">
  <view class="live-video" bindtap="showFull">
    <live-player id="livePlayer" src="{{liveUrl}}" mode="live" autoplay bindstatechange="statechange" binderror="error">
      <view class='full_img_idv' catchtap="hideFull" wx:if="{{showControls}}">
        <view class="col-box" bindtap="unFullScreen" wx:if="{{fullScreenFlag}}">
          退出全屏
        </view>
        <view class="col-box" wx:else bindtap="onFullScreen">
          全屏
        </view>
      </view>
    </live-player>
  </view>
</view>

//js
Page({
  data: {
        liveUrl:"",
    fullScreenFlagfalse,
    showControlsfalse,
    LivePlayerContext''
  },
  onLoad() {


  },
  showFull() {
    this.setData({
      showControlstrue
    })
  },
  hideFull() {
    this.setData({
      showControlsfalse
    })
  },
  onFullScreen() {
    console.log("点击全屏喽");
    let that = this
    this.data.LivePlayerContext = wx.createLivePlayerContext('livePlayer')
    debugger
    this.data.LivePlayerContext.requestFullScreen({
      direction90,
      success(e) {
        debugger
        that.setData({
          fullScreenFlagtrue
        })
      },
      fail(e) {
        debugger
        console.log(e)
      },
      complete(e) {
        debugger
        console.log(e)
      }
    })
  },
  unFullScreen() {
    let that = this
    this.data.LivePlayerContext.exitFullScreen({
      success(e) {
        that.setData({
          fullScreenFlagfalse
        })
      },
    })
  },
  statechange(e) {
    console.log('live-player code:', e.detail.code)
  },
  error(e) {
    console.error('live-player error:', e.detail.errMsg)
  }
})


回答关注问题邀请回答
收藏

2 个回答

登录 后发表内容