小程序中,背景音乐明明在播放,为什么返回的状态说我没有播放?

Aries
  • 544

小程序载入完成后,点击播放按钮,播放。
代码:

//index.js
//获取应用实例
var app = getApp();
Page({
    data: {
        currentPosition:0,
        currentTime: '00:00',
        duration: '00:00',
        progress:0,
        poster:'',
        songUrl:'',
        songName:'',
        songAuthor:'',
        audioIcon:'play',
        isPlaying:false,
    },
    onReady: function (e) {

    },
    onLoad: function () {
        this.setData({
            poster:'https://www.abc.com/0.jpg',
            songName:'似是故人来',
            songAuthor:'梅艳芳',
            songUrl:'http://www.abc.com/ssgrl.mp3'
        });
    },
    playAudio : function () {
        var that = this;
        if(!this.data.isPlaying){
            wx.playBackgroundAudio({
                dataUrl:this.data.songUrl,
                coverImgUrl:this.data.poster,
                title:this.data.songName,
                success:function (res) {
                    setInterval(() => {
                        wx.getBackgroundAudioPlayerState({
                            success: (res) => {
                                console.log(res);
                            },
                            fail:function (res) {
                                console.log(res);
                            }
                        })
                    }, 1000);
                },
                fail:function (res) {
                    console.log(res);
                }
            })
        }
    }
})

结果
图片描述

回复
阅读 2.8k
1 个回答
✓ 已被采纳

解决了,是官方的BUG,今天下午修复

宣传栏