收藏
回答

android下录制的音频,在ios可以播放,android小程序端无法播放

问题模块 框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
API和组件 小程序 Bug createinnercontext 客户端 7.0.3 2.6.3 [234]

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


- 预期表现


- 复现路径


- 提供一个最简复现 Demo


音频下载地址:

http://ischool.h3c.com:9008/e930c5da-3c37-4659-bfba-7abd4b122833.aac

报错信息:

  1. {errCode10004errMsg"errCode:55, err:unknow format"}

    1. errCode:10004

    2. errMsg:"errCode:55, err:unknow format"

    3. __proto__:Object


PAR-AL00armeabi-v7a

28

7.0.3

2.6.3 [234]

409ms

Wi-Fi

代码段:

console.log("检测到点击")

let that = this

let name = e.currentTarget.dataset.id

let host = api.AudioDownload + name

let url = "http://ischool.h3c.com:9008/e930c5da-3c37-4659-bfba-7abd4b122833.aac"//host

audio.src = url

audio.startTime = 0

audio.autoplay = false

audio.loop = false

audio.obeyMuteSwitch = false

audio.volume = 1

//wx.setInnerAudioOption({obeyMuteSwitch:false});

console.log("监测点2", audio.src, audio.obeyMuteSwitch, audio.autoplay, audio.volume, audio)

if (!that.data.voiceProcessing) {

console.log("监测点3")

audio.play()

audio.onCanplay(() => {

console.log("监听音频进入可以播放状态的事件。但不保证后面可以流畅播放")

})

audio.onWaiting(()=>{

// debugger

console.log("start waiting");

})

audio.onError((res) => {

console.log("error",res);

console.log("监听音频播放错误事件")

})

audio.onPlay(

() => {

debugger

console.log("监听到Play")

that.setData({

voiceProcessing: true

})

}

)

audio.onEnded(

() => {

console.log("监听到end")

that.setData({

voiceProcessing: false

})

}

)

} else {

audio.pause()

audio.onPause(

() => {

audio.onPause(() => {

console.log("监听音频暂停事件")

})

that.setData({

voiceProcessing: false

})

}

)

}

请各位帮忙看下!

最后一次编辑于  03-19  (未经腾讯允许,不得转载)
邀请回答
复制链接收藏投诉关注问题回答

1 个回答

  • nickname
    nickname
    03-19

    你好,参考以下帖子看看

    android录制的音频无法使用InnerAudioContext播放

    https://developers.weixin.qq.com/community/develop/doc/000a88dd94c5f037a70807bb951c00

    03-19
    赞同
    回复 7
    • 高献光
      高献光
      03-20

      我昨天就看过那个方案啦,也试过啦,无效,微信api层面是否有办法解决呢?

      03-20
      回复
    • nickname
      nickname
      03-20回复高献光

      是改了格式也无效?给个代码片段看看呢:https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

      03-20
      回复
    • 高献光
      高献光
      03-21回复nickname

      小程序端的代码见上面所示,需要c++生成acc文件的代码吗?


      03-21
      回复
    • 高献光
      高献光
      03-21回复nickname

      public voidprepareAudio()

          {

             try

             {

                 isPrepared = false;

                 mIsRecording = false;

                 mIsCodecing = false;

       

                 File dir = newFile(mDir);              //创建文件夹

                 if (!dir.exists())

                 {

                     dir.mkdirs();

                 }

                 String fileName     = generateFileName();//随机生成文件名

                 mCurrentFilePath    = mDir + "/" + fileName;

                 mCurrentFile        = newFileOutputStream(mCurrentFilePath);

       

                 mPcmBufferSize      =AudioRecord.getMinBufferSize(AUDIO_SAMPLE_RATE, AUDIO_CHANNELS,

                                                                    AUDIO_FORMAT);

                 mPcmBufferSize      = mPcmBufferSize + (80 -mPcmBufferSize % 80);

                 mAudioProcBuffer    = new short[mPcmBufferSize];

                 mAudioProcBufAvalSize=0;

                 mAacEncodeBuffer    = new short[AUDIO_AAC_ENCODE_SAMPLE_SIZE];

                 mAacEncodeAvalSize  = 0;

                 mPcmQueue           = newConcurrentLinkedQueue<>();

                 mAudioRecorder      = new AudioRecord(AUDIO_SOURCE,AUDIO_SAMPLE_RATE, AUDIO_CHANNELS,

                                                       AUDIO_FORMAT, mPcmBufferSize);

                 mAudioRecorder.startRecording();

       

                 mWebrtcProcessor = new WebrtcProcessor();

                 mWebrtcProcessor.init(AUDIO_SAMPLE_RATE);

       

                 try

                 {

                     mMediaCodec = MediaCodec.createEncoderByType(MediaFormat.MIMETYPE_AUDIO_AAC);

                     MediaFormat mediaFormat =MediaFormat.createAudioFormat(MediaFormat.MIMETYPE_AUDIO_AAC,AudioRecordManager.AUDIO_SAMPLE_RATE, AudioRecordManager.AUDIO_CHANNEL_COUNT);

                     mediaFormat.setString(MediaFormat.KEY_MIME, MediaFormat.MIMETYPE_AUDIO_AAC);

                     mediaFormat.setInteger(MediaFormat.KEY_AAC_PROFILE,MediaCodecInfo.CodecProfileLevel.AACObjectLC);

                     mediaFormat.setInteger(MediaFormat.KEY_BIT_RATE,AudioRecordManager.AUDIO_BIT_RATE);

                     mediaFormat.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE,AudioRecordManager.AUDIO_SAMPLE_RATE * AudioRecordManager.AUDIO_CHANNEL_COUNT *2);

                     mMediaCodec.configure(mediaFormat, null, null,MediaCodec.CONFIGURE_FLAG_ENCODE);

                     mMediaCodec.start();

                     mInputBuffers =mMediaCodec.getInputBuffers();

                     mOutputBuffers = mMediaCodec.getOutputBuffers();

                 }

                 catch(IOException e)

                 {

                     e.printStackTrace();

                 }

       

                 isPrepared = true;      //准备结束

                 if (mListener != null)

                 {

                     mListener.wellPrepared();

                 }

             }

              catch(Exception e)

             {

                 e.printStackTrace();

             }

          }

         


      }


      03-21
      回复
    • nickname
      nickname
      03-21回复高献光

      麻烦提供这种格式的代码片段:https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

      03-21
      回复
    查看更多(2)