html52.com
我爱小程序-开发者交流社区

【bug】live-player设置src后调用play方法无效

问题模块 框架类型 API/组件名称 终端类型 操作系统 微信版本 基础库版本
API和组件 小程序 live-player/createLivePlayerContext 客户端 6.6.3 1.9.91


live-player设置src后直接调用play方法,在真机下无法播放,bindstatechange也没有被触发,

demo代码:


<live-player

   src="{{liveSrc}}"

   mode="live"

   id="live"

   bindstatechange="statechange"

/>


Page({

    data: {

        liveSrc: ''

    },

    onReady() {

       const that = this;

       

       this.player = wx.createLivePlayerContext('live');

       this.setData({

           liveSrc: 'rtmp://pull102.lizhi.fm/home/1591c13309c866a963ede100cb0321a4'

       }, () => {

           that.player.play();

       });

   }

})


以上代码不会播放,但是如果延迟play的调用,就可以正常播放:


Page({

    data: {

        liveSrc: ''

    },

   onReady() {

       const that = this;

       

       this.player = wx.createLivePlayerContext('live');

       this.setData({

           liveSrc: 'rtmp://pull102.lizhi.fm/home/1591c13309c866a963ede100cb0321a4'

       }, () => {

           setTimeout(() => {

               that.player.play();

           }, 1000);

       });

   }

})


评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付