收藏
回答

IOS12手机端切换闪光灯功能不生效

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug LivePusherContext.toggleTorch() 客户端 6.7.3 2.4.2

- 当前 Bug 的表现(可附上截图)


iphone6手机端点击切换闪光灯,无反应,控制台提示"operateLivePusher:fail", 无错误码。

安卓C8手机,切换正常。


- 预期表现


同一套代码,iphone手机端正常切换闪光灯。


- 复现路径


省略。


- 提供一个最简复现 Demo


<view class="page-body">
  <view class="page-section tc">
    <live-pusher id="pusher" url="rtmp://***/ford/cashi" mode="RTC" autopush bindstatechange="statechange" />
  
    <view class="btn-area">
      <button bindtap="bindStart" class="page-body-button" type="primary">播放推流</button>
      <button bindtap="bindPause" class="page-body-button" type="primary">暂停推流</button>
      <button bindtap="bindStop" class="page-body-button" type="primary">停止推流</button>
      <button bindtap="bindResume" class="page-body-button" type="primary">恢复推流</button>
      <button bindtap="bindSwitchCamera" class="page-body-button" type="primary">切换前后摄像头</button>
      <button bindtap="bindToggleTorch" class="page-body-button" type="primary">切换闪光灯</button>
    </view>
  </view>
</view>


Page({
  onReady(res) {
    this.ctx = wx.createLivePusherContext('pusher')
  },
  statechange(e) {
    console.log('live-pusher code:', e.detail.code)
  },
  bindStart() {
    this.ctx.start({
      success: res => {
        console.log('start success')
      },
      fail: res => {
        console.log('start fail')
      }
    })
  },
  bindPause() {
    this.ctx.pause({
      success: res => {
        console.log('pause success')
      },
      fail: res => {
        console.log('pause fail')
      }
    })
  },
  bindStop() {
    this.ctx.stop({
      success: res => {
        console.log('stop success')
      },
      fail: res => {
        console.log('stop fail')
      }
    })
  },
  bindResume() {
    this.ctx.resume({
      success: res => {
        console.log('resume success')
      },
      fail: res => {
        console.log('resume fail')
      }
    })
  },
  bindSwitchCamera() {
    this.ctx.switchCamera({
      success: res => {
        console.log('switchCamera success')
      },
      fail: res => {
        console.log('switchCamera fail')
      }
    })
  },
  bindToggleTorch() {
    this.ctx.toggleTorch({
      success: res => {
        console.log('toggleTorch success')
      },
      fail: res => {
        console.log('toggleTorch fail', res)
      }
    })
  }
})


最后一次编辑于  2018-12-17
回答关注问题邀请回答
收藏

2 个回答

登录 后发表内容