【bug】live-player设置src后调用play方法无效
发布于 6 年前 作者 chaosun 9416 次浏览 来自 问答

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);

       });

   }

})

回到顶部